test(mongodb authn, authz): add test cases for use_legacy_protocol
This commit adds test cases that check that the authn and authz modules for MongoDB support the use_legacy_protocol configuration option. Fixes: https://emqx.atlassian.net/browse/EMQX-12245
This commit is contained in:
parent
a0e0a27f87
commit
db48a977bb
|
@ -285,11 +285,12 @@ raw_mongo_auth_config() ->
|
|||
<<"filter">> => #{<<"username">> => <<"${username}">>},
|
||||
<<"password_hash_field">> => <<"password_hash">>,
|
||||
<<"salt_field">> => <<"salt">>,
|
||||
<<"is_superuser_field">> => <<"is_superuser">>
|
||||
<<"is_superuser_field">> => <<"is_superuser">>,
|
||||
<<"use_legacy_protocol">> => <<"auto">>
|
||||
}.
|
||||
|
||||
user_seeds() ->
|
||||
[
|
||||
PlainSeed =
|
||||
#{
|
||||
data => #{
|
||||
username => <<"plain">>,
|
||||
|
@ -304,7 +305,10 @@ user_seeds() ->
|
|||
config_params => #{},
|
||||
result => {ok, #{is_superuser => true}}
|
||||
},
|
||||
|
||||
[
|
||||
PlainSeed#{config_params => #{<<"use_legacy_protocol">> => <<"auto">>}},
|
||||
PlainSeed#{config_params => #{<<"use_legacy_protocol">> => <<"true">>}},
|
||||
PlainSeed#{config_params => #{<<"use_legacy_protocol">> => <<"false">>}},
|
||||
#{
|
||||
data => #{
|
||||
username => <<"md5">>,
|
||||
|
|
|
@ -75,9 +75,14 @@ end_per_testcase(_TestCase, _Config) ->
|
|||
%%------------------------------------------------------------------------------
|
||||
|
||||
t_run_case(Config) ->
|
||||
run_case(Config, true),
|
||||
run_case(Config, false),
|
||||
run_case(Config, auto).
|
||||
|
||||
run_case(Config, UseLegazyProtocol) ->
|
||||
Case = ?config(test_case, Config),
|
||||
ok = setup_source_data(Case),
|
||||
ok = setup_authz_source(Case),
|
||||
ok = setup_authz_source(Case#{use_legacy_protocol => UseLegazyProtocol}),
|
||||
ok = emqx_authz_test_lib:run_checks(Case).
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
|
@ -374,10 +379,11 @@ setup_source_data(#{records := Records}) ->
|
|||
{{true, _}, _} = mc_worker_api:insert(?MONGO_CLIENT, <<"acl">>, Records),
|
||||
ok.
|
||||
|
||||
setup_authz_source(#{filter := Filter}) ->
|
||||
setup_authz_source(#{filter := Filter, use_legacy_protocol := UseLegazyProtocol}) ->
|
||||
setup_config(
|
||||
#{
|
||||
<<"filter">> => Filter
|
||||
<<"filter">> => Filter,
|
||||
<<"use_legacy_protocol">> => UseLegazyProtocol
|
||||
}
|
||||
).
|
||||
|
||||
|
@ -401,7 +407,8 @@ raw_mongo_authz_config() ->
|
|||
<<"username">> => mongo_username(),
|
||||
<<"password">> => mongo_password(),
|
||||
|
||||
<<"filter">> => #{<<"username">> => <<"${username}">>}
|
||||
<<"filter">> => #{<<"username">> => <<"${username}">>},
|
||||
<<"use_legacy_protocol">> => <<"auto">>
|
||||
}.
|
||||
|
||||
mongo_server() ->
|
||||
|
|
Loading…
Reference in New Issue