fix(authn): fix type error
This commit is contained in:
parent
35a4a05f03
commit
b89973ce7c
|
@ -264,7 +264,7 @@ do_post_config_update({create_authenticator, ChainName, Config}, _NewConfig, _Ol
|
||||||
do_post_config_update({delete_authenticator, ChainName, AuthenticatorID}, _NewConfig, OldConfig, _AppEnvs) ->
|
do_post_config_update({delete_authenticator, ChainName, AuthenticatorID}, _NewConfig, OldConfig, _AppEnvs) ->
|
||||||
case delete_authenticator(ChainName, AuthenticatorID) of
|
case delete_authenticator(ChainName, AuthenticatorID) of
|
||||||
ok ->
|
ok ->
|
||||||
[Config] = [Config0 || Config0 <- OldConfig, AuthenticatorID == generate_id(Config0)],
|
[Config] = [Config0 || Config0 <- to_list(OldConfig), AuthenticatorID == generate_id(Config0)],
|
||||||
CertsDir = certs_dir([to_bin(ChainName), AuthenticatorID]),
|
CertsDir = certs_dir([to_bin(ChainName), AuthenticatorID]),
|
||||||
clear_certs(CertsDir, Config),
|
clear_certs(CertsDir, Config),
|
||||||
ok;
|
ok;
|
||||||
|
@ -456,11 +456,11 @@ list_users(ChainName, AuthenticatorID) ->
|
||||||
|
|
||||||
-spec generate_id(config()) -> authenticator_id().
|
-spec generate_id(config()) -> authenticator_id().
|
||||||
generate_id(#{mechanism := Mechanism0, backend := Backend0}) ->
|
generate_id(#{mechanism := Mechanism0, backend := Backend0}) ->
|
||||||
Mechanism = atom_to_binary(Mechanism0),
|
Mechanism = to_bin(Mechanism0),
|
||||||
Backend = atom_to_binary(Backend0),
|
Backend = to_bin(Backend0),
|
||||||
<<Mechanism/binary, ":", Backend/binary>>;
|
<<Mechanism/binary, ":", Backend/binary>>;
|
||||||
generate_id(#{mechanism := Mechanism}) ->
|
generate_id(#{mechanism := Mechanism}) ->
|
||||||
atom_to_binary(Mechanism);
|
to_bin(Mechanism);
|
||||||
generate_id(#{<<"mechanism">> := Mechanism, <<"backend">> := Backend}) ->
|
generate_id(#{<<"mechanism">> := Mechanism, <<"backend">> := Backend}) ->
|
||||||
<<Mechanism/binary, ":", Backend/binary>>;
|
<<Mechanism/binary, ":", Backend/binary>>;
|
||||||
generate_id(#{<<"mechanism">> := Mechanism}) ->
|
generate_id(#{<<"mechanism">> := Mechanism}) ->
|
||||||
|
|
|
@ -211,12 +211,12 @@ t_update_config(Config) when is_list(Config) ->
|
||||||
ok = register_provider(?config("auth1"), ?MODULE),
|
ok = register_provider(?config("auth1"), ?MODULE),
|
||||||
ok = register_provider(?config("auth2"), ?MODULE),
|
ok = register_provider(?config("auth2"), ?MODULE),
|
||||||
Global = ?config(global),
|
Global = ?config(global),
|
||||||
AuthenticatorConfig1 = #{mechanism => 'password-based',
|
AuthenticatorConfig1 = #{<<"mechanism">> => <<"password-based">>,
|
||||||
backend => 'built-in-database',
|
<<"backend">> => <<"built-in-database">>,
|
||||||
enable => true},
|
<<"enable">> => true},
|
||||||
AuthenticatorConfig2 = #{mechanism => 'password-based',
|
AuthenticatorConfig2 = #{<<"mechanism">> => <<"password-based">>,
|
||||||
backend => mysql,
|
<<"backend">> => <<"mysql">>,
|
||||||
enable => true},
|
<<"enable">> => true},
|
||||||
ID1 = <<"password-based:built-in-database">>,
|
ID1 = <<"password-based:built-in-database">>,
|
||||||
ID2 = <<"password-based:mysql">>,
|
ID2 = <<"password-based:mysql">>,
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ t_update_config(Config) when is_list(Config) ->
|
||||||
?assertMatch({ok, _}, update_config([authentication], {create_authenticator, Global, AuthenticatorConfig2})),
|
?assertMatch({ok, _}, update_config([authentication], {create_authenticator, Global, AuthenticatorConfig2})),
|
||||||
?assertMatch({ok, #{id := ID2, state := #{mark := 1}}}, ?AUTHN:lookup_authenticator(Global, ID2)),
|
?assertMatch({ok, #{id := ID2, state := #{mark := 1}}}, ?AUTHN:lookup_authenticator(Global, ID2)),
|
||||||
|
|
||||||
?assertMatch({ok, _}, update_config([authentication], {update_authenticator, Global, ID1, AuthenticatorConfig1#{enable => false}})),
|
?assertMatch({ok, _}, update_config([authentication], {update_authenticator, Global, ID1, AuthenticatorConfig1#{<<"enable">> => false}})),
|
||||||
?assertMatch({ok, #{id := ID1, state := #{mark := 2}}}, ?AUTHN:lookup_authenticator(Global, ID1)),
|
?assertMatch({ok, #{id := ID1, state := #{mark := 2}}}, ?AUTHN:lookup_authenticator(Global, ID1)),
|
||||||
|
|
||||||
?assertMatch({ok, _}, update_config([authentication], {move_authenticator, Global, ID2, top})),
|
?assertMatch({ok, _}, update_config([authentication], {move_authenticator, Global, ID2, top})),
|
||||||
|
@ -244,7 +244,7 @@ t_update_config(Config) when is_list(Config) ->
|
||||||
?assertMatch({ok, _}, update_config(ConfKeyPath, {create_authenticator, ListenerID, AuthenticatorConfig2})),
|
?assertMatch({ok, _}, update_config(ConfKeyPath, {create_authenticator, ListenerID, AuthenticatorConfig2})),
|
||||||
?assertMatch({ok, #{id := ID2, state := #{mark := 1}}}, ?AUTHN:lookup_authenticator(ListenerID, ID2)),
|
?assertMatch({ok, #{id := ID2, state := #{mark := 1}}}, ?AUTHN:lookup_authenticator(ListenerID, ID2)),
|
||||||
|
|
||||||
?assertMatch({ok, _}, update_config(ConfKeyPath, {update_authenticator, ListenerID, ID1, AuthenticatorConfig1#{enable => false}})),
|
?assertMatch({ok, _}, update_config(ConfKeyPath, {update_authenticator, ListenerID, ID1, AuthenticatorConfig1#{<<"enable">> => false}})),
|
||||||
?assertMatch({ok, #{id := ID1, state := #{mark := 2}}}, ?AUTHN:lookup_authenticator(ListenerID, ID1)),
|
?assertMatch({ok, #{id := ID1, state := #{mark := 2}}}, ?AUTHN:lookup_authenticator(ListenerID, ID1)),
|
||||||
|
|
||||||
?assertMatch({ok, _}, update_config(ConfKeyPath, {move_authenticator, ListenerID, ID2, top})),
|
?assertMatch({ok, _}, update_config(ConfKeyPath, {move_authenticator, ListenerID, ID2, top})),
|
||||||
|
|
Loading…
Reference in New Issue