From f2e29184dec5bc0cbf9bdd84cf3f79100129db9d Mon Sep 17 00:00:00 2001 From: zhanghongtong Date: Thu, 26 Aug 2021 14:30:34 +0800 Subject: [PATCH] chore(emqx_authz): use new config path --- apps/emqx_authz/src/emqx_authz.erl | 6 +++--- apps/emqx_authz/test/emqx_authz_SUITE.erl | 8 ++++---- apps/emqx_authz/test/emqx_authz_api_SUITE.erl | 4 ++-- apps/emqx_authz/test/emqx_authz_http_SUITE.erl | 2 +- apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl | 2 +- apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl | 2 +- apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl | 2 +- apps/emqx_authz/test/emqx_authz_redis_SUITE.erl | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/emqx_authz/src/emqx_authz.erl b/apps/emqx_authz/src/emqx_authz.erl index 3905f0138..90e46461d 100644 --- a/apps/emqx_authz/src/emqx_authz.erl +++ b/apps/emqx_authz/src/emqx_authz.erl @@ -36,7 +36,7 @@ -export([post_config_update/4, pre_config_update/2]). --define(CONF_KEY_PATH, [authorization_rules, rules]). +-define(CONF_KEY_PATH, [authorization, rules]). -spec(register_metrics() -> ok). register_metrics() -> @@ -185,9 +185,9 @@ post_config_update(_, NewRules, _OldConf, _AppEnvs) -> %%-------------------------------------------------------------------- check_rules(RawRules) -> - {ok, Conf} = hocon:binary(jsx:encode(#{<<"authorization_rules">> => #{<<"rules">> => RawRules}}), #{format => richmap}), + {ok, Conf} = hocon:binary(jsx:encode(#{<<"authorization">> => #{<<"rules">> => RawRules}}), #{format => richmap}), CheckConf = hocon_schema:check(emqx_authz_schema, Conf, #{atom_key => true}), - #{authorization_rules := #{rules := Rules}} = hocon_schema:richmap_to_map(CheckConf), + #{authorization:= #{rules := Rules}} = hocon_schema:richmap_to_map(CheckConf), Rules. find_rule_by_id(Id) -> find_rule_by_id(Id, lookup()). diff --git a/apps/emqx_authz/test/emqx_authz_SUITE.erl b/apps/emqx_authz/test/emqx_authz_SUITE.erl index a766ecd82..2a656f07c 100644 --- a/apps/emqx_authz/test/emqx_authz_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_SUITE.erl @@ -22,7 +22,7 @@ -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). --define(CONF_DEFAULT, <<"authorization_rules: {rules: []}">>). +-define(CONF_DEFAULT, <<"authorization: {rules: []}">>). all() -> emqx_ct:all(?MODULE). @@ -37,7 +37,7 @@ init_per_suite(Config) -> meck:expect(emqx_resource, remove, fun(_) -> ok end ), ok = emqx_config:init_load(emqx_authz_schema, ?CONF_DEFAULT), - ok = emqx_ct_helpers:start_apps([emqx_authz]), + ok = emqx_ct_helpers:start_apps([emqx_machine, emqx_authz]), {ok, _} = emqx:update_config([authorization, cache, enable], false), {ok, _} = emqx:update_config([authorization, no_match], deny), Config. @@ -111,7 +111,7 @@ t_update_rule(_) -> {ok, _} = emqx_authz:update(head, [?RULE1]), {ok, _} = emqx_authz:update(tail, [?RULE3]), - ?assertMatch([#{type := http}, #{type := mongo}, #{type := mysql}], emqx:get_config([authorization_rules, rules], [])), + ?assertMatch([#{type := http}, #{type := mongo}, #{type := mysql}], emqx:get_config([authorization, rules], [])), [#{annotations := #{id := Id1}, type := http}, #{annotations := #{id := Id2}, type := mongo}, @@ -120,7 +120,7 @@ t_update_rule(_) -> {ok, _} = emqx_authz:update({replace_once, Id1}, ?RULE5), {ok, _} = emqx_authz:update({replace_once, Id3}, ?RULE4), - ?assertMatch([#{type := redis}, #{type := mongo}, #{type := pgsql}], emqx:get_config([authorization_rules, rules], [])), + ?assertMatch([#{type := redis}, #{type := mongo}, #{type := pgsql}], emqx:get_config([authorization, rules], [])), [#{annotations := #{id := Id1}, type := redis}, #{annotations := #{id := Id2}, type := mongo}, diff --git a/apps/emqx_authz/test/emqx_authz_api_SUITE.erl b/apps/emqx_authz/test/emqx_authz_api_SUITE.erl index b88afc57b..673bc1c4e 100644 --- a/apps/emqx_authz/test/emqx_authz_api_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_api_SUITE.erl @@ -22,7 +22,7 @@ -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). --define(CONF_DEFAULT, <<"authorization_rules: {rules: []}">>). +-define(CONF_DEFAULT, <<"authorization: {rules: []}">>). -import(emqx_ct_http, [ request_api/3 , request_api/5 @@ -126,7 +126,7 @@ set_special_configs(emqx_dashboard) -> emqx_config:put([emqx_dashboard], Config), ok; set_special_configs(emqx_authz) -> - emqx_config:put([authorization_rules], #{rules => []}), + emqx_config:put([authorization], #{rules => []}), ok; set_special_configs(_App) -> ok. diff --git a/apps/emqx_authz/test/emqx_authz_http_SUITE.erl b/apps/emqx_authz/test/emqx_authz_http_SUITE.erl index a455d0ab8..cacf1407c 100644 --- a/apps/emqx_authz/test/emqx_authz_http_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_http_SUITE.erl @@ -21,7 +21,7 @@ -include("emqx_authz.hrl"). -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). --define(CONF_DEFAULT, <<"authorization_rules: {rules: []}">>). +-define(CONF_DEFAULT, <<"authorization: {rules: []}">>). all() -> emqx_ct:all(?MODULE). diff --git a/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl b/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl index 1ad7b4f7a..dd9b2108a 100644 --- a/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl @@ -22,7 +22,7 @@ -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). --define(CONF_DEFAULT, <<"authorization_rules: {rules: []}">>). +-define(CONF_DEFAULT, <<"authorization: {rules: []}">>). all() -> emqx_ct:all(?MODULE). diff --git a/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl b/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl index 3c0320a42..8a762e9f3 100644 --- a/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl @@ -22,7 +22,7 @@ -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). --define(CONF_DEFAULT, <<"authorization_rules: {rules: []}">>). +-define(CONF_DEFAULT, <<"authorization: {rules: []}">>). all() -> emqx_ct:all(?MODULE). diff --git a/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl b/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl index 43ea271a6..209e76af9 100644 --- a/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl @@ -22,7 +22,7 @@ -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). --define(CONF_DEFAULT, <<"authorization_rules: {rules: []}">>). +-define(CONF_DEFAULT, <<"authorization: {rules: []}">>). all() -> emqx_ct:all(?MODULE). diff --git a/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl b/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl index 46ed9579e..70fb2ae85 100644 --- a/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl +++ b/apps/emqx_authz/test/emqx_authz_redis_SUITE.erl @@ -21,7 +21,7 @@ -include("emqx_authz.hrl"). -include_lib("eunit/include/eunit.hrl"). -include_lib("common_test/include/ct.hrl"). --define(CONF_DEFAULT, <<"authorization_rules: {rules: []}">>). +-define(CONF_DEFAULT, <<"authorization: {rules: []}">>). all() -> emqx_ct:all(?MODULE).