chore(auth): update ldap authn test

This commit is contained in:
Ilya Averyanov 2023-08-07 13:47:58 +03:00
parent f00f4568dc
commit abcdf18ca4
1 changed files with 7 additions and 7 deletions

View File

@ -8,6 +8,7 @@
-include_lib("emqx_authn/include/emqx_authn.hrl"). -include_lib("emqx_authn/include/emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
-define(LDAP_HOST, "ldap"). -define(LDAP_HOST, "ldap").
-define(LDAP_DEFAULT_PORT, 389). -define(LDAP_DEFAULT_PORT, 389).
@ -20,7 +21,6 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_testcase(_, Config) -> init_per_testcase(_, Config) ->
{ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
emqx_authentication:initialize_authentication(?GLOBAL, []), emqx_authentication:initialize_authentication(?GLOBAL, []),
emqx_authn_test_lib:delete_authenticators( emqx_authn_test_lib:delete_authenticators(
[authentication], [authentication],
@ -32,8 +32,9 @@ init_per_suite(Config) ->
_ = application:load(emqx_conf), _ = application:load(emqx_conf),
case emqx_common_test_helpers:is_tcp_server_available(?LDAP_HOST, ?LDAP_DEFAULT_PORT) of case emqx_common_test_helpers:is_tcp_server_available(?LDAP_HOST, ?LDAP_DEFAULT_PORT) of
true -> true ->
ok = emqx_common_test_helpers:start_apps([emqx_authn]), Apps = emqx_cth_suite:start([emqx, emqx_conf, emqx_authn], #{
ok = start_apps([emqx_resource]), work_dir => ?config(priv_dir, Config)
}),
{ok, _} = emqx_resource:create_local( {ok, _} = emqx_resource:create_local(
?LDAP_RESOURCE, ?LDAP_RESOURCE,
?RESOURCE_GROUP, ?RESOURCE_GROUP,
@ -41,19 +42,18 @@ init_per_suite(Config) ->
ldap_config(), ldap_config(),
#{} #{}
), ),
Config; [{apps, Apps} | Config];
false -> false ->
{skip, no_ldap} {skip, no_ldap}
end. end.
end_per_suite(_Config) -> end_per_suite(Config) ->
emqx_authn_test_lib:delete_authenticators( emqx_authn_test_lib:delete_authenticators(
[authentication], [authentication],
?GLOBAL ?GLOBAL
), ),
ok = emqx_resource:remove_local(?LDAP_RESOURCE), ok = emqx_resource:remove_local(?LDAP_RESOURCE),
ok = stop_apps([emqx_resource]), ok = emqx_cth_suite:stop(?config(apps, Config)).
ok = emqx_common_test_helpers:stop_apps([emqx_authn]).
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------
%% Tests %% Tests