ED-124 ED-162 ED-242: +rbkmoney/bouncer-proto#26 +erlang 24 (#33)

This commit is contained in:
dinama 2021-08-26 07:04:16 +03:00 committed by GitHub
parent cf64f9d12a
commit 6dbd5079a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 39 deletions

View File

@ -14,10 +14,11 @@ SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG)
# Base image for the service # Base image for the service
BASE_IMAGE_NAME := service-erlang BASE_IMAGE_NAME := service-erlang
BASE_IMAGE_TAG := 0c1352dbf4a31afe0df372b59699a88f3af7986f BASE_IMAGE_TAG := ef20e2ec1cb1528e9214bdeb862b15478950d5cd
BUILD_IMAGE_NAME := build-erlang BUILD_IMAGE_NAME := build-erlang
BUILD_IMAGE_TAG := 61a001bbb48128895735a3ac35b0858484fdb2eb BUILD_IMAGE_TAG := aaa79c2d6b597f93f5f8b724eecfc31ec2e2a23b
CALL_ANYWHERE := \ CALL_ANYWHERE := \
submodules \ submodules \
all compile xref lint format check_format dialyze cover release clean distclean all compile xref lint format check_format dialyze cover release clean distclean

@ -1 +1 @@
Subproject commit e1318727d4d0c3e48f5122bf3197158b6695f50e Subproject commit a7655bc60c877a65cdfe3d9b668021d970d88a76

View File

@ -26,9 +26,9 @@
%% Common project dependencies. %% Common project dependencies.
{deps, [ {deps, [
{cowboy, "2.8.0"}, {cowboy, "2.9.0"},
{jsx, "3.0.0"}, {jsx, "3.1.0"},
{jesse, "1.5.5"}, {jesse, "1.6.1"},
{gun, {git, "https://github.com/ninenines/gun.git", {branch, "master"}}}, {gun, {git, "https://github.com/ninenines/gun.git", {branch, "master"}}},
{genlib, {git, "https://github.com/rbkmoney/genlib.git", {branch, "master"}}}, {genlib, {git, "https://github.com/rbkmoney/genlib.git", {branch, "master"}}},
{thrift, {git, "https://github.com/rbkmoney/thrift_erlang.git", {branch, "master"}}}, {thrift, {git, "https://github.com/rbkmoney/thrift_erlang.git", {branch, "master"}}},
@ -43,7 +43,7 @@
% Production-only deps. % Production-only deps.
% Defined here for the sake of rebar-locking. % Defined here for the sake of rebar-locking.
{recon, "2.5.1"}, {recon, "2.5.2"},
{logger_logstash_formatter, {logger_logstash_formatter,
{git, "https://github.com/rbkmoney/logger_logstash_formatter.git", {branch, "master"}}}, {git, "https://github.com/rbkmoney/logger_logstash_formatter.git", {branch, "master"}}},
{how_are_you, {git, "https://github.com/rbkmoney/how_are_you.git", {branch, "master"}}}, {how_are_you, {git, "https://github.com/rbkmoney/how_are_you.git", {branch, "master"}}},
@ -53,7 +53,7 @@
%% Helpful plugins. %% Helpful plugins.
{plugins, [ {plugins, [
rebar3_lint, rebar3_lint,
{erlfmt, "0.10.0"} {erlfmt, "1.0.0"}
]}. ]}.
{erlfmt, [ {erlfmt, [

View File

@ -1,8 +1,8 @@
{"1.2.0", {"1.2.0",
[{<<"bear">>,{pkg,<<"bear">>,<<"0.8.7">>},2}, [{<<"bear">>,{pkg,<<"bear">>,<<"0.9.0">>},2},
{<<"bouncer_proto">>, {<<"bouncer_proto">>,
{git,"git@github.com:rbkmoney/bouncer-proto.git", {git,"git@github.com:rbkmoney/bouncer-proto.git",
{ref,"e574cb496b4c48e21e661a9f053c8122de088a6a"}}, {ref,"8da12fe98bc751e7f8f17f64ad4f571a6a63b0fe"}},
0}, 0},
{<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},1}, {<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},1},
{<<"certifi">>,{pkg,<<"certifi">>,<<"2.6.1">>},2}, {<<"certifi">>,{pkg,<<"certifi">>,<<"2.6.1">>},2},
@ -10,15 +10,15 @@
{git,"https://github.com/rbkmoney/cg_mon.git", {git,"https://github.com/rbkmoney/cg_mon.git",
{ref,"5a87a37694e42b6592d3b4164ae54e0e87e24e18"}}, {ref,"5a87a37694e42b6592d3b4164ae54e0e87e24e18"}},
1}, 1},
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.8.0">>},0}, {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},0},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.9.1">>},1}, {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},1},
{<<"erl_health">>, {<<"erl_health">>,
{git,"https://github.com/rbkmoney/erlang-health.git", {git,"https://github.com/rbkmoney/erlang-health.git",
{ref,"5958e2f35cd4d09f40685762b82b82f89b4d9333"}}, {ref,"5958e2f35cd4d09f40685762b82b82f89b4d9333"}},
0}, 0},
{<<"folsom">>, {<<"folsom">>,
{git,"https://github.com/folsom-project/folsom.git", {git,"https://github.com/folsom-project/folsom.git",
{ref,"eeb1cc467eb64bd94075b95b8963e80d8b4df3df"}}, {ref,"62fd0714e6f0b4e7833880afe371a9c882ea0fc2"}},
1}, 1},
{<<"genlib">>, {<<"genlib">>,
{git,"https://github.com/rbkmoney/genlib.git", {git,"https://github.com/rbkmoney/genlib.git",
@ -36,11 +36,11 @@
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.17.4">>},1}, {<<"hackney">>,{pkg,<<"hackney">>,<<"1.17.4">>},1},
{<<"how_are_you">>, {<<"how_are_you">>,
{git,"https://github.com/rbkmoney/how_are_you.git", {git,"https://github.com/rbkmoney/how_are_you.git",
{ref,"29f9d3d7c35f7a2d586c8571f572838df5ec91dd"}}, {ref,"2fd8013420328464c2c84302af2781b86577b39f"}},
0}, 0},
{<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2}, {<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2},
{<<"jesse">>,{pkg,<<"jesse">>,<<"1.5.5">>},0}, {<<"jesse">>,{pkg,<<"jesse">>,<<"1.6.1">>},0},
{<<"jsx">>,{pkg,<<"jsx">>,<<"3.0.0">>},0}, {<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},0},
{<<"logger_logstash_formatter">>, {<<"logger_logstash_formatter">>,
{git,"https://github.com/rbkmoney/logger_logstash_formatter.git", {git,"https://github.com/rbkmoney/logger_logstash_formatter.git",
{ref,"87e52c755cf9e64d651e3ddddbfcd2ccd1db79db"}}, {ref,"87e52c755cf9e64d651e3ddddbfcd2ccd1db79db"}},
@ -52,12 +52,12 @@
{ref,"06c5c8430e445cb7874e54358e457cbb5697fc32"}}, {ref,"06c5c8430e445cb7874e54358e457cbb5697fc32"}},
0}, 0},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2}, {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},1}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1},
{<<"recon">>,{pkg,<<"recon">>,<<"2.5.1">>},0}, {<<"recon">>,{pkg,<<"recon">>,<<"2.5.2">>},0},
{<<"rfc3339">>,{pkg,<<"rfc3339">>,<<"0.2.2">>},1}, {<<"rfc3339">>,{pkg,<<"rfc3339">>,<<"0.2.2">>},1},
{<<"scoper">>, {<<"scoper">>,
{git,"https://github.com/rbkmoney/scoper.git", {git,"https://github.com/rbkmoney/scoper.git",
{ref,"89a973bf3cedc5a48c9fd89d719d25e79fe10027"}}, {ref,"a2c2b7a4b1770205b7b1dbe2e0df6c88044e6244"}},
0}, 0},
{<<"snowflake">>, {<<"snowflake">>,
{git,"https://github.com/rbkmoney/snowflake.git", {git,"https://github.com/rbkmoney/snowflake.git",
@ -71,7 +71,7 @@
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2}, {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2},
{<<"woody">>, {<<"woody">>,
{git,"https://github.com/rbkmoney/woody_erlang.git", {git,"https://github.com/rbkmoney/woody_erlang.git",
{ref,"d9fca6da55a46e39bdb7ad2c0dba0b7205a7e70b"}}, {ref,"330bdcf71e99c2ea7aed424cd718939cb360ec1c"}},
0}, 0},
{<<"woody_user_identity">>, {<<"woody_user_identity">>,
{git,"https://github.com/rbkmoney/woody_erlang_user_identity.git", {git,"https://github.com/rbkmoney/woody_erlang_user_identity.git",
@ -79,40 +79,40 @@
0}]}. 0}]}.
[ [
{pkg_hash,[ {pkg_hash,[
{<<"bear">>, <<"16264309AE5D005D03718A5C82641FCC259C9E8F09ADEB6FD79CA4271168656F">>}, {<<"bear">>, <<"A31CCF5361791DD5E708F4789D67E2FEF496C4F05935FC59ADC11622F834D128">>},
{<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>}, {<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>},
{<<"certifi">>, <<"DBAB8E5E155A0763EEA978C913CA280A6B544BFA115633FA20249C3D396D9493">>}, {<<"certifi">>, <<"DBAB8E5E155A0763EEA978C913CA280A6B544BFA115633FA20249C3D396D9493">>},
{<<"cowboy">>, <<"F3DC62E35797ECD9AC1B50DB74611193C29815401E53BAC9A5C0577BD7BC667D">>}, {<<"cowboy">>, <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>},
{<<"cowlib">>, <<"61A6C7C50CF07FDD24B2F45B89500BB93B6686579B069A89F88CB211E1125C78">>}, {<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>},
{<<"gproc">>, <<"853CCB7805E9ADA25D227A157BA966F7B34508F386A3E7E21992B1B484230699">>}, {<<"gproc">>, <<"853CCB7805E9ADA25D227A157BA966F7B34508F386A3E7E21992B1B484230699">>},
{<<"hackney">>, <<"99DA4674592504D3FB0CFEF0DB84C3BA02B4508BAE2DFF8C0108BAA0D6E0977C">>}, {<<"hackney">>, <<"99DA4674592504D3FB0CFEF0DB84C3BA02B4508BAE2DFF8C0108BAA0D6E0977C">>},
{<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>}, {<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>},
{<<"jesse">>, <<"ECFD2C1634C49052CA907B4DFDE1D1F44B7FD7862D933F4590807E42759B8072">>}, {<<"jesse">>, <<"58F2F0A74A385061A6BA7F8889EF1033859A5F9D8A58A168ECF6A2CCFD9AA1FF">>},
{<<"jsx">>, <<"20A170ABD4335FC6DB24D5FAD1E5D677C55DADF83D1B20A8A33B5FE159892A39">>}, {<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>},
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>}, {<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>}, {<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
{<<"parse_trans">>, <<"16328AB840CC09919BD10DAB29E431DA3AF9E9E7E7E6F0089DD5A2D2820011D8">>}, {<<"parse_trans">>, <<"16328AB840CC09919BD10DAB29E431DA3AF9E9E7E7E6F0089DD5A2D2820011D8">>},
{<<"ranch">>, <<"6B1FAB51B49196860B733A49C07604465A47BDB78AA10C1C16A3D199F7F8C881">>}, {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>},
{<<"recon">>, <<"430FFA60685AC1EFDFB1FE4C97B8767C92D0D92E6E7C3E8621559BA77598678A">>}, {<<"recon">>, <<"CBA53FA8DB83AD968C9A652E09C3ED7DDCC4DA434F27C3EAA9CA47FFB2B1FF03">>},
{<<"rfc3339">>, <<"1552DF616ACA368D982E9F085A0E933B6688A3F4938A671798978EC2C0C58730">>}, {<<"rfc3339">>, <<"1552DF616ACA368D982E9F085A0E933B6688A3F4938A671798978EC2C0C58730">>},
{<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>}, {<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>},
{<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]}, {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]},
{pkg_hash_ext,[ {pkg_hash_ext,[
{<<"bear">>, <<"534217DCE6A719D59E54FB0EB7A367900DBFC5F85757E8C1F94269DF383F6D9B">>}, {<<"bear">>, <<"47F71F098F2E3CD05E124A896C5EC2F155967A2B6FF6731E0D627312CCAB7E28">>},
{<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>}, {<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>},
{<<"certifi">>, <<"524C97B4991B3849DD5C17A631223896272C6B0AF446778BA4675A1DFF53BB7E">>}, {<<"certifi">>, <<"524C97B4991B3849DD5C17A631223896272C6B0AF446778BA4675A1DFF53BB7E">>},
{<<"cowboy">>, <<"4643E4FBA74AC96D4D152C75803DE6FAD0B3FA5DF354C71AFDD6CBEEB15FAC8A">>}, {<<"cowboy">>, <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>},
{<<"cowlib">>, <<"E4175DC240A70D996156160891E1C62238EDE1729E45740BDD38064DAD476170">>}, {<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>},
{<<"gproc">>, <<"587E8AF698CCD3504CF4BA8D90F893EDE2B0F58CABB8A916E2BF9321DE3CF10B">>}, {<<"gproc">>, <<"587E8AF698CCD3504CF4BA8D90F893EDE2B0F58CABB8A916E2BF9321DE3CF10B">>},
{<<"hackney">>, <<"DE16FF4996556C8548D512F4DBE22DD58A587BF3332E7FD362430A7EF3986B16">>}, {<<"hackney">>, <<"DE16FF4996556C8548D512F4DBE22DD58A587BF3332E7FD362430A7EF3986B16">>},
{<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>}, {<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>},
{<<"jesse">>, <<"38D9C4743F97F073D0486CF6626AB370C842D94EE207BB3574052845979A7C0D">>}, {<<"jesse">>, <<"A26C32FBC196C74AD0FBEFB36E7A9604ED0654436849DF814917EE1EF53F4688">>},
{<<"jsx">>, <<"37BECA0435F5CA8A2F45F76A46211E76418FBEF80C36F0361C249FC75059DC6D">>}, {<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>},
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>}, {<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
{<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>}, {<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>},
{<<"parse_trans">>, <<"07CD9577885F56362D414E8C4C4E6BDF10D43A8767ABB92D24CBE8B24C54888B">>}, {<<"parse_trans">>, <<"07CD9577885F56362D414E8C4C4E6BDF10D43A8767ABB92D24CBE8B24C54888B">>},
{<<"ranch">>, <<"451D8527787DF716D99DC36162FCA05934915DB0B6141BBDAC2EA8D3C7AFC7D7">>}, {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>},
{<<"recon">>, <<"5721C6B6D50122D8F68CCCAC712CAA1231F97894BAB779EFF5FF0F886CB44648">>}, {<<"recon">>, <<"2C7523C8DEE91DFF41F6B3D63CBA2BD49EB6D2FE5BF1EEC0DF7F87EB5E230E1C">>},
{<<"rfc3339">>, <<"986D7F9BAC6891AA4D5051690058DE4E623245620BBEADA7F239F85C4DF8F23C">>}, {<<"rfc3339">>, <<"986D7F9BAC6891AA4D5051690058DE4E623245620BBEADA7F239F85C4DF8F23C">>},
{<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>}, {<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>},
{<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]} {<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]}

View File

@ -106,8 +106,10 @@ get_stub_handler_specs(ServiceOpts) ->
[ [
{ {
maps:get(path, OrgManagementStub, <<"/v1/org_management_stub">>), maps:get(path, OrgManagementStub, <<"/v1/org_management_stub">>),
{{orgmgmt_auth_context_provider_thrift, 'AuthContextProvider'}, {
bouncer_org_management_stub} {orgmgmt_auth_context_provider_thrift, 'AuthContextProvider'},
bouncer_org_management_stub
}
} }
]. ].

View File

@ -60,6 +60,30 @@ from_thrift_context(Ctx) ->
bouncer_thrift:from_thrift_struct(StructDef, Ctx, 3, #{}). bouncer_thrift:from_thrift_struct(StructDef, Ctx, 3, #{}).
-spec try_upgrade(thrift_ctx_fragment()) -> thrift_ctx_fragment(). -spec try_upgrade(thrift_ctx_fragment()) -> thrift_ctx_fragment().
try_upgrade(#bctx_v1_ContextFragment{vsn = 1} = Ctx) ->
% TODO #ED-124 #ED-162 rbkmoney/bouncer-policies#46
% tokens.replacement_ip -> client_info.ip
% удалить после выкатки capi_pcidss|bouncer-proto без bctx_v1_ContextTokens
ContextCAPI =
case Ctx#bctx_v1_ContextFragment.tokens of
#bctx_v1_ContextTokens{replacement_ip = undefined} ->
Ctx#bctx_v1_ContextFragment.capi;
#bctx_v1_ContextTokens{replacement_ip = IP} ->
CAPI = Ctx#bctx_v1_ContextFragment.capi,
Operation = CAPI#bctx_v1_ContextCommonAPI.op,
ClientInfo = #bctx_v1_ClientInfo{ip = IP},
CAPI#bctx_v1_ContextCommonAPI{
op = Operation#bctx_v1_CommonAPIOperation{
client_info = ClientInfo
}
};
_ ->
Ctx#bctx_v1_ContextFragment.capi
end,
Ctx#bctx_v1_ContextFragment{
vsn = ?BCTX_V1_HEAD,
capi = ContextCAPI
};
try_upgrade(#bctx_v1_ContextFragment{vsn = ?BCTX_V1_HEAD} = Ctx) -> try_upgrade(#bctx_v1_ContextFragment{vsn = ?BCTX_V1_HEAD} = Ctx) ->
Ctx. Ctx.

View File

@ -21,8 +21,8 @@ handle_function('GetUserContext', {UserID}, _WoodyCtx, _Opts) ->
orgs = [ orgs = [
#bctx_v1_Organization{ #bctx_v1_Organization{
id = UserID, id = UserID,
owner = #bctx_v1_Entity{id = UserID}, owner = #bouncer_base_Entity{id = UserID},
party = #bctx_v1_Entity{id = UserID} party = #bouncer_base_Entity{id = UserID}
} }
] ]
} }

View File

@ -204,7 +204,7 @@ write_queue_contention(C) ->
LogfileEvents = [jsx:decode(L) || L <- LogfileLines, byte_size(L) > 0], LogfileEvents = [jsx:decode(L) || L <- LogfileLines, byte_size(L) > 0],
CompletedEvents = [ CompletedEvents = [
Event Event
|| Event = #{<<"judgement">> := #{<<"event">> := <<"completed">>}} <- LogfileEvents || Event = #{<<"judgement">> := #{<<"event">> := <<"completed">>}} <- LogfileEvents
], ],
?assertEqual(length(Succeeded), length(CompletedEvents)) ?assertEqual(length(Succeeded), length(CompletedEvents))
after after