|
|
@@ -19,6 +19,7 @@
|
|
|
-compile(nowarn_export_all).
|
|
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
+-include_lib("common_test/include/ct.hrl").
|
|
|
|
|
|
all() ->
|
|
|
emqx_common_test_helpers:all(?MODULE).
|
|
|
@@ -32,11 +33,15 @@ end_per_suite(_) ->
|
|
|
|
|
|
init_per_testcase(TestCase = t_configs_node, Config) ->
|
|
|
?MODULE:TestCase({'init', Config});
|
|
|
+init_per_testcase(TestCase = t_create_webhook_v1_bridges_api, Config) ->
|
|
|
+ ?MODULE:TestCase({'init', Config});
|
|
|
init_per_testcase(_TestCase, Config) ->
|
|
|
Config.
|
|
|
|
|
|
end_per_testcase(TestCase = t_configs_node, Config) ->
|
|
|
?MODULE:TestCase({'end', Config});
|
|
|
+end_per_testcase(TestCase = t_create_webhook_v1_bridges_api, Config) ->
|
|
|
+ ?MODULE:TestCase({'end', Config});
|
|
|
end_per_testcase(_TestCase, Config) ->
|
|
|
Config.
|
|
|
|
|
|
@@ -372,6 +377,100 @@ t_get_configs_in_different_accept(_Config) ->
|
|
|
%% returns error if it set to other type
|
|
|
?assertMatch({400, "application/json", _}, Request(<<"application/xml">>)).
|
|
|
|
|
|
+t_create_webhook_v1_bridges_api({'init', Config}) ->
|
|
|
+ application:ensure_all_started(emqx_connector),
|
|
|
+ application:ensure_all_started(emqx_bridge),
|
|
|
+ Config;
|
|
|
+t_create_webhook_v1_bridges_api({'end', _}) ->
|
|
|
+ application:stop(emqx_bridge),
|
|
|
+ application:stop(emqx_connector),
|
|
|
+ ok;
|
|
|
+t_create_webhook_v1_bridges_api(Config) ->
|
|
|
+ WebHookFile = filename:join(?config(data_dir, Config), "webhook_v1.conf"),
|
|
|
+ ?assertMatch({ok, _}, hocon:files([WebHookFile])),
|
|
|
+ {ok, WebHookBin} = file:read_file(WebHookFile),
|
|
|
+ ?assertEqual([], update_configs_with_binary(WebHookBin)),
|
|
|
+ Actions =
|
|
|
+ #{
|
|
|
+ <<"http">> =>
|
|
|
+ #{
|
|
|
+ <<"webhook_name">> =>
|
|
|
+ #{
|
|
|
+ <<"connector">> => <<"connector_webhook_name">>,
|
|
|
+ <<"description">> => <<>>,
|
|
|
+ <<"enable">> => true,
|
|
|
+ <<"parameters">> =>
|
|
|
+ #{
|
|
|
+ <<"body">> => <<"{\"value\": \"${value}\"}">>,
|
|
|
+ <<"headers">> => #{},
|
|
|
+ <<"max_retries">> => 3,
|
|
|
+ <<"method">> => <<"post">>,
|
|
|
+ <<"path">> => <<>>
|
|
|
+ },
|
|
|
+ <<"resource_opts">> =>
|
|
|
+ #{
|
|
|
+ <<"health_check_interval">> => <<"15s">>,
|
|
|
+ <<"inflight_window">> => 100,
|
|
|
+ <<"max_buffer_bytes">> => <<"256MB">>,
|
|
|
+ <<"query_mode">> => <<"async">>,
|
|
|
+ <<"request_ttl">> => <<"45s">>,
|
|
|
+ <<"worker_pool_size">> => 4
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ?assertEqual(Actions, emqx_conf:get_raw([<<"actions">>])),
|
|
|
+ Connectors =
|
|
|
+ #{
|
|
|
+ <<"http">> =>
|
|
|
+ #{
|
|
|
+ <<"connector_webhook_name">> =>
|
|
|
+ #{
|
|
|
+ <<"connect_timeout">> => <<"15s">>,
|
|
|
+ <<"description">> => <<>>,
|
|
|
+ <<"enable">> => true,
|
|
|
+ <<"enable_pipelining">> => 100,
|
|
|
+ <<"headers">> =>
|
|
|
+ #{
|
|
|
+ <<"Authorization">> => <<"Bearer redacted">>,
|
|
|
+ <<"content-type">> => <<"application/json">>
|
|
|
+ },
|
|
|
+ <<"pool_size">> => 4,
|
|
|
+ <<"pool_type">> => <<"random">>,
|
|
|
+ <<"resource_opts">> =>
|
|
|
+ #{
|
|
|
+ <<"health_check_interval">> => <<"15s">>,
|
|
|
+ <<"start_after_created">> => true,
|
|
|
+ <<"start_timeout">> => <<"5s">>
|
|
|
+ },
|
|
|
+ <<"ssl">> =>
|
|
|
+ #{
|
|
|
+ <<"ciphers">> => [],
|
|
|
+ <<"depth">> => 10,
|
|
|
+ <<"enable">> => true,
|
|
|
+ <<"hibernate_after">> => <<"5s">>,
|
|
|
+ <<"log_level">> => <<"notice">>,
|
|
|
+ <<"reuse_sessions">> => true,
|
|
|
+ <<"secure_renegotiate">> => true,
|
|
|
+ <<"user_lookup_fun">> =>
|
|
|
+ <<"emqx_tls_psk:lookup">>,
|
|
|
+ <<"verify">> => <<"verify_none">>,
|
|
|
+ <<"versions">> =>
|
|
|
+ [
|
|
|
+ <<"tlsv1.3">>,
|
|
|
+ <<"tlsv1.2">>,
|
|
|
+ <<"tlsv1.1">>,
|
|
|
+ <<"tlsv1">>
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ <<"url">> => <<"https://127.0.0.1:18083">>
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ?assertEqual(Connectors, emqx_conf:get_raw([<<"connectors">>])),
|
|
|
+ ?assertEqual(#{<<"webhook">> => #{}}, emqx_conf:get_raw([<<"bridges">>])),
|
|
|
+ ok.
|
|
|
+
|
|
|
%% Helpers
|
|
|
|
|
|
get_config(Name) ->
|