IMP-112: Filter out is_enabled = false candidates

This commit is contained in:
Rustem Shaydullin 2024-02-16 16:21:57 +03:00
parent 578bbc8571
commit 46666e33ce
No known key found for this signature in database
GPG Key ID: 098B14A3236B5DFD
4 changed files with 32 additions and 13 deletions

View File

@ -251,7 +251,17 @@ mock_party_management(SupPid) ->
?candidate({constant, true}, ?trm(2)),
?candidate({constant, true}, ?trm(3)),
?candidate({constant, true}, ?trm(4)),
?candidate({constant, true}, ?trm(7))
?candidate({constant, true}, ?trm(7)),
#domain_RoutingCandidate{
allowed = {constant, true},
terminal = ?trm(8),
is_enabled = false
},
#domain_RoutingCandidate{
allowed = {constant, true},
terminal = ?trm(9),
is_enabled = true
}
]}
}};
('ComputeRoutingRuleset', {?ruleset(1), ?base_routing_rule_domain_revision, _}) ->
@ -467,7 +477,8 @@ no_route_found_for_payment(_C) ->
{?prv(2), ?trm(2), {'PaymentsProvisionTerms', category}},
{?prv(3), ?trm(3), {'PaymentsProvisionTerms', payment_tool}},
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}},
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}}
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}},
{?prv(9), ?trm(9), {'PaymentsProvisionTerms', cost}}
],
RejectedRoutes1
),
@ -489,7 +500,8 @@ no_route_found_for_payment(_C) ->
{?prv(2), ?trm(2), {'PaymentsProvisionTerms', category}},
{?prv(3), ?trm(3), {'PaymentsProvisionTerms', payment_tool}},
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}},
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}}
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}},
{?prv(9), ?trm(9), {'PaymentsProvisionTerms', currency}}
],
RejectedRoutes2
).
@ -516,7 +528,7 @@ gather_route_success(_C) ->
party_id => ?dummy_party_id,
client_ip => undefined
},
{ok, {[Route], RejectedRoutes}} = unwrap_routing_context(
{ok, {[Route | _], RejectedRoutes}} = unwrap_routing_context(
hg_routing:gather_routes(payment, PaymentInstitution, VS, Revision, Ctx)
),
?assertMatch(?trm(1), hg_route:terminal_ref(Route)),
@ -568,7 +580,8 @@ rejected_by_table_prohibitions(_C) ->
{?prv(1), ?trm(1), {'PaymentsProvisionTerms', payment_tool}},
{?prv(2), ?trm(2), {'PaymentsProvisionTerms', category}},
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}},
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}}
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}},
{?prv(9), ?trm(9), {'PaymentsProvisionTerms', payment_tool}}
],
RejectedRoutes
),
@ -629,11 +642,11 @@ ruleset_misconfig(_C) ->
-spec routes_selected_for_low_risk_score(config()) -> test_return().
routes_selected_for_low_risk_score(C) ->
routes_selected_with_risk_score(C, low, [?prv(1), ?prv(2), ?prv(3), ?prv(4), ?prv(7)]).
routes_selected_with_risk_score(C, low, [?prv(1), ?prv(2), ?prv(3), ?prv(4), ?prv(7), ?prv(9)]).
-spec routes_selected_for_high_risk_score(config()) -> test_return().
routes_selected_for_high_risk_score(C) ->
routes_selected_with_risk_score(C, high, [?prv(2), ?prv(3), ?prv(4), ?prv(7)]).
routes_selected_with_risk_score(C, high, [?prv(2), ?prv(3), ?prv(4), ?prv(7), ?prv(9)]).
routes_selected_with_risk_score(_C, RiskScore, ProviderRefs) ->
Currency = ?cur(<<"RUB">>),
@ -891,6 +904,8 @@ construct_domain_fixture() ->
{provider, ?prv(5)} => {provider, ?provider_obj(?prv(5), #domain_ProvisionTermSet{})},
{provider, ?prv(6)} => {provider, ?provider_obj(?prv(6), #domain_ProvisionTermSet{})},
{provider, ?prv(7)} => {provider, ?provider_obj(?prv(7), #domain_ProvisionTermSet{})},
{provider, ?prv(8)} => {provider, ?provider_obj(?prv(8), #domain_ProvisionTermSet{})},
{provider, ?prv(9)} => {provider, ?provider_obj(?prv(9), #domain_ProvisionTermSet{})},
{provider, ?prv(11)} => {provider, ?provider_obj(?prv(11), #domain_ProvisionTermSet{})},
{provider, ?prv(12)} => {provider, ?provider_obj(?prv(12), #domain_ProvisionTermSet{})},
{terminal, ?trm(1)} => {terminal, ?terminal_obj(?trm(1), ?prv(1), undefined)},
@ -900,6 +915,8 @@ construct_domain_fixture() ->
{terminal, ?trm(5)} => {terminal, ?terminal_obj(?trm(5), ?prv(5))},
{terminal, ?trm(6)} => {terminal, ?terminal_obj(?trm(6), ?prv(6))},
{terminal, ?trm(7)} => {terminal, ?terminal_obj(?trm(7), ?prv(7))},
{terminal, ?trm(8)} => {terminal, ?terminal_obj(?trm(8), ?prv(8))},
{terminal, ?trm(9)} => {terminal, ?terminal_obj(?trm(9), ?prv(9))},
{terminal, ?trm(11)} => {terminal, ?terminal_obj(?trm(11), ?prv(11))},
{terminal, ?trm(12)} => {terminal, ?terminal_obj(?trm(12), ?prv(12))},
{payment_institution, ?pinst(1)} =>

View File

@ -186,14 +186,16 @@ get_decisions_candidates(#domain_RoutingRuleset{decisions = Decisions}) ->
{delegates, _Delegates} ->
throw({misconfiguration, {routing_decisions, Decisions}});
{candidates, Candidates} ->
ok = validate_decisions_candidates(Candidates),
Candidates
ValidatedCandidates = validate_decisions_candidates(Candidates),
ValidatedCandidates
end.
validate_decisions_candidates([]) ->
ok;
validate_decisions_candidates([#domain_RoutingCandidate{allowed = {constant, true}} | Rest]) ->
[];
validate_decisions_candidates([#domain_RoutingCandidate{is_enabled = false} | Rest]) ->
validate_decisions_candidates(Rest);
validate_decisions_candidates([#domain_RoutingCandidate{allowed = {constant, true}} = C | Rest]) ->
[C | validate_decisions_candidates(Rest)];
validate_decisions_candidates([Candidate | _]) ->
throw({misconfiguration, {routing_candidate, Candidate}}).

View File

@ -27,7 +27,7 @@ services:
command: /sbin/init
dominant:
image: ghcr.io/valitydev/dominant:sha-2150eea
image: ghcr.io/valitydev/dominant:sha-bec333e
command: /opt/dominant/bin/dominant foreground
depends_on:
machinegun:

View File

@ -21,7 +21,7 @@
{<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2},
{<<"damsel">>,
{git,"https://github.com/valitydev/damsel.git",
{ref,"decfa45d7ce4b3c948957c6ddba34742aaa9fdc5"}},
{ref,"03fe1f0c8f96781eb11462d537b365362eb04719"}},
0},
{<<"dmt_client">>,
{git,"https://github.com/valitydev/dmt-client.git",