Просмотр исходного кода

fix(cthsuite): disable default `acl.conf` authz source

So that users of `emqx_cth_suite` won't have to deal with providing
correct filepath each time they start `emqx_conf` and/or `emqx_authz`
up.
Andrew Mayorov 2 лет назад
Родитель
Сommit
9bda4192e5
1 измененных файлов с 33 добавлено и 8 удалено
  1. 33 8
      apps/emqx/test/emqx_cth_suite.erl

+ 33 - 8
apps/emqx/test/emqx_cth_suite.erl

@@ -260,16 +260,38 @@ default_appspec(emqx, SuiteOpts) ->
     #{
         override_env => [{data_dir, maps:get(work_dir, SuiteOpts, "data")}]
     };
-default_appspec(emqx_conf, SuiteOpts) ->
+default_appspec(emqx_authz, _SuiteOpts) ->
     #{
         config => #{
-            node => #{
-                name => node(),
-                cookie => erlang:get_cookie(),
-                % FIXME
-                data_dir => unicode:characters_to_binary(maps:get(work_dir, SuiteOpts, "data"))
-            }
-        },
+            % NOTE
+            % Disable default authorization sources (i.e. acl.conf file rules).
+            authorization => #{sources => []}
+        }
+    };
+default_appspec(emqx_conf, SuiteOpts) ->
+    Config = #{
+        node => #{
+            name => node(),
+            cookie => erlang:get_cookie(),
+            % FIXME
+            data_dir => unicode:characters_to_binary(maps:get(work_dir, SuiteOpts, "data"))
+        }
+    },
+    % NOTE
+    % Since `emqx_conf_schema` manages config for a lot of applications, it's good to include
+    % their defaults as well.
+    SharedConfig = lists:foldl(
+        fun(App, Acc) ->
+            emqx_utils_maps:deep_merge(Acc, default_config(App, SuiteOpts))
+        end,
+        Config,
+        [
+            emqx,
+            emqx_authz
+        ]
+    ),
+    #{
+        config => SharedConfig,
         % NOTE
         % We inform `emqx` of our config loader before starting `emqx_conf` sothat it won't
         % overwrite everything with a default configuration.
@@ -286,6 +308,9 @@ default_appspec(emqx_dashboard, _SuiteOpts) ->
 default_appspec(_, _) ->
     #{}.
 
+default_config(App, SuiteOpts) ->
+    maps:get(config, default_appspec(App, SuiteOpts), #{}).
+
 %%
 
 start_ekka() ->