Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/party_management/test/pm_ct_domain.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
-define(party(ID), #domain_PartyConfigRef{id = ID}).
-define(shop(ID), #domain_ShopConfigRef{id = ID}).
-define(wallet(ID), #domain_WalletConfigRef{id = ID}).
-define(lim(ID), #domain_LimitConfigRef{id = ID}).
-define(cur(ID), #domain_CurrencyRef{symbolic_code = ID}).
-define(pmt(C, T), #domain_PaymentMethodRef{id = {C, T}}).
-define(pmt_sys(ID), #domain_PaymentSystemRef{id = ID}).
Expand Down
12 changes: 8 additions & 4 deletions apps/party_management/test/pm_ct_fixture.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

-export([construct_party/1]).
-export([construct_shop_account/1]).
-export([construct_shop/6]).
-export([construct_shop/7]).
-export([construct_wallet_account/1]).
-export([construct_wallet/4]).
-export([construct_wallet/5]).
-export([construct_currency/1]).
-export([construct_currency/2]).
-export([construct_category/2]).
Expand Down Expand Up @@ -98,19 +98,21 @@ construct_shop_account(CurrencyCode) ->
-spec construct_shop(
dmsl_domain_thrift:'ShopConfigRef'(),
dmsl_domain_thrift:'PaymentInstitutionRef'(),
dmsl_domain_thrift:'TermSetHierarchyRef'(),
dmsl_domain_thrift:'ShopAccount'(),
dmsl_domain_thrift:'PartyConfigRef'(),
binary(),
dmsl_domain_thrift:'CategoryRef'()
) -> {shop_config, dmsl_domain_thrift:'ShopConfigObject'()}.
construct_shop(ShopRef, PaymentInstitutionRef, ShopAccount, PartyRef, ShopLocation, CategoryRef) ->
construct_shop(ShopRef, PaymentInstitutionRef, TermSetHierarchyRef, ShopAccount, PartyRef, ShopLocation, CategoryRef) ->
{shop_config, #domain_ShopConfigObject{
ref = ShopRef,
data = #domain_ShopConfig{
name = ShopRef#domain_ShopConfigRef.id,
block = make_unblocked(),
suspension = make_active(),
payment_institution = PaymentInstitutionRef,
terms = TermSetHierarchyRef,
account = ShopAccount,
party_ref = PartyRef,
location = {url, ShopLocation},
Expand All @@ -131,17 +133,19 @@ construct_wallet_account(CurrencyCode) ->
-spec construct_wallet(
dmsl_domain_thrift:'WalletConfigRef'(),
dmsl_domain_thrift:'PaymentInstitutionRef'(),
dmsl_domain_thrift:'TermSetHierarchyRef'(),
dmsl_domain_thrift:'WalletAccount'(),
dmsl_domain_thrift:'PartyConfigRef'()
) -> {wallet_config, dmsl_domain_thrift:'WalletConfigObject'()}.
construct_wallet(WalletRef, PaymentInstitutionRef, WalletAccount, PartyRef) ->
construct_wallet(WalletRef, PaymentInstitutionRef, TermSetHierarchyRef, WalletAccount, PartyRef) ->
{wallet_config, #domain_WalletConfigObject{
ref = WalletRef,
data = #domain_WalletConfig{
name = WalletRef#domain_WalletConfigRef.id,
block = make_unblocked(),
suspension = make_active(),
payment_institution = PaymentInstitutionRef,
terms = TermSetHierarchyRef,
account = WalletAccount,
party_ref = PartyRef
}
Expand Down
89 changes: 62 additions & 27 deletions apps/party_management/test/pm_party_tests_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-include_lib("damsel/include/dmsl_payproc_thrift.hrl").
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("damsel/include/dmsl_base_thrift.hrl").
-include_lib("damsel/include/dmsl_limiter_config_thrift.hrl").

-export([all/0]).
-export([groups/0]).
Expand Down Expand Up @@ -114,7 +115,8 @@ groups() ->
init_per_suite(C) ->
{Apps, _Ret} = pm_ct_helper:start_apps([woody, scoper, dmt_client, party_management]),
PartyRef = ?party(list_to_binary(lists:concat(["party.", erlang:system_time()]))),
_Rev = pm_domain:upsert(construct_domain_fixture(PartyRef)),
LimitsRev = pm_domain:upsert(constuct_limits_domain_fixture()),
_Rev = pm_domain:upsert(construct_domain_fixture(PartyRef, LimitsRev)),
[{apps, Apps}, {party_ref, PartyRef} | C].

-spec end_per_suite(config()) -> _.
Expand Down Expand Up @@ -349,24 +351,24 @@ compute_provider_terminal_terms_ok(C) ->
{value, [
%% In ordset fashion
#domain_TurnoverLimit{
id = <<"p_card_day_count">>,
ref = ?lim(<<"p_card_day_count">>),
upper_boundary = 1,
domain_revision = undefined
domain_revision = _
},
#domain_TurnoverLimit{
id = <<"payment_card_month_amount_rub">>,
ref = ?lim(<<"payment_card_month_amount_rub">>),
upper_boundary = 7500000,
domain_revision = undefined
domain_revision = _
},
#domain_TurnoverLimit{
id = <<"payment_card_month_count">>,
ref = ?lim(<<"payment_card_month_count">>),
upper_boundary = 10,
domain_revision = undefined
domain_revision = _
},
#domain_TurnoverLimit{
id = <<"payment_day_amount_rub">>,
ref = ?lim(<<"payment_day_amount_rub">>),
upper_boundary = 5000000,
domain_revision = undefined
domain_revision = _
}
]}
},
Expand Down Expand Up @@ -678,8 +680,39 @@ compute_pred_w_partially_irreducible_criterion(_) ->

%%

-spec construct_domain_fixture(dmsl_domain_thrift:'PartyConfigRef'()) -> [pm_domain:object()].
construct_domain_fixture(PartyRef) ->
-spec constuct_limits_domain_fixture() -> [pm_domain:object()].
constuct_limits_domain_fixture() ->
[
{limit_config, #domain_LimitConfigObject{
ref = #domain_LimitConfigRef{id = LimitID},
data = #limiter_config_LimitConfig{
processor_type = <<"TurnoverProcessor">>,
started_at = <<"2000-01-01T00:00:00Z">>,
shard_size = 12,
time_range_type = {calendar, {month, #limiter_config_TimeRangeTypeCalendarMonth{}}},
context_type = {payment_processing, #limiter_config_LimitContextTypePaymentProcessing{}},
type =
{turnover, #limiter_config_LimitTypeTurnover{
metric = {amount, #limiter_config_LimitTurnoverAmount{currency = <<"RUB">>}}
}},
scopes = ordsets:from_list([{shop, #limiter_config_LimitScopeEmptyDetails{}}]),
description = <<"description">>,
op_behaviour = #limiter_config_OperationLimitBehaviour{
invoice_payment_refund = {subtraction, #limiter_config_Subtraction{}}
}
}
}}
|| LimitID <- [
<<"payment_card_month_count">>,
<<"payment_card_month_amount_rub">>,
<<"payment_day_amount_rub">>,
<<"p_card_day_count">>
]
].

-spec construct_domain_fixture(dmsl_domain_thrift:'PartyConfigRef'(), dmsl_domain_conf_v2_thrift:'Version'()) ->
[pm_domain:object()].
construct_domain_fixture(PartyRef, PrevRev) ->
TestTermSet = #domain_TermSet{
payments = #domain_PaymentsServiceTerms{
currencies = {value, ordsets:from_list([?cur(<<"RUB">>)])},
Expand Down Expand Up @@ -1005,6 +1038,7 @@ construct_domain_fixture(PartyRef) ->
pm_ct_fixture:construct_shop(
?shop(?SHOP_ID),
?pinst(1),
?trms(2),
pm_ct_fixture:construct_shop_account(<<"RUB">>),
PartyRef,
<<"http://example.com">>,
Expand All @@ -1013,6 +1047,7 @@ construct_domain_fixture(PartyRef) ->
pm_ct_fixture:construct_wallet(
?wallet(?WALLET_ID),
?pinst(1),
?trms(2),
pm_ct_fixture:construct_wallet_account(<<"RUB">>),
PartyRef
),
Expand Down Expand Up @@ -1157,25 +1192,25 @@ construct_domain_fixture(PartyRef) ->
{value,
?ordset([
#domain_TurnoverLimit{
id = <<"payment_card_month_count">>,
ref = ?lim(<<"payment_card_month_count">>),
upper_boundary = 5,
domain_revision = undefined
domain_revision = PrevRev
},
%% Common limits
#domain_TurnoverLimit{
id = <<"payment_card_month_amount_rub">>,
ref = ?lim(<<"payment_card_month_amount_rub">>),
upper_boundary = 7500000,
domain_revision = undefined
domain_revision = PrevRev
},
#domain_TurnoverLimit{
id = <<"payment_day_amount_rub">>,
ref = ?lim(<<"payment_day_amount_rub">>),
upper_boundary = 5000000,
domain_revision = undefined
domain_revision = PrevRev
},
#domain_TurnoverLimit{
id = <<"p_card_day_count">>,
ref = ?lim(<<"p_card_day_count">>),
upper_boundary = 1,
domain_revision = undefined
domain_revision = PrevRev
}
])}
},
Expand All @@ -1194,25 +1229,25 @@ construct_domain_fixture(PartyRef) ->
{value,
?ordset([
#domain_TurnoverLimit{
id = <<"payment_card_month_count">>,
ref = ?lim(<<"payment_card_month_count">>),
upper_boundary = 10,
domain_revision = undefined
domain_revision = PrevRev
},
%% Common limits
#domain_TurnoverLimit{
id = <<"payment_card_month_amount_rub">>,
ref = ?lim(<<"payment_card_month_amount_rub">>),
upper_boundary = 7500000,
domain_revision = undefined
domain_revision = PrevRev
},
#domain_TurnoverLimit{
id = <<"payment_day_amount_rub">>,
ref = ?lim(<<"payment_day_amount_rub">>),
upper_boundary = 5000000,
domain_revision = undefined
domain_revision = PrevRev
},
#domain_TurnoverLimit{
id = <<"p_card_day_count">>,
ref = ?lim(<<"p_card_day_count">>),
upper_boundary = 1,
domain_revision = undefined
domain_revision = PrevRev
}
])}
}
Expand Down
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
command: /sbin/init

dmt:
image: ghcr.io/valitydev/dominant-v2:sha-bfed984
image: ghcr.io/valitydev/dominant-v2:sha-90f5fa2
command: /opt/dmt/bin/dmt foreground
healthcheck:
test: "/opt/dmt/bin/dmt ping"
Expand Down
4 changes: 2 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
{prometheus, "4.11.0"},
{prometheus_cowboy, "0.1.9"},
{woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}},
{damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.12"}}},
{damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.17"}}},
{payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}},
{dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {tag, "v2.0.3"}}},
{scoper, {git, "https://github.com/valitydev/scoper.git", {tag, "v1.1.0"}}},
{erl_health, {git, "https://github.com/valitydev/erlang-health.git", {branch, "master"}}},
{erl_health, {git, "https://github.com/valitydev/erlang-health.git", {tag, "v1.0.0"}}},

%% OpenTelemetry deps
{opentelemetry_api, "1.4.0"},
Expand Down
4 changes: 2 additions & 2 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
{<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2},
{<<"damsel">>,
{git,"https://github.com/valitydev/damsel.git",
{ref,"8cab698cd78125ac47489d0ba81169df376757a4"}},
{ref,"f831d3aa5fdfd0338b41af44d1eeffe810ca9708"}},
0},
{<<"dmt_client">>,
{git,"https://github.com/valitydev/dmt_client.git",
{ref,"20c18cc9b51d0f273db60c929e8a8a871d6a1866"}},
0},
{<<"erl_health">>,
{git,"https://github.com/valitydev/erlang-health.git",
{ref,"49716470d0e8dab5e37db55d52dea78001735a3d"}},
{ref,"63d34ef9fb60afea953dad9828330f4198614800"}},
0},
{<<"genlib">>,
{git,"https://github.com/valitydev/genlib.git",
Expand Down
Loading