test(authz): no need to mock emqx_config
This commit is contained in:
parent
305142f991
commit
40faa31241
|
@ -32,11 +32,6 @@ init_per_suite(Config) ->
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end),
|
||||||
|
|
||||||
%% important! let emqx_schema include the current app!
|
|
||||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
|
||||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
|
||||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
|
||||||
|
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
|
|
||||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||||
|
@ -55,7 +50,6 @@ init_per_suite(Config) ->
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
||||||
meck:unload(emqx_schema),
|
|
||||||
meck:unload(emqx_resource).
|
meck:unload(emqx_resource).
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
|
@ -29,11 +29,6 @@ groups() ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
%% important! let emqx_schema include the current app!
|
|
||||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
|
||||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
|
||||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
|
||||||
|
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end),
|
||||||
|
|
||||||
|
@ -56,7 +51,6 @@ init_per_suite(Config) ->
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
||||||
meck:unload(emqx_schema),
|
|
||||||
meck:unload(emqx_resource).
|
meck:unload(emqx_resource).
|
||||||
|
|
||||||
-define(RULE1,[#{<<"topics">> => [<<"#">>],
|
-define(RULE1,[#{<<"topics">> => [<<"#">>],
|
||||||
|
|
|
@ -29,15 +29,9 @@ groups() ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||||
|
|
||||||
%% important! let emqx_schema include the current app!
|
|
||||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
|
||||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
|
||||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
|
||||||
|
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
|
|
||||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||||
|
@ -59,7 +53,6 @@ init_per_suite(Config) ->
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
||||||
meck:unload(emqx_schema),
|
|
||||||
meck:unload(emqx_resource).
|
meck:unload(emqx_resource).
|
||||||
|
|
||||||
-define(COLUMNS, [ <<"ipaddress">>
|
-define(COLUMNS, [ <<"ipaddress">>
|
||||||
|
|
|
@ -32,11 +32,6 @@ init_per_suite(Config) ->
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||||
|
|
||||||
%% important! let emqx_schema include the current app!
|
|
||||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
|
||||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
|
||||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
|
||||||
|
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
|
|
||||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||||
|
@ -57,7 +52,6 @@ init_per_suite(Config) ->
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
||||||
meck:unload(emqx_schema),
|
|
||||||
meck:unload(emqx_resource).
|
meck:unload(emqx_resource).
|
||||||
|
|
||||||
-define(COLUMNS, [ {column, <<"ipaddress">>, meck, meck, meck, meck, meck, meck, meck}
|
-define(COLUMNS, [ {column, <<"ipaddress">>, meck, meck, meck, meck, meck, meck, meck}
|
||||||
|
|
|
@ -32,11 +32,6 @@ init_per_suite(Config) ->
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||||
|
|
||||||
%% important! let emqx_schema include the current app!
|
|
||||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
|
||||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
|
||||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
|
||||||
|
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
|
|
||||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||||
|
@ -56,7 +51,6 @@ init_per_suite(Config) ->
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
|
||||||
meck:unload(emqx_schema),
|
|
||||||
meck:unload(emqx_resource).
|
meck:unload(emqx_resource).
|
||||||
|
|
||||||
-define(RULE1, [<<"test/%u">>, <<"publish">>]).
|
-define(RULE1, [<<"test/%u">>, <<"publish">>]).
|
||||||
|
|
Loading…
Reference in New Issue