chore(auth plugins): remove emqx_modules in test case
This commit is contained in:
parent
280fedca0d
commit
99843e7b4b
|
@ -44,13 +44,11 @@ groups() ->
|
||||||
|
|
||||||
init_per_group(GrpName, Cfg) ->
|
init_per_group(GrpName, Cfg) ->
|
||||||
Fun = fun(App) -> set_special_configs(GrpName, App) end,
|
Fun = fun(App) -> set_special_configs(GrpName, App) end,
|
||||||
emqx_ct_helpers:start_apps([emqx_modules]),
|
|
||||||
emqx_ct_helpers:start_apps([emqx_auth_ldap], Fun),
|
emqx_ct_helpers:start_apps([emqx_auth_ldap], Fun),
|
||||||
emqx_mod_acl_internal:unload([]),
|
|
||||||
Cfg.
|
Cfg.
|
||||||
|
|
||||||
end_per_group(_GrpName, _Cfg) ->
|
end_per_group(_GrpName, _Cfg) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_auth_ldap, emqx_modules]).
|
emqx_ct_helpers:stop_apps([emqx_auth_ldap]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Cases
|
%% Cases
|
||||||
|
|
|
@ -36,12 +36,11 @@ all() ->
|
||||||
check_acl].
|
check_acl].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
emqx_ct_helpers:start_apps([emqx_modules, emqx_auth_ldap], fun set_special_configs/1),
|
emqx_ct_helpers:start_apps([emqx_auth_ldap], fun set_special_configs/1),
|
||||||
emqx_mod_acl_internal:unload([]),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_auth_ldap, emqx_modules]).
|
emqx_ct_helpers:stop_apps([emqx_auth_ldap]).
|
||||||
|
|
||||||
check_auth(_) ->
|
check_auth(_) ->
|
||||||
MqttUser1 = #{clientid => <<"mqttuser1">>,
|
MqttUser1 = #{clientid => <<"mqttuser1">>,
|
||||||
|
@ -62,7 +61,6 @@ check_auth(_) ->
|
||||||
?assertEqual({error, not_authorized}, emqx_access_control:authenticate(NonExistUser1)).
|
?assertEqual({error, not_authorized}, emqx_access_control:authenticate(NonExistUser1)).
|
||||||
|
|
||||||
check_acl(_) ->
|
check_acl(_) ->
|
||||||
% emqx_modules:load_module(emqx_mod_acl_internal, false),
|
|
||||||
MqttUser = #{clientid => <<"mqttuser1">>, username => <<"user1">>, zone => external},
|
MqttUser = #{clientid => <<"mqttuser1">>, username => <<"user1">>, zone => external},
|
||||||
NoMqttUser = #{clientid => <<"mqttuser2">>, username => <<"user7">>, zone => external},
|
NoMqttUser = #{clientid => <<"mqttuser2">>, username => <<"user7">>, zone => external},
|
||||||
allow = emqx_access_control:check_acl(MqttUser, publish, <<"mqttuser0001/pub/1">>),
|
allow = emqx_access_control:check_acl(MqttUser, publish, <<"mqttuser0001/pub/1">>),
|
||||||
|
|
|
@ -50,23 +50,18 @@ all() ->
|
||||||
emqx_ct:all(?MODULE).
|
emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Cfg) ->
|
init_per_suite(Cfg) ->
|
||||||
emqx_ct_helpers:start_apps([emqx_modules, emqx_auth_mongo], fun set_special_confs/1),
|
emqx_ct_helpers:start_apps([emqx_auth_mongo], fun set_special_confs/1),
|
||||||
emqx_modules:load_module(emqx_mod_acl_internal, false),
|
|
||||||
init_mongo_data(),
|
init_mongo_data(),
|
||||||
Cfg.
|
Cfg.
|
||||||
|
|
||||||
end_per_suite(_Cfg) ->
|
end_per_suite(_Cfg) ->
|
||||||
deinit_mongo_data(),
|
deinit_mongo_data(),
|
||||||
emqx_ct_helpers:stop_apps([emqx_auth_mongo, emqx_modules]).
|
emqx_ct_helpers:stop_apps([emqx_auth_mongo]).
|
||||||
|
|
||||||
set_special_confs(emqx) ->
|
set_special_confs(emqx) ->
|
||||||
application:set_env(emqx, acl_nomatch, deny),
|
application:set_env(emqx, acl_nomatch, deny),
|
||||||
application:set_env(emqx, acl_file,
|
|
||||||
emqx_ct_helpers:deps_path(emqx, "test/emqx_SUITE_data/acl.conf")),
|
|
||||||
application:set_env(emqx, allow_anonymous, false),
|
application:set_env(emqx, allow_anonymous, false),
|
||||||
application:set_env(emqx, enable_acl_cache, false),
|
application:set_env(emqx, enable_acl_cache, false);
|
||||||
application:set_env(emqx, plugins_loaded_file,
|
|
||||||
emqx_ct_helpers:deps_path(emqx, "test/emqx_SUITE_data/loaded_plugins"));
|
|
||||||
set_special_confs(_App) ->
|
set_special_confs(_App) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -133,7 +128,7 @@ t_check_acl(_) ->
|
||||||
allow = emqx_access_control:check_acl(User2, subscribe, <<"$SYS/testuser/1">>),
|
allow = emqx_access_control:check_acl(User2, subscribe, <<"$SYS/testuser/1">>),
|
||||||
allow = emqx_access_control:check_acl(User3, publish, <<"a/b/c">>),
|
allow = emqx_access_control:check_acl(User3, publish, <<"a/b/c">>),
|
||||||
deny = emqx_access_control:check_acl(User3, publish, <<"c">>),
|
deny = emqx_access_control:check_acl(User3, publish, <<"c">>),
|
||||||
allow = emqx_access_control:check_acl(User4, publish, <<"a/b/c">>).
|
deny = emqx_access_control:check_acl(User4, publish, <<"a/b/c">>).
|
||||||
|
|
||||||
t_acl_super(_) ->
|
t_acl_super(_) ->
|
||||||
reload({auth_query, [{password_hash, plain}, {password_field, [<<"password">>]}]}),
|
reload({auth_query, [{password_hash, plain}, {password_field, [<<"password">>]}]}),
|
||||||
|
|
|
@ -70,7 +70,7 @@ all() ->
|
||||||
emqx_ct:all(?MODULE).
|
emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
emqx_ct_helpers:start_apps([emqx_modules, emqx_auth_pgsql]),
|
emqx_ct_helpers:start_apps([emqx_auth_pgsql]),
|
||||||
drop_acl(),
|
drop_acl(),
|
||||||
drop_auth(),
|
drop_auth(),
|
||||||
init_auth(),
|
init_auth(),
|
||||||
|
@ -79,7 +79,7 @@ init_per_suite(Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_auth_pgsql, emqx_modules]),
|
emqx_ct_helpers:stop_apps([emqx_auth_pgsql]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
set_special_configs() ->
|
set_special_configs() ->
|
||||||
|
@ -161,7 +161,6 @@ t_check_auth(_) ->
|
||||||
{error, not_authorized} = emqx_access_control:authenticate(Bcrypt#{password => <<"password">>}).
|
{error, not_authorized} = emqx_access_control:authenticate(Bcrypt#{password => <<"password">>}).
|
||||||
|
|
||||||
t_check_acl(_) ->
|
t_check_acl(_) ->
|
||||||
emqx_modules:load_module(emqx_mod_acl_internal, false),
|
|
||||||
User1 = #{zone => external, peerhost => {127,0,0,1}, clientid => <<"c1">>, username => <<"u1">>},
|
User1 = #{zone => external, peerhost => {127,0,0,1}, clientid => <<"c1">>, username => <<"u1">>},
|
||||||
User2 = #{zone => external, peerhost => {127,0,0,1}, clientid => <<"c2">>, username => <<"u2">>},
|
User2 = #{zone => external, peerhost => {127,0,0,1}, clientid => <<"c2">>, username => <<"u2">>},
|
||||||
allow = emqx_access_control:check_acl(User1, subscribe, <<"t1">>),
|
allow = emqx_access_control:check_acl(User1, subscribe, <<"t1">>),
|
||||||
|
@ -170,8 +169,8 @@ t_check_acl(_) ->
|
||||||
User4 = #{zone => external, peerhost => {10,10,10,110}, clientid => <<"c1">>, username => <<"u1">>},
|
User4 = #{zone => external, peerhost => {10,10,10,110}, clientid => <<"c1">>, username => <<"u1">>},
|
||||||
allow = emqx_access_control:check_acl(User3, subscribe, <<"t1">>),
|
allow = emqx_access_control:check_acl(User3, subscribe, <<"t1">>),
|
||||||
allow = emqx_access_control:check_acl(User3, subscribe, <<"t1">>),
|
allow = emqx_access_control:check_acl(User3, subscribe, <<"t1">>),
|
||||||
allow = emqx_access_control:check_acl(User3, subscribe, <<"t2">>),%% nomatch -> ignore -> emqttd acl
|
deny = emqx_access_control:check_acl(User3, subscribe, <<"t2">>),%% nomatch -> ignore -> emqx acl
|
||||||
allow = emqx_access_control:check_acl(User4, subscribe, <<"t1">>),%% nomatch -> ignore -> emqttd acl
|
deny = emqx_access_control:check_acl(User4, subscribe, <<"t1">>),%% nomatch -> ignore -> emqx acl
|
||||||
User5 = #{zone => external, peerhost => {127,0,0,1}, clientid => <<"c3">>, username => <<"u3">>},
|
User5 = #{zone => external, peerhost => {127,0,0,1}, clientid => <<"c3">>, username => <<"u3">>},
|
||||||
allow = emqx_access_control:check_acl(User5, subscribe, <<"t1">>),
|
allow = emqx_access_control:check_acl(User5, subscribe, <<"t1">>),
|
||||||
allow = emqx_access_control:check_acl(User5, publish, <<"t1">>).
|
allow = emqx_access_control:check_acl(User5, publish, <<"t1">>).
|
||||||
|
|
|
@ -49,22 +49,18 @@ all() ->
|
||||||
emqx_ct:all(?MODULE).
|
emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Cfg) ->
|
init_per_suite(Cfg) ->
|
||||||
emqx_ct_helpers:start_apps([emqx_modules, emqx_auth_redis], fun set_special_configs/1),
|
emqx_ct_helpers:start_apps([emqx_auth_redis], fun set_special_configs/1),
|
||||||
init_redis_rows(),
|
init_redis_rows(),
|
||||||
Cfg.
|
Cfg.
|
||||||
|
|
||||||
end_per_suite(_Cfg) ->
|
end_per_suite(_Cfg) ->
|
||||||
deinit_redis_rows(),
|
deinit_redis_rows(),
|
||||||
emqx_ct_helpers:stop_apps([emqx_auth_redis, emqx_modules]).
|
emqx_ct_helpers:stop_apps([emqx_auth_redis]).
|
||||||
|
|
||||||
set_special_configs(emqx) ->
|
set_special_configs(emqx) ->
|
||||||
application:set_env(emqx, allow_anonymous, false),
|
application:set_env(emqx, allow_anonymous, false),
|
||||||
application:set_env(emqx, acl_nomatch, deny),
|
application:set_env(emqx, acl_nomatch, deny),
|
||||||
application:set_env(emqx, acl_file,
|
application:set_env(emqx, enable_acl_cache, false);
|
||||||
emqx_ct_helpers:deps_path(emqx, "test/emqx_SUITE_data/acl.conf")),
|
|
||||||
application:set_env(emqx, enable_acl_cache, false),
|
|
||||||
application:set_env(emqx, plugins_loaded_file,
|
|
||||||
emqx_ct_helpers:deps_path(emqx, "test/emqx_SUITE_data/loaded_plugins"));
|
|
||||||
set_special_configs(_App) ->
|
set_special_configs(_App) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -72,7 +68,6 @@ init_redis_rows() ->
|
||||||
%% Users
|
%% Users
|
||||||
[q(["HMSET", Key|FiledValue]) || {Key, FiledValue} <- ?INIT_AUTH],
|
[q(["HMSET", Key|FiledValue]) || {Key, FiledValue} <- ?INIT_AUTH],
|
||||||
%% ACLs
|
%% ACLs
|
||||||
emqx_modules:load_module(emqx_mod_acl_internal, false),
|
|
||||||
Result = [q(["HSET", Key, Filed, Value]) || {Key, Filed, Value} <- ?INIT_ACL],
|
Result = [q(["HSET", Key, Filed, Value]) || {Key, Filed, Value} <- ?INIT_ACL],
|
||||||
ct:pal("redis init result: ~p~n", [Result]).
|
ct:pal("redis init result: ~p~n", [Result]).
|
||||||
|
|
||||||
|
@ -136,7 +131,7 @@ t_check_acl(_) ->
|
||||||
allow = emqx_access_control:check_acl(User2, subscribe, <<"topic2">>),
|
allow = emqx_access_control:check_acl(User2, subscribe, <<"topic2">>),
|
||||||
allow = emqx_access_control:check_acl(User3, publish, <<"topic3">>),
|
allow = emqx_access_control:check_acl(User3, publish, <<"topic3">>),
|
||||||
allow = emqx_access_control:check_acl(User3, subscribe, <<"topic3">>),
|
allow = emqx_access_control:check_acl(User3, subscribe, <<"topic3">>),
|
||||||
allow = emqx_access_control:check_acl(User4, publish, <<"a/b/c">>).
|
deny = emqx_access_control:check_acl(User4, publish, <<"a/b/c">>).
|
||||||
|
|
||||||
t_acl_super(_) ->
|
t_acl_super(_) ->
|
||||||
reload([{password_hash, plain}]),
|
reload([{password_hash, plain}]),
|
||||||
|
|
Loading…
Reference in New Issue