Skip to content
Open
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
4 changes: 4 additions & 0 deletions apps/ff_cth/include/ct_domain.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

-include_lib("damsel/include/dmsl_domain_config_thrift.hrl").

-define(IDENTITY_PROVIDER_NAME1, <<"Test provider payinst#1">>).
-define(IDENTITY_PROVIDER_NAME2, <<"Test provider payinst#2">>).

-define(ordset(Es), ordsets:from_list(Es)).

-define(glob(), #domain_GlobalsRef{}).
Expand All @@ -22,6 +25,7 @@
-define(insp(ID), #domain_InspectorRef{id = ID}).
-define(payinst(ID), #domain_PaymentInstitutionRef{id = ID}).
-define(ruleset(ID), #domain_RoutingRulesetRef{id = ID}).
-define(identprov(Name), #domain_IdentityProviderRef{id = Name}).

-define(cash(Amount, SymCode), #domain_Cash{amount = Amount, currency = ?cur(SymCode)}).

Expand Down
10 changes: 6 additions & 4 deletions apps/ff_cth/src/ct_domain.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-export([term_set_hierarchy/2]).
-export([term_set_hierarchy/3]).
-export([timed_term_set/1]).
-export([globals/2]).
-export([globals/3]).
-export([withdrawal_provider/4]).
-export([withdrawal_terminal/1]).

Expand Down Expand Up @@ -437,13 +437,15 @@ timed_term_set(TermSet) ->
terms = TermSet
}.

-spec globals(?dtp('ExternalAccountSetRef'), [?dtp('PaymentInstitutionRef')]) -> object().
globals(EASRef, PIRefs) ->
-spec globals(?dtp('ExternalAccountSetRef'), [?dtp('PaymentInstitutionRef')], [?dtp('IdentityProviderRef')]) ->
object().
globals(EASRef, PIRefs, IPRefs) ->
{globals, #domain_GlobalsObject{
ref = ?glob(),
data = #domain_Globals{
external_account_set = {value, EASRef},
payment_institutions = ?ordset(PIRefs)
payment_institutions = ?ordset(PIRefs),
identity_providers = ?ordset(IPRefs)
}
}}.

Expand Down
47 changes: 24 additions & 23 deletions apps/ff_cth/src/ct_payment_system.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-module(ct_payment_system).

-include_lib("ff_cth/include/ct_domain.hrl").

-export([setup/0]).
-export([setup/1]).
-export([shutdown/1]).
Expand Down Expand Up @@ -75,8 +77,7 @@ start_processing_apps(Options) ->
woody,
dmt_client,
{fistful, [
{services, services(Options)},
{providers, identity_provider_config(Options)}
{services, services(Options)}
]},
ff_server
]),
Expand Down Expand Up @@ -156,12 +157,12 @@ configure_processing_apps(Options) ->
ok = create_crunch_identity(
payment_inst_identity_id(Options),
provider_identity_id(Options),
<<"good-one">>
?IDENTITY_PROVIDER_NAME1
),
ok = create_crunch_identity(
dummy_payment_inst_identity_id(Options),
dummy_provider_identity_id(Options),
<<"good-two">>
?IDENTITY_PROVIDER_NAME2
).

create_crunch_identity(PayInstIID, ProviderIID, ProviderID) ->
Expand All @@ -172,7 +173,7 @@ create_crunch_identity(PayInstIID, ProviderIID, ProviderID) ->

create_company_account() ->
PartyID = create_party(),
IdentityID = create_identity(PartyID, <<"good-one">>),
IdentityID = create_identity(PartyID, ?IDENTITY_PROVIDER_NAME1),
{ok, Currency} = ff_currency:get(<<"RUB">>),
{ok, IdentityMachine} = ff_identity_machine:get(IdentityID),
Identity = ff_identity_machine:identity(IdentityMachine),
Expand Down Expand Up @@ -207,22 +208,6 @@ do_set_env([Key | Path], Value, Env) ->
SubEnv = maps:get(Key, Env, #{}),
Env#{Key => do_set_env(Path, Value, SubEnv)}.

%% Default options
identity_provider_config(Options) ->
Default = #{
<<"good-one">> => #{
payment_institution_id => 1,
contract_template_id => 1,
contractor_level => full
},
<<"good-two">> => #{
payment_institution_id => 2,
contract_template_id => 1,
contractor_level => full
}
},
maps:get(identity_provider_config, Options, Default).

services(Options) ->
Default = #{
ff_withdrawal_adapter_host => "http://fistful-server:8022/v1/ff_withdrawal_adapter_host",
Expand Down Expand Up @@ -281,7 +266,10 @@ domain_config(Options, C) ->
]},

Default = [
ct_domain:globals(?eas(1), [?payinst(1)]),
ct_domain:globals(?eas(1), [?payinst(1)], [
?identprov(?IDENTITY_PROVIDER_NAME1),
?identprov(?IDENTITY_PROVIDER_NAME2)
]),
ct_domain:external_account_set(?eas(1), <<"Default">>, ?cur(<<"RUB">>), C),

routing_ruleset(?ruleset(1), <<"WithdrawalRuleset#1">>, WithdrawalDecision1),
Expand Down Expand Up @@ -596,7 +584,10 @@ domain_config(Options, C) ->
ct_domain:payment_method(?pmt(bank_card_deprecated, mastercard)),

ct_domain:payment_system(?pmtsys(<<"VISA">>), <<"VISA">>),
ct_domain:payment_system(?pmtsys(<<"NSPK MIR">>), <<"NSPK MIR">>)
ct_domain:payment_system(?pmtsys(<<"NSPK MIR">>), <<"NSPK MIR">>),

identity_provider(?identprov(?IDENTITY_PROVIDER_NAME1), ?payinst(1), ?tmpl(1)),
identity_provider(?identprov(?IDENTITY_PROVIDER_NAME2), ?payinst(2), ?tmpl(1))
],
maps:get(domain_config, Options, Default).

Expand Down Expand Up @@ -982,3 +973,13 @@ candidate(Allowed, Terminal) ->
allowed = Allowed,
terminal = Terminal
}.

identity_provider(Ref, PayInstRef, TmplRef) ->
{identity_provider, #domain_IdentityProviderObject{
ref = Ref,
data = #domain_IdentityProvider{
payment_institution = PayInstRef,
contract_template = TmplRef,
contractor_level = full
}
}}.
3 changes: 2 additions & 1 deletion apps/ff_server/src/ff_provider_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ handle_function_('GetProvider', {ID}, _Opts) ->
woody_error:raise(business, #fistful_ProviderNotFound{})
end;
handle_function_('ListProviders', _, _Opts) ->
{ok, marshal_providers(ff_provider:list())}.
Providers = ff_provider:list(),
{ok, marshal_providers(Providers)}.

%%

Expand Down
3 changes: 2 additions & 1 deletion apps/ff_server/test/ff_deposit_handler_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_deposit_handler_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("stdlib/include/assert.hrl").
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("fistful_proto/include/ff_proto_deposit_thrift.hrl").
Expand Down Expand Up @@ -688,7 +689,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
3 changes: 2 additions & 1 deletion apps/ff_server/test/ff_destination_handler_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_destination_handler_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("fistful_proto/include/ff_proto_destination_thrift.hrl").

-export([all/0]).
Expand Down Expand Up @@ -180,7 +181,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
9 changes: 5 additions & 4 deletions apps/ff_server/test/ff_eventsink_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_eventsink_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("fistful_proto/include/ff_proto_withdrawal_thrift.hrl").

-export([all/0]).
Expand Down Expand Up @@ -94,7 +95,7 @@ get_identity_events_ok(C) ->
id => ID,
name => Name,
party => Party,
provider => <<"good-one">>
provider => ?IDENTITY_PROVIDER_NAME1
},
#{<<"com.rbkmoney.wapi">> => #{<<"name">> => Name}}
),
Expand Down Expand Up @@ -269,7 +270,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down Expand Up @@ -359,8 +360,8 @@ process_withdrawal(WalID, DestID) ->
{Events, _MaxID} = ct_eventsink:events(undefined, 1000, Sink),
search_event_commited(Events, WdrID)
end,
% genlib_retry:linear(15, 1000)
genlib_retry:linear(5, 1000)
genlib_retry:linear(15, 1000)
% genlib_retry:linear(5, 1000)
),
WdrID.

Expand Down
9 changes: 3 additions & 6 deletions apps/ff_server/test/ff_identity_handler_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_identity_handler_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("stdlib/include/assert.hrl").
-include_lib("fistful_proto/include/ff_proto_identity_thrift.hrl").

Expand Down Expand Up @@ -63,7 +64,7 @@ create_identity_ok(_C) ->
PartyID = create_party(),
EID = genlib:unique(),
Name = <<"Identity Name">>,
ProvID = <<"good-one">>,
ProvID = ?IDENTITY_PROVIDER_NAME1,
Ctx = #{<<"NS">> => #{<<"owner">> => PartyID}},
Metadata = ff_entity_context_codec:marshal(#{<<"metadata">> => #{<<"some key">> => <<"some data">>}}),
Identity = create_identity(EID, Name, PartyID, ProvID, Ctx, Metadata),
Expand All @@ -87,7 +88,7 @@ get_event_unknown_identity_ok(_C) ->
EID = genlib:unique(),
PID = create_party(),
Name = <<"Identity Name">>,
ProvID = <<"good-one">>,
ProvID = ?IDENTITY_PROVIDER_NAME1,
Metadata = ff_entity_context_codec:marshal(#{<<"metadata">> => #{<<"some key">> => <<"some data">>}}),
create_identity(EID, Name, PID, ProvID, Ctx, Metadata),
Range = #'EventRange'{
Expand Down Expand Up @@ -128,7 +129,3 @@ create_party() ->
ID = genlib:bsuuid(),
_ = ff_party:create(ID),
ID.

%% CONFIGS

-include_lib("ff_cth/include/ct_domain.hrl").
5 changes: 3 additions & 2 deletions apps/ff_server/test/ff_provider_handler_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_provider_handler_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("stdlib/include/assert.hrl").
-include_lib("fistful_proto/include/ff_proto_provider_thrift.hrl").

Expand Down Expand Up @@ -73,8 +74,8 @@ end_per_testcase(_Name, _C) ->

-spec get_provider_ok(config()) -> test_return().
get_provider_ok(_C) ->
{ok, Provider} = call_service('GetProvider', {<<"good-one">>}),
?assertEqual(<<"good-one">>, Provider#provider_Provider.id),
{ok, Provider} = call_service('GetProvider', {?IDENTITY_PROVIDER_NAME1}),
?assertEqual(?IDENTITY_PROVIDER_NAME1, Provider#provider_Provider.id),
?assertEqual(<<"Generic Payment Institution">>, Provider#provider_Provider.name),
?assertEqual([<<"RUS">>], Provider#provider_Provider.residences).

Expand Down
3 changes: 2 additions & 1 deletion apps/ff_server/test/ff_source_handler_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

-include_lib("stdlib/include/assert.hrl").
-include_lib("fistful_proto/include/ff_proto_source_thrift.hrl").
-include_lib("ff_cth/include/ct_domain.hrl").

-export([all/0]).
-export([groups/0]).
Expand Down Expand Up @@ -172,7 +173,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
3 changes: 2 additions & 1 deletion apps/ff_server/test/ff_w2w_transfer_handler_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_w2w_transfer_handler_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("stdlib/include/assert.hrl").
-include_lib("fistful_proto/include/ff_proto_w2w_transfer_thrift.hrl").
-include_lib("shumpune_proto/include/shumpune_shumpune_thrift.hrl").
Expand Down Expand Up @@ -345,7 +346,7 @@ call_accounter(Function, Args) ->
ff_woody_client:call(accounter, {Service, Function, Args}, woody_context:new()).

create_identity(Party, C) ->
create_identity(Party, <<"good-two">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME2, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
3 changes: 2 additions & 1 deletion apps/ff_server/test/ff_wallet_handler_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_wallet_handler_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("stdlib/include/assert.hrl").
-include_lib("fistful_proto/include/ff_proto_wallet_thrift.hrl").
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
Expand Down Expand Up @@ -185,7 +186,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
3 changes: 2 additions & 1 deletion apps/ff_server/test/ff_withdrawal_handler_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(ff_withdrawal_handler_SUITE).

-include_lib("ff_cth/include/ct_domain.hrl").
-include_lib("stdlib/include/assert.hrl").
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("fistful_proto/include/ff_proto_withdrawal_thrift.hrl").
Expand Down Expand Up @@ -556,7 +557,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
3 changes: 2 additions & 1 deletion apps/ff_server/test/ff_withdrawal_session_repair_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-include_lib("stdlib/include/assert.hrl").
-include_lib("fistful_proto/include/ff_proto_withdrawal_session_thrift.hrl").
-include_lib("damsel/include/dmsl_domain_thrift.hrl").
-include_lib("ff_cth/include/ct_domain.hrl").

-export([all/0]).
-export([groups/0]).
Expand Down Expand Up @@ -129,7 +130,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"Owner">>, <<"good-one">>, C).
create_identity(Party, <<"Owner">>, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, Name, ProviderID, _C) ->
ID = genlib:unique(),
Expand Down
3 changes: 2 additions & 1 deletion apps/ff_transfer/test/ff_deposit_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

-include_lib("stdlib/include/assert.hrl").
-include_lib("damsel/include/dmsl_payment_processing_thrift.hrl").
-include_lib("ff_cth/include/ct_domain.hrl").

%% Common test API

Expand Down Expand Up @@ -291,7 +292,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
3 changes: 2 additions & 1 deletion apps/ff_transfer/test/ff_deposit_adjustment_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-module(ff_deposit_adjustment_SUITE).

-include_lib("stdlib/include/assert.hrl").
-include_lib("ff_cth/include/ct_domain.hrl").

%% Common test API

Expand Down Expand Up @@ -384,7 +385,7 @@ create_party(_C) ->
ID.

create_identity(Party, C) ->
create_identity(Party, <<"good-one">>, C).
create_identity(Party, ?IDENTITY_PROVIDER_NAME1, C).

create_identity(Party, ProviderID, C) ->
create_identity(Party, <<"Identity Name">>, ProviderID, C).
Expand Down
Loading