fix(emqx_authz): update config with own schema module
This commit is contained in:
parent
cf1246f026
commit
9dcb725898
|
@ -49,7 +49,7 @@ lookup() ->
|
|||
emqx_config:get(?CONF_KEY_PATH, []).
|
||||
|
||||
update(Cmd, Rules) ->
|
||||
emqx_config:update(?CONF_KEY_PATH, {Cmd, Rules}).
|
||||
emqx_config:update(emqx_authz_schema, ?CONF_KEY_PATH, {Cmd, Rules}).
|
||||
|
||||
%% For now we only support re-creating the entire rule list
|
||||
pre_config_update({head, Rule}, OldConf) when is_map(Rule), is_list(OldConf) ->
|
||||
|
|
|
@ -34,6 +34,13 @@
|
|||
% -define(API_VERSION, "v4").
|
||||
% -define(BASE_PATH, "api").
|
||||
|
||||
-define(CONF_DEFAULT, <<"""
|
||||
authorization:{
|
||||
rules: [
|
||||
]
|
||||
}
|
||||
""">>).
|
||||
|
||||
all() ->
|
||||
%% TODO: V5 API
|
||||
%% emqx_ct:all(?MODULE).
|
||||
|
@ -43,11 +50,7 @@ groups() ->
|
|||
[].
|
||||
|
||||
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),
|
||||
|
||||
ok = emqx_config:init_load(emqx_authz_schema, ?CONF_DEFAULT),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
%create_default_app(),
|
||||
|
@ -55,7 +58,6 @@ init_per_suite(Config) ->
|
|||
|
||||
end_per_suite(_Config) ->
|
||||
%delete_default_app(),
|
||||
meck:unload(emqx_schema),
|
||||
emqx_ct_helpers:stop_apps([emqx_authz]).
|
||||
|
||||
% set_special_configs(emqx) ->
|
||||
|
@ -79,6 +81,7 @@ end_per_suite(_Config) ->
|
|||
% %%------------------------------------------------------------------------------
|
||||
|
||||
t_api_unit_test(_Config) ->
|
||||
%% TODO: Decode from JSON or HOCON, instead of hand-crafting decode result
|
||||
Rule1 = #{<<"principal">> =>
|
||||
#{<<"and">> => [#{<<"username">> => <<"^test?">>},
|
||||
#{<<"clientid">> => <<"^test?">>}
|
||||
|
|
Loading…
Reference in New Issue