Merge pull request #7951 from zmstone/0514-fix-flaky-authn-test-case
0514 fix flaky authn test case
This commit is contained in:
commit
1c95c417f7
|
@ -71,9 +71,15 @@ pre_config_update(_, UpdateReq, OldConfig) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_pre_config_update({create_authenticator, ChainName, Config}, OldConfig) ->
|
do_pre_config_update({create_authenticator, ChainName, Config}, OldConfig) ->
|
||||||
CertsDir = certs_dir(ChainName, Config),
|
NewId = authenticator_id(Config),
|
||||||
NConfig = convert_certs(CertsDir, Config),
|
case lists:filter(fun(OldConfig0) -> authenticator_id(OldConfig0) =:= NewId end, OldConfig) of
|
||||||
{ok, OldConfig ++ [NConfig]};
|
[] ->
|
||||||
|
CertsDir = certs_dir(ChainName, Config),
|
||||||
|
NConfig = convert_certs(CertsDir, Config),
|
||||||
|
{ok, OldConfig ++ [NConfig]};
|
||||||
|
[_] ->
|
||||||
|
{error, {already_exists, {authenticator, NewId}}}
|
||||||
|
end;
|
||||||
do_pre_config_update({delete_authenticator, _ChainName, AuthenticatorID}, OldConfig) ->
|
do_pre_config_update({delete_authenticator, _ChainName, AuthenticatorID}, OldConfig) ->
|
||||||
NewConfig = lists:filter(
|
NewConfig = lists:filter(
|
||||||
fun(OldConfig0) ->
|
fun(OldConfig0) ->
|
||||||
|
@ -257,9 +263,12 @@ clear_certs(CertsDir, Config) ->
|
||||||
ok = emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL).
|
ok = emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL).
|
||||||
|
|
||||||
get_authenticator_config(AuthenticatorID, AuthenticatorsConfig) ->
|
get_authenticator_config(AuthenticatorID, AuthenticatorsConfig) ->
|
||||||
case [C0 || C0 <- AuthenticatorsConfig, AuthenticatorID == authenticator_id(C0)] of
|
case
|
||||||
[C | _] -> C;
|
lists:filter(fun(C) -> AuthenticatorID =:= authenticator_id(C) end, AuthenticatorsConfig)
|
||||||
[] -> {error, not_found}
|
of
|
||||||
|
[C] -> C;
|
||||||
|
[] -> {error, not_found};
|
||||||
|
_ -> error({duplicated_authenticator_id, AuthenticatorsConfig})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
split_by_id(ID, AuthenticatorsConfig) ->
|
split_by_id(ID, AuthenticatorsConfig) ->
|
||||||
|
@ -305,7 +314,7 @@ authenticator_id(#{mechanism := Mechanism}) ->
|
||||||
authenticator_id(#{<<"mechanism">> := Mechanism, <<"backend">> := Backend}) ->
|
authenticator_id(#{<<"mechanism">> := Mechanism, <<"backend">> := Backend}) ->
|
||||||
<<Mechanism/binary, ":", Backend/binary>>;
|
<<Mechanism/binary, ":", Backend/binary>>;
|
||||||
authenticator_id(#{<<"mechanism">> := Mechanism}) ->
|
authenticator_id(#{<<"mechanism">> := Mechanism}) ->
|
||||||
Mechanism;
|
to_bin(Mechanism);
|
||||||
authenticator_id(_C) ->
|
authenticator_id(_C) ->
|
||||||
throw({missing_parameter, #{name => mechanism}}).
|
throw({missing_parameter, #{name => mechanism}}).
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ init_per_testcase(_, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_config:erase(?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME_BINARY),
|
||||||
_ = application:load(emqx_conf),
|
_ = application:load(emqx_conf),
|
||||||
ok = emqx_common_test_helpers:start_apps(
|
ok = emqx_common_test_helpers:start_apps(
|
||||||
[emqx_authn, emqx_dashboard],
|
[emqx_authn, emqx_dashboard],
|
||||||
|
|
|
@ -11,4 +11,7 @@ if [[ "${files_dirty}" == '' ]] && [[ "${files_cached}" == '' ]]; then
|
||||||
fi
|
fi
|
||||||
files="$(echo -e "${files_dirty} \n ${files_cached}" | xargs)"
|
files="$(echo -e "${files_dirty} \n ${files_cached}" | xargs)"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
./scripts/erlfmt $OPT $files
|
if ! (./scripts/erlfmt $OPT $files); then
|
||||||
|
echo "EXECUTE 'make fmt' to fix" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue