TD-717: Add global_allow field to routing (#93)

* TD-717: Add global_allow field to routing

* Remove ct:log

* Fix spec

* Bump dialyzer cache
This commit is contained in:
ndiezel0 2023-09-19 18:08:23 +05:00 committed by GitHub
parent deccc5a0a1
commit b8156b10e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 36 deletions

View File

@ -38,4 +38,4 @@ jobs:
thrift-version: ${{ needs.setup.outputs.thrift-version }}
run-ct-with-compose: true
use-coveralls: true
cache-version: v3
cache-version: v4

View File

@ -647,6 +647,7 @@ check_terms_acceptability(recurrent_payment, Terms, VS) ->
acceptable_payment_terms(
#domain_PaymentsProvisionTerms{
allow = Allow,
global_allow = GlobalAllow,
currencies = CurrenciesSelector,
categories = CategoriesSelector,
payment_methods = PMsSelector,
@ -660,7 +661,8 @@ acceptable_payment_terms(
% TODO varsets getting mixed up
% it seems better to pass down here hierarchy of contexts w/ appropriate module accessors
ParentName = 'PaymentsProvisionTerms',
_ = acceptable_allow(ParentName, Allow),
_ = acceptable_allow(ParentName, global_allow, GlobalAllow),
_ = acceptable_allow(ParentName, allow, Allow),
_ = try_accept_term(ParentName, currency, getv(currency, VS), CurrenciesSelector),
_ = try_accept_term(ParentName, category, getv(category, VS), CategoriesSelector),
_ = try_accept_term(ParentName, payment_tool, getv(payment_tool, VS), PMsSelector),
@ -723,14 +725,14 @@ acceptable_partial_refunds_terms(
acceptable_partial_refunds_terms(undefined, _RVS) ->
throw(?rejected({'PartialRefundsProvisionTerms', undefined})).
acceptable_allow(_ParentName, undefined) ->
acceptable_allow(_ParentName, _Type, undefined) ->
true;
acceptable_allow(_ParentName, {constant, true}) ->
acceptable_allow(_ParentName, _Type, {constant, true}) ->
true;
acceptable_allow(ParentName, {constant, false}) ->
throw(?rejected({ParentName, allow}));
acceptable_allow(_ParentName, Ambiguous) ->
error({misconfiguration, {'Could not reduce predicate to a value', {allow, Ambiguous}}}).
acceptable_allow(ParentName, Type, {constant, false}) ->
throw(?rejected({ParentName, Type}));
acceptable_allow(_ParentName, Type, Ambiguous) ->
error({misconfiguration, {'Could not reduce predicate to a value', {Type, Ambiguous}}}).
%%

View File

@ -177,6 +177,7 @@
-define(payment_terms, #domain_PaymentsProvisionTerms{
allow = {constant, true},
global_allow = {constant, true},
currencies =
{value,
?ordset([

View File

@ -249,7 +249,8 @@ mock_party_management(SupPid) ->
?candidate({constant, true}, ?trm(1)),
?candidate({constant, true}, ?trm(2)),
?candidate({constant, true}, ?trm(3)),
?candidate({constant, true}, ?trm(4))
?candidate({constant, true}, ?trm(4)),
?candidate({constant, true}, ?trm(7))
]}
}};
('ComputeRoutingRuleset', {?ruleset(1), ?base_routing_rule_domain_revision, _}) ->
@ -334,6 +335,13 @@ mock_party_management(SupPid) ->
allow = {constant, false}
}
}};
('ComputeProviderTerminalTerms', {?prv(7), _, ?base_routing_rule_domain_revision, _}) ->
{ok, #domain_ProvisionTermSet{
payments = ?payment_terms#domain_PaymentsProvisionTerms{
allow = {constant, true},
global_allow = {constant, false}
}
}};
('ComputeProviderTerminalTerms', {?prv(1), _, ?routing_with_risk_coverage_set_domain_revision, _}) ->
{ok, #domain_ProvisionTermSet{
payments = ?payment_terms#domain_PaymentsProvisionTerms{
@ -455,7 +463,8 @@ no_route_found_for_payment(_C) ->
{?prv(1), ?trm(1), {'PaymentsProvisionTerms', cost}},
{?prv(2), ?trm(2), {'PaymentsProvisionTerms', category}},
{?prv(3), ?trm(3), {'PaymentsProvisionTerms', payment_tool}},
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}}
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}},
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}}
],
RejectedRoutes1
),
@ -474,7 +483,8 @@ no_route_found_for_payment(_C) ->
{?prv(1), ?trm(1), {'PaymentsProvisionTerms', currency}},
{?prv(2), ?trm(2), {'PaymentsProvisionTerms', category}},
{?prv(3), ?trm(3), {'PaymentsProvisionTerms', payment_tool}},
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}}
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}},
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}}
],
RejectedRoutes2
).
@ -513,7 +523,8 @@ gather_route_success(_C) ->
[
{?prv(2), ?trm(2), {'PaymentsProvisionTerms', category}},
{?prv(3), ?trm(3), {'PaymentsProvisionTerms', payment_tool}},
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}}
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}},
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}}
],
RejectedRoutes
).
@ -553,7 +564,8 @@ rejected_by_table_prohibitions(_C) ->
{?prv(3), ?trm(3), {'RoutingRule', undefined}},
{?prv(1), ?trm(1), {'PaymentsProvisionTerms', payment_tool}},
{?prv(2), ?trm(2), {'PaymentsProvisionTerms', category}},
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}}
{?prv(4), ?trm(4), {'PaymentsProvisionTerms', allow}},
{?prv(7), ?trm(7), {'PaymentsProvisionTerms', global_allow}}
],
RejectedRoutes
),
@ -620,11 +632,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)]).
routes_selected_with_risk_score(C, low, [?prv(1), ?prv(2), ?prv(3), ?prv(4), ?prv(7)]).
-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)]).
routes_selected_with_risk_score(C, high, [?prv(2), ?prv(3), ?prv(4), ?prv(7)]).
routes_selected_with_risk_score(_C, RiskScore, ProviderRefs) ->
Currency = ?cur(<<"RUB">>),
@ -879,6 +891,7 @@ construct_domain_fixture() ->
{terminal, ?trm(4)} => {terminal, ?terminal_obj(?trm(4), ?prv(4))},
{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(11)} => {terminal, ?terminal_obj(?trm(11), ?prv(11))},
{terminal, ?trm(12)} => {terminal, ?terminal_obj(?trm(12), ?prv(12))},
{payment_institution, ?pinst(1)} =>

View File

@ -20,14 +20,14 @@ services:
limiter:
condition: service_healthy
shumway:
condition: service_healthy
condition: service_started
bender:
condition: service_healthy
working_dir: $PWD
command: /sbin/init
dominant:
image: ghcr.io/valitydev/dominant:sha-fdf5277
image: ghcr.io/valitydev/dominant:sha-486d2ef
command: /opt/dominant/bin/dominant foreground
depends_on:
machinegun:
@ -69,7 +69,7 @@ services:
machinegun:
condition: service_healthy
shumway:
condition: service_healthy
condition: service_started
healthcheck:
test: "/opt/limiter/bin/limiter ping"
interval: 5s
@ -77,8 +77,12 @@ services:
retries: 20
shumway:
image: docker.io/rbkmoney/shumway:44eb989065b27be619acd16b12ebdb2288b46c36
image: ghcr.io/valitydev/shumway:sha-658587c
restart: unless-stopped
depends_on:
- shumway-db
ports:
- "8022"
entrypoint:
- java
- -Xmx512m
@ -87,15 +91,10 @@ services:
- --spring.datasource.url=jdbc:postgresql://shumway-db:5432/shumway
- --spring.datasource.username=postgres
- --spring.datasource.password=postgres
- --management.metrics.export.statsd.enabled=false
depends_on:
shumway-db:
condition: service_healthy
- --management.endpoint.metrics.enabled=false
- --management.endpoint.prometheus.enabled=false
healthcheck:
test: "curl http://localhost:8023/actuator/health"
interval: 5s
timeout: 1s
retries: 40
disable: true
party-management:
image: ghcr.io/valitydev/party-management:sha-18bba50
@ -106,7 +105,7 @@ services:
dominant:
condition: service_started
shumway:
condition: service_healthy
condition: service_started
healthcheck:
test: "/opt/party-management/bin/party-management ping"
interval: 10s
@ -114,14 +113,10 @@ services:
retries: 10
shumway-db:
image: docker.io/library/postgres:9.6
image: docker.io/library/postgres:13.10
ports:
- "5432"
environment:
- POSTGRES_DB=shumway
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- SERVICE_NAME=shumway-db
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

View File

@ -17,7 +17,7 @@
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},2},
{<<"damsel">>,
{git,"https://github.com/valitydev/damsel.git",
{ref,"2374f52326fb9b10e79e0ec0a769af35529938e9"}},
{ref,"c65fc2e6a829f440a82720b3602b7bab4f30b71d"}},
0},
{<<"dmt_client">>,
{git,"https://github.com/valitydev/dmt-client.git",