mirror of
https://github.com/valitydev/hellgate.git
synced 2024-11-06 02:45:20 +00:00
Fix: Add blacklist bypass (#120)
* added * fixed dialyzer * minor * added constant bypass * fixed format * removed some tests * added env for score
This commit is contained in:
parent
872e076d33
commit
5c02fe6ce0
@ -43,20 +43,18 @@ check_blacklist(#{
|
||||
field_name = <<"CARD_TOKEN">>,
|
||||
value = Token
|
||||
},
|
||||
Result = issue_call(
|
||||
DeadLine = woody_deadline:from_timeout(genlib_app:env(hellgate, inspect_timeout, infinity)),
|
||||
{ok, Check} = issue_call(
|
||||
'IsBlacklisted',
|
||||
{Context},
|
||||
hg_proxy:get_call_options(
|
||||
Proxy,
|
||||
Revision
|
||||
)
|
||||
),
|
||||
false,
|
||||
DeadLine
|
||||
),
|
||||
case Result of
|
||||
{ok, Check} when is_atom(Check) ->
|
||||
Check;
|
||||
{exception, Error} ->
|
||||
error(Error)
|
||||
end;
|
||||
Check;
|
||||
check_blacklist(_Ctx) ->
|
||||
false.
|
||||
|
||||
@ -68,7 +66,7 @@ inspect(
|
||||
domain_revision = Revision
|
||||
} = Payment,
|
||||
#domain_Inspector{
|
||||
fallback_risk_score = FallBackRiskScore,
|
||||
fallback_risk_score = FallBackRiskScore0,
|
||||
proxy =
|
||||
Proxy = #domain_Proxy{
|
||||
ref = ProxyRef,
|
||||
@ -82,22 +80,24 @@ inspect(
|
||||
payment = get_payment_info(Shop, Invoice, Payment),
|
||||
options = maps:merge(ProxyDef#domain_ProxyDefinition.options, ProxyAdditional)
|
||||
},
|
||||
Result = issue_call(
|
||||
FallBackRiskScore1 =
|
||||
case FallBackRiskScore0 of
|
||||
undefined ->
|
||||
genlib_app:env(hellgate, inspect_score, high);
|
||||
Score ->
|
||||
Score
|
||||
end,
|
||||
{ok, RiskScore} = issue_call(
|
||||
'InspectPayment',
|
||||
{Context},
|
||||
hg_proxy:get_call_options(
|
||||
Proxy,
|
||||
Revision
|
||||
),
|
||||
FallBackRiskScore,
|
||||
FallBackRiskScore1,
|
||||
DeadLine
|
||||
),
|
||||
case Result of
|
||||
{ok, RiskScore} when is_atom(RiskScore) ->
|
||||
RiskScore;
|
||||
{exception, Error} ->
|
||||
error(Error)
|
||||
end.
|
||||
RiskScore.
|
||||
|
||||
get_payment_info(
|
||||
#domain_Shop{
|
||||
@ -157,12 +157,6 @@ get_payment_info(
|
||||
payment = ProxyPayment
|
||||
}.
|
||||
|
||||
issue_call(Func, Args, CallOpts) ->
|
||||
issue_call(Func, Args, CallOpts, undefined, undefined).
|
||||
|
||||
issue_call(Func, Args, CallOpts, undefined, _DeadLine) ->
|
||||
% Do not set custom deadline without fallback risk score
|
||||
hg_woody_wrapper:call(proxy_inspector, Func, Args, CallOpts);
|
||||
issue_call(Func, Args, CallOpts, Default, DeadLine) ->
|
||||
try hg_woody_wrapper:call(proxy_inspector, Func, Args, CallOpts, DeadLine) of
|
||||
{ok, _} = RiskScore ->
|
||||
|
@ -199,6 +199,7 @@ start_app(hellgate = AppName) ->
|
||||
refunded => {intervals, [1, 1, 1]}
|
||||
}},
|
||||
{inspect_timeout, 1000},
|
||||
{inspect_score, high},
|
||||
{fault_detector, #{
|
||||
timeout => 2000,
|
||||
enabled => false,
|
||||
|
@ -167,17 +167,12 @@
|
||||
-export([adhoc_repair_invalid_changes_failed/1]).
|
||||
-export([adhoc_repair_force_invalid_transition/1]).
|
||||
|
||||
-export([repair_fail_pre_processing_succeeded/1]).
|
||||
-export([repair_skip_inspector_succeeded/1]).
|
||||
-export([repair_fail_session_on_processed_succeeded/1]).
|
||||
-export([repair_fail_suspended_session_succeeded/1]).
|
||||
-export([repair_fail_session_on_pre_processing/1]).
|
||||
-export([repair_fail_session_on_refund_succeeded/1]).
|
||||
-export([repair_complex_first_scenario_succeeded/1]).
|
||||
-export([repair_complex_second_scenario_succeeded/1]).
|
||||
-export([repair_fulfill_session_on_processed_succeeded/1]).
|
||||
-export([repair_fulfill_suspended_session_succeeded/1]).
|
||||
-export([repair_fulfill_session_on_pre_processing_failed/1]).
|
||||
-export([repair_fulfill_session_with_trx_succeeded/1]).
|
||||
-export([repair_fulfill_session_on_refund_succeeded/1]).
|
||||
-export([repair_fulfill_session_on_captured_succeeded/1]).
|
||||
@ -454,17 +449,12 @@ groups() ->
|
||||
adhoc_repair_force_invalid_transition
|
||||
]},
|
||||
{repair_scenarios, [parallel], [
|
||||
repair_fail_pre_processing_succeeded,
|
||||
repair_skip_inspector_succeeded,
|
||||
repair_fail_session_on_processed_succeeded,
|
||||
repair_fail_suspended_session_succeeded,
|
||||
repair_fail_session_on_pre_processing,
|
||||
repair_fail_session_on_refund_succeeded,
|
||||
repair_complex_first_scenario_succeeded,
|
||||
repair_complex_second_scenario_succeeded,
|
||||
repair_fulfill_session_on_processed_succeeded,
|
||||
repair_fulfill_suspended_session_succeeded,
|
||||
repair_fulfill_session_on_pre_processing_failed,
|
||||
repair_fulfill_session_with_trx_succeeded,
|
||||
repair_fulfill_session_on_refund_succeeded,
|
||||
repair_fulfill_session_on_captured_succeeded
|
||||
@ -5196,57 +5186,6 @@ repair_fail_cash_flow_building_succeeded(C) ->
|
||||
]
|
||||
} = hg_client_invoicing:get_limit_values(InvoiceID, PaymentID, Client).
|
||||
|
||||
-spec repair_fail_pre_processing_succeeded(config()) -> test_return().
|
||||
repair_fail_pre_processing_succeeded(C) ->
|
||||
Client = cfg(client, C),
|
||||
PartyClient = cfg(party_client, C),
|
||||
ShopID = hg_ct_helper:create_battle_ready_shop(
|
||||
cfg(party_id, C),
|
||||
?cat(6),
|
||||
<<"RUB">>,
|
||||
?tmpl(2),
|
||||
?pinst(2),
|
||||
PartyClient
|
||||
),
|
||||
InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(10), 42000, C),
|
||||
% Invoice
|
||||
PaymentParams = make_payment_params(?pmt_sys(<<"visa-ref">>)),
|
||||
?payment_state(?payment(PaymentID)) = hg_client_invoicing:start_payment(InvoiceID, PaymentParams, Client),
|
||||
?payment_ev(PaymentID, ?payment_started(?payment_w_status(?pending()))) =
|
||||
next_change(InvoiceID, Client),
|
||||
|
||||
timeout = next_change(InvoiceID, 2000, Client),
|
||||
ok = repair_invoice_with_scenario(InvoiceID, fail_pre_processing, Client),
|
||||
?payment_ev(PaymentID, ?payment_status_changed(?failed({failure, _Failure}))) =
|
||||
next_change(InvoiceID, Client).
|
||||
|
||||
-spec repair_skip_inspector_succeeded(config()) -> test_return().
|
||||
repair_skip_inspector_succeeded(C) ->
|
||||
Client = cfg(client, C),
|
||||
PartyClient = cfg(party_client, C),
|
||||
ShopID = hg_ct_helper:create_battle_ready_shop(
|
||||
cfg(party_id, C),
|
||||
?cat(6),
|
||||
<<"RUB">>,
|
||||
?tmpl(2),
|
||||
?pinst(2),
|
||||
PartyClient
|
||||
),
|
||||
InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(10), 42000, C),
|
||||
% Invoice
|
||||
PaymentParams = make_payment_params(?pmt_sys(<<"visa-ref">>)),
|
||||
?payment_state(?payment(PaymentID)) = hg_client_invoicing:start_payment(InvoiceID, PaymentParams, Client),
|
||||
?payment_ev(PaymentID, ?payment_started(?payment_w_status(?pending()))) =
|
||||
next_change(InvoiceID, Client),
|
||||
|
||||
timeout = next_change(InvoiceID, 2000, Client),
|
||||
ok = repair_invoice_with_scenario(InvoiceID, skip_inspector, Client),
|
||||
_ = await_payment_cash_flow(low, ?route(?prv(2), ?trm(7)), InvoiceID, PaymentID, Client),
|
||||
?payment_ev(PaymentID, ?session_ev(?processed(), ?session_started())) =
|
||||
next_change(InvoiceID, Client),
|
||||
PaymentID = await_payment_process_finish(InvoiceID, PaymentID, Client),
|
||||
PaymentID = await_payment_capture(InvoiceID, PaymentID, Client).
|
||||
|
||||
-spec repair_fail_session_on_processed_succeeded(config()) -> test_return().
|
||||
repair_fail_session_on_processed_succeeded(C) ->
|
||||
Client = cfg(client, C),
|
||||
@ -5298,67 +5237,6 @@ repair_fail_suspended_session_succeeded(C) ->
|
||||
?payment_ev(PaymentID, ?payment_status_changed(?failed({failure, Failure})))
|
||||
] = next_changes(InvoiceID, 3, Client).
|
||||
|
||||
-spec repair_fail_session_on_pre_processing(config()) -> test_return().
|
||||
repair_fail_session_on_pre_processing(C) ->
|
||||
Client = cfg(client, C),
|
||||
PartyClient = cfg(party_client, C),
|
||||
ShopID = hg_ct_helper:create_battle_ready_shop(
|
||||
cfg(party_id, C),
|
||||
?cat(7),
|
||||
<<"RUB">>,
|
||||
?tmpl(2),
|
||||
?pinst(2),
|
||||
PartyClient
|
||||
),
|
||||
InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(10), 42000, C),
|
||||
PaymentParams = make_payment_params(?pmt_sys(<<"visa-ref">>)),
|
||||
?payment_state(?payment(PaymentID)) = hg_client_invoicing:start_payment(InvoiceID, PaymentParams, Client),
|
||||
?payment_ev(PaymentID, ?payment_started(?payment_w_status(?pending()))) =
|
||||
next_change(InvoiceID, Client),
|
||||
|
||||
timeout = next_change(InvoiceID, 2000, Client),
|
||||
?assertException(
|
||||
error,
|
||||
{{woody_error, {external, result_unexpected, _}}, _},
|
||||
repair_invoice_with_scenario(InvoiceID, {fail_session, construct_authorization_failure()}, Client)
|
||||
),
|
||||
ok = repair_invoice_with_scenario(InvoiceID, fail_pre_processing, Client),
|
||||
?payment_ev(PaymentID, ?payment_status_changed(?failed({failure, _Failure}))) =
|
||||
next_change(InvoiceID, Client).
|
||||
|
||||
-spec repair_complex_first_scenario_succeeded(config()) -> test_return().
|
||||
repair_complex_first_scenario_succeeded(C) ->
|
||||
Client = cfg(client, C),
|
||||
PartyClient = cfg(party_client, C),
|
||||
ShopID = hg_ct_helper:create_battle_ready_shop(
|
||||
cfg(party_id, C),
|
||||
?cat(6),
|
||||
<<"RUB">>,
|
||||
?tmpl(2),
|
||||
?pinst(2),
|
||||
PartyClient
|
||||
),
|
||||
InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(10), 42000, C),
|
||||
% Invoice
|
||||
PaymentParams = make_payment_params(?pmt_sys(<<"visa-ref">>)),
|
||||
?payment_state(?payment(PaymentID)) = hg_client_invoicing:start_payment(InvoiceID, PaymentParams, Client),
|
||||
?payment_ev(PaymentID, ?payment_started(?payment_w_status(?pending()))) =
|
||||
next_change(InvoiceID, Client),
|
||||
|
||||
timeout = next_change(InvoiceID, 2000, Client),
|
||||
|
||||
Scenarios = [
|
||||
skip_inspector,
|
||||
{fail_session, construct_authorization_failure()}
|
||||
],
|
||||
ok = repair_invoice_with_scenario(InvoiceID, Scenarios, Client),
|
||||
|
||||
_ = await_payment_cash_flow(low, ?route(?prv(2), ?trm(7)), InvoiceID, PaymentID, Client),
|
||||
?payment_ev(PaymentID, ?session_ev(?processed(), ?session_started())) =
|
||||
next_change(InvoiceID, Client),
|
||||
PaymentID = await_payment_process_finish(InvoiceID, PaymentID, Client),
|
||||
PaymentID = await_payment_capture(InvoiceID, PaymentID, Client).
|
||||
|
||||
-spec repair_complex_second_scenario_succeeded(config()) -> test_return().
|
||||
repair_complex_second_scenario_succeeded(C) ->
|
||||
Client = cfg(client, C),
|
||||
@ -5484,34 +5362,6 @@ repair_fulfill_session_on_captured_succeeded(C) ->
|
||||
|
||||
PaymentID = await_payment_capture_finish(InvoiceID, PaymentID, Reason, Client).
|
||||
|
||||
-spec repair_fulfill_session_on_pre_processing_failed(config()) -> test_return().
|
||||
repair_fulfill_session_on_pre_processing_failed(C) ->
|
||||
Client = cfg(client, C),
|
||||
PartyClient = cfg(party_client, C),
|
||||
ShopID = hg_ct_helper:create_battle_ready_shop(
|
||||
cfg(party_id, C),
|
||||
?cat(7),
|
||||
<<"RUB">>,
|
||||
?tmpl(2),
|
||||
?pinst(2),
|
||||
PartyClient
|
||||
),
|
||||
InvoiceID = start_invoice(ShopID, <<"rubberduck">>, make_due_date(10), 42000, C),
|
||||
PaymentParams = make_payment_params(?pmt_sys(<<"visa-ref">>)),
|
||||
?payment_state(?payment(PaymentID)) = hg_client_invoicing:start_payment(InvoiceID, PaymentParams, Client),
|
||||
?payment_ev(PaymentID, ?payment_started(?payment_w_status(?pending()))) =
|
||||
next_change(InvoiceID, Client),
|
||||
|
||||
timeout = next_change(InvoiceID, 2000, Client),
|
||||
?assertException(
|
||||
error,
|
||||
{{woody_error, {external, result_unexpected, _}}, _},
|
||||
repair_invoice_with_scenario(InvoiceID, fulfill_session, Client)
|
||||
),
|
||||
ok = repair_invoice_with_scenario(InvoiceID, fail_pre_processing, Client),
|
||||
?payment_ev(PaymentID, ?payment_status_changed(?failed({failure, _Failure}))) =
|
||||
next_change(InvoiceID, Client).
|
||||
|
||||
-spec repair_fulfill_session_with_trx_succeeded(config()) -> test_return().
|
||||
repair_fulfill_session_with_trx_succeeded(C) ->
|
||||
Client = cfg(client, C),
|
||||
|
Loading…
Reference in New Issue
Block a user