mirror of
https://github.com/valitydev/bouncer.git
synced 2024-11-06 02:15:18 +00:00
MSPF-591: Update bouncer_proto (#11)
* MSPF-591: Update bouncer_proto * MSPF-591: Fix lint * MSPF-591: Update proto
This commit is contained in:
parent
c9f70695cc
commit
2445f446d6
@ -2,7 +2,7 @@
|
|||||||
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2},
|
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2},
|
||||||
{<<"bouncer_proto">>,
|
{<<"bouncer_proto">>,
|
||||||
{git,"git@github.com:rbkmoney/bouncer-proto.git",
|
{git,"git@github.com:rbkmoney/bouncer-proto.git",
|
||||||
{ref,"ea44337686d65fa8e72cdb02c4b73dafd5cafc09"}},
|
{ref,"aab9db7ecc0ff436acc81f3358ae52239559ce7b"}},
|
||||||
0},
|
0},
|
||||||
{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
|
{<<"cache">>,{pkg,<<"cache">>,<<"2.2.0">>},1},
|
||||||
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},2},
|
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},2},
|
||||||
|
@ -81,14 +81,20 @@ handle_network_error({unknown, Reason} = Error, St) ->
|
|||||||
thrift_judgement().
|
thrift_judgement().
|
||||||
encode_judgement({Resolution, _Assertions}) ->
|
encode_judgement({Resolution, _Assertions}) ->
|
||||||
#bdcs_Judgement{
|
#bdcs_Judgement{
|
||||||
|
resolution_legacy = encode_resolution_legacy(Resolution),
|
||||||
resolution = encode_resolution(Resolution)
|
resolution = encode_resolution(Resolution)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
encode_resolution(allowed) ->
|
encode_resolution_legacy(allowed) ->
|
||||||
allowed;
|
allowed;
|
||||||
encode_resolution(forbidden) ->
|
encode_resolution_legacy(forbidden) ->
|
||||||
forbidden.
|
forbidden.
|
||||||
|
|
||||||
|
encode_resolution(allowed) ->
|
||||||
|
{allowed, #bdcs_ResolutionAllowed{}};
|
||||||
|
encode_resolution(forbidden) ->
|
||||||
|
{forbidden, #bdcs_ResolutionForbidden{}}.
|
||||||
|
|
||||||
-spec decode_context(thrift_context(), st()) ->
|
-spec decode_context(thrift_context(), st()) ->
|
||||||
{bouncer_context:ctx(), st()}.
|
{bouncer_context:ctx(), st()}.
|
||||||
decode_context(#bdcs_Context{fragments = FragmentsIn}, St0) ->
|
decode_context(#bdcs_Context{fragments = FragmentsIn}, St0) ->
|
||||||
|
@ -167,7 +167,8 @@ end_per_testcase(_Name, _C) ->
|
|||||||
%%
|
%%
|
||||||
|
|
||||||
-define(CONTEXT(Fragments), #bdcs_Context{fragments = Fragments}).
|
-define(CONTEXT(Fragments), #bdcs_Context{fragments = Fragments}).
|
||||||
-define(JUDGEMENT(Resolution), #bdcs_Judgement{resolution = Resolution}).
|
-define(JUDGEMENT(Resolution, ResolutionLegacy),
|
||||||
|
#bdcs_Judgement{resolution = Resolution, resolution_legacy = ResolutionLegacy}).
|
||||||
|
|
||||||
-spec missing_ruleset_notfound(config()) -> ok.
|
-spec missing_ruleset_notfound(config()) -> ok.
|
||||||
-spec incorrect_ruleset_invalid1(config()) -> ok.
|
-spec incorrect_ruleset_invalid1(config()) -> ok.
|
||||||
@ -361,7 +362,7 @@ allowed_create_invoice_shop_manager(C) ->
|
|||||||
]),
|
]),
|
||||||
Context = ?CONTEXT(#{<<"root">> => mk_ctx_v1_fragment(Fragment)}),
|
Context = ?CONTEXT(#{<<"root">> => mk_ctx_v1_fragment(Fragment)}),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
?JUDGEMENT(allowed),
|
?JUDGEMENT({allowed, #bdcs_ResolutionAllowed{}}, allowed),
|
||||||
call_judge(?API_RULESET_ID, Context, Client)
|
call_judge(?API_RULESET_ID, Context, Client)
|
||||||
),
|
),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
@ -380,7 +381,7 @@ forbidden_expired(C) ->
|
|||||||
}),
|
}),
|
||||||
Context = ?CONTEXT(#{<<"root">> => mk_ctx_v1_fragment(Fragment)}),
|
Context = ?CONTEXT(#{<<"root">> => mk_ctx_v1_fragment(Fragment)}),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
?JUDGEMENT(forbidden),
|
?JUDGEMENT({forbidden, #bdcs_ResolutionForbidden{}}, forbidden),
|
||||||
call_judge(?API_RULESET_ID, Context, Client)
|
call_judge(?API_RULESET_ID, Context, Client)
|
||||||
),
|
),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
@ -398,7 +399,7 @@ forbidden_blacklisted_ip(C) ->
|
|||||||
]),
|
]),
|
||||||
Context = ?CONTEXT(#{<<"root">> => mk_ctx_v1_fragment(Fragment)}),
|
Context = ?CONTEXT(#{<<"root">> => mk_ctx_v1_fragment(Fragment)}),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
?JUDGEMENT(forbidden),
|
?JUDGEMENT({forbidden, #bdcs_ResolutionForbidden{}}, forbidden),
|
||||||
call_judge(?API_RULESET_ID, Context, Client)
|
call_judge(?API_RULESET_ID, Context, Client)
|
||||||
),
|
),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
@ -410,7 +411,7 @@ forbidden_w_empty_context(C) ->
|
|||||||
Client1 = mk_client(C),
|
Client1 = mk_client(C),
|
||||||
EmptyFragment = mk_ctx_v1_fragment(#{}),
|
EmptyFragment = mk_ctx_v1_fragment(#{}),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
?JUDGEMENT(forbidden),
|
?JUDGEMENT({forbidden, #bdcs_ResolutionForbidden{}}, forbidden),
|
||||||
call_judge(?API_RULESET_ID, ?CONTEXT(#{}), Client1)
|
call_judge(?API_RULESET_ID, ?CONTEXT(#{}), Client1)
|
||||||
),
|
),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
@ -419,7 +420,7 @@ forbidden_w_empty_context(C) ->
|
|||||||
),
|
),
|
||||||
Client2 = mk_client(C),
|
Client2 = mk_client(C),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
?JUDGEMENT(forbidden),
|
?JUDGEMENT({forbidden, #bdcs_ResolutionForbidden{}}, forbidden),
|
||||||
call_judge(?API_RULESET_ID, ?CONTEXT(#{<<"empty">> => EmptyFragment}), Client2)
|
call_judge(?API_RULESET_ID, ?CONTEXT(#{<<"empty">> => EmptyFragment}), Client2)
|
||||||
),
|
),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
|
Loading…
Reference in New Issue
Block a user