mirror of
https://github.com/valitydev/bouncer-client-erlang.git
synced 2024-11-06 00:25:18 +00:00
Bump to rbkmoney/bouncer-proto@7ac8871 (#8)
Add "owned" party to organization ctx.
This commit is contained in:
parent
f01fc16219
commit
36cb53a7d4
@ -2,7 +2,7 @@
|
||||
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},3},
|
||||
{<<"bouncer_proto">>,
|
||||
{git,"git@github.com:rbkmoney/bouncer-proto.git",
|
||||
{ref,"20f3ecd77412f1d317ba41c0ef1c5fb3cdbbde11"}},
|
||||
{ref,"7ac88717904c6bab73096198b308380e006ed42c"}},
|
||||
0},
|
||||
{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
|
||||
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},2},
|
||||
|
@ -65,6 +65,7 @@
|
||||
-type user_org() :: #{
|
||||
id => id(),
|
||||
owner => entity(),
|
||||
party => entity(),
|
||||
roles => [user_role()]
|
||||
}.
|
||||
|
||||
@ -244,12 +245,13 @@ maybe_marshal_user_orgs(Orgs) ->
|
||||
maybe_marshal_user_org(Org) ->
|
||||
ID = maybe_get_param(id, Org),
|
||||
OwnerEntity = maybe_get_param(owner, Org),
|
||||
PartyEntity = maybe_get_param(party, Org),
|
||||
Roles = maybe_get_param(roles, Org),
|
||||
|
||||
#bctx_v1_Organization{
|
||||
id = ID,
|
||||
owner = maybe_add_param(maybe_marshal_entity(OwnerEntity), OwnerEntity),
|
||||
roles = maybe_add_param(maybe_marshal_user_roles(Roles), Roles)
|
||||
owner = maybe_marshal_entity(OwnerEntity),
|
||||
party = maybe_marshal_entity(PartyEntity),
|
||||
roles = maybe_marshal_user_roles(Roles)
|
||||
}.
|
||||
|
||||
maybe_marshal_user_roles(undefined) ->
|
||||
|
@ -113,23 +113,33 @@ empty_judge(C) ->
|
||||
|
||||
-spec validate_user_fragment(config()) -> _.
|
||||
validate_user_fragment(C) ->
|
||||
UserID = <<"someUser">>,
|
||||
UserRealm = <<"external">>,
|
||||
UserID = <<"somebody">>,
|
||||
UserRealm = <<"once">>,
|
||||
OrgID = <<"told">>,
|
||||
PartyID = <<"me">>,
|
||||
mock_services(
|
||||
[
|
||||
{bouncer, fun('Judge', {_RulesetID, Fragments}) ->
|
||||
case get_fragment(<<"user">>, Fragments) of
|
||||
Auth = get_fragment(<<"user">>, Fragments),
|
||||
?assertEqual(
|
||||
#bctx_v1_ContextFragment{
|
||||
user = #bctx_v1_User{id = UserID, realm = #bctx_v1_Entity{id = UserRealm}}
|
||||
} ->
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}}
|
||||
}};
|
||||
_ ->
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {forbidden, #bdcs_ResolutionForbidden{}}
|
||||
}}
|
||||
end
|
||||
user = #bctx_v1_User{
|
||||
id = UserID,
|
||||
realm = #bctx_v1_Entity{id = UserRealm},
|
||||
orgs = [
|
||||
#bctx_v1_Organization{
|
||||
id = OrgID,
|
||||
party = #bctx_v1_Entity{id = PartyID},
|
||||
owner = #bctx_v1_Entity{id = UserID}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
Auth
|
||||
),
|
||||
{ok, #bdcs_Judgement{
|
||||
resolution = {allowed, #bdcs_ResolutionAllowed{}}
|
||||
}}
|
||||
end}
|
||||
],
|
||||
C
|
||||
@ -141,7 +151,8 @@ validate_user_fragment(C) ->
|
||||
fragments => #{
|
||||
<<"user">> => bouncer_context_helpers:make_user_fragment(#{
|
||||
id => UserID,
|
||||
realm => #{id => UserRealm}
|
||||
realm => #{id => UserRealm},
|
||||
orgs => [#{id => OrgID, party => #{id => PartyID}, owner => #{id => UserID}}]
|
||||
})
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user