test(proper): track to the lastest code
- use limited atom type - keep webhook confs testing to lastest schema
This commit is contained in:
parent
1d241bc39c
commit
c413af5c35
|
@ -488,9 +488,9 @@ pubsub_to_enum(subscribe) -> 'SUBSCRIBE'.
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
do_setup() ->
|
||||
logger:set_primary_config(#{level => warning}),
|
||||
_ = emqx_exhook_demo_svr:start(),
|
||||
emqx_ct_helpers:start_apps([emqx_exhook], fun set_special_cfgs/1),
|
||||
emqx_logger:set_log_level(warning),
|
||||
%% waiting first loaded event
|
||||
{'on_provider_loaded', _} = emqx_exhook_demo_svr:take(),
|
||||
ok.
|
||||
|
@ -500,12 +500,14 @@ do_teardown(_) ->
|
|||
%% waiting last unloaded event
|
||||
{'on_provider_unloaded', _} = emqx_exhook_demo_svr:take(),
|
||||
_ = emqx_exhook_demo_svr:stop(),
|
||||
logger:set_primary_config(#{level => notice}),
|
||||
timer:sleep(2000),
|
||||
ok.
|
||||
|
||||
set_special_cfgs(emqx) ->
|
||||
application:set_env(emqx, allow_anonymous, false),
|
||||
application:set_env(emqx, enable_acl_cache, false),
|
||||
application:set_env(emqx, modules_loaded_file, undefined),
|
||||
application:set_env(emqx, plugins_loaded_file,
|
||||
emqx_ct_helpers:deps_path(emqx, "test/emqx_SUITE_data/loaded_plugins"));
|
||||
set_special_cfgs(emqx_exhook) ->
|
||||
|
@ -528,7 +530,7 @@ unsub_properties() ->
|
|||
#{}.
|
||||
|
||||
shutdown_reason() ->
|
||||
oneof([utf8(), {shutdown, atom()}]).
|
||||
oneof([utf8(), {shutdown, emqx_ct_proper_types:limited_atom()}]).
|
||||
|
||||
authresult() ->
|
||||
#{auth_result => connack_return_code()}.
|
||||
|
|
|
@ -53,12 +53,13 @@ prop_confs() ->
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
do_setup() ->
|
||||
application:set_env(kernel, logger_level, error),
|
||||
logger:set_primary_config(#{level => warning}),
|
||||
emqx_ct_helpers:start_apps([], fun set_special_cfgs/1),
|
||||
ok.
|
||||
|
||||
do_teardown(_) ->
|
||||
emqx_ct_helpers:stop_apps([]),
|
||||
logger:set_primary_config(#{level => info}),
|
||||
ok.
|
||||
|
||||
set_special_cfgs(_) ->
|
||||
|
@ -113,7 +114,10 @@ cuttlefish_conf_option(K, V)
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
confs() ->
|
||||
nof([{"web.hook.encode_payload", oneof(["base64", "base62"])},
|
||||
nof([{"web.hook.headers.content-type",
|
||||
oneof(["application/json"])},
|
||||
{"web.hook.body.encoding_of_payload_field",
|
||||
oneof(["plain", "base64", "base62"])},
|
||||
{"web.hook.rule.client.connect.1", rule_spec()},
|
||||
{"web.hook.rule.client.connack.1", rule_spec()},
|
||||
{"web.hook.rule.client.connected.1", rule_spec()},
|
||||
|
|
|
@ -211,9 +211,9 @@ prop_session_terminated() ->
|
|||
prop_message_publish() ->
|
||||
?ALL({Msg, Env, Encode}, {message(), topic_filter_env(), payload_encode()},
|
||||
begin
|
||||
application:set_env(emqx_web_hook, encode_payload, Encode),
|
||||
application:set_env(emqx_web_hook, encoding_of_payload_field, Encode),
|
||||
{ok, Msg} = emqx_web_hook:on_message_publish(Msg, Env),
|
||||
application:unset_env(emqx_web_hook, encode_payload),
|
||||
application:unset_env(emqx_web_hook, encoding_of_payload_field),
|
||||
|
||||
(not emqx_message:is_sys(Msg))
|
||||
andalso filter_topic_match(emqx_message:topic(Msg), Env)
|
||||
|
@ -237,9 +237,9 @@ prop_message_publish() ->
|
|||
prop_message_delivered() ->
|
||||
?ALL({ClientInfo, Msg, Env, Encode}, {clientinfo(), message(), topic_filter_env(), payload_encode()},
|
||||
begin
|
||||
application:set_env(emqx_web_hook, encode_payload, Encode),
|
||||
application:set_env(emqx_web_hook, encoding_of_payload_field, Encode),
|
||||
ok = emqx_web_hook:on_message_delivered(ClientInfo, Msg, Env),
|
||||
application:unset_env(emqx_web_hook, encode_payload),
|
||||
application:unset_env(emqx_web_hook, encoding_of_payload_field),
|
||||
|
||||
(not emqx_message:is_sys(Msg))
|
||||
andalso filter_topic_match(emqx_message:topic(Msg), Env)
|
||||
|
@ -265,9 +265,9 @@ prop_message_delivered() ->
|
|||
prop_message_acked() ->
|
||||
?ALL({ClientInfo, Msg, Env, Encode}, {clientinfo(), message(), empty_env(), payload_encode()},
|
||||
begin
|
||||
application:set_env(emqx_web_hook, encode_payload, Encode),
|
||||
application:set_env(emqx_web_hook, encoding_of_payload_field, Encode),
|
||||
ok = emqx_web_hook:on_message_acked(ClientInfo, Msg, Env),
|
||||
application:unset_env(emqx_web_hook, encode_payload),
|
||||
application:unset_env(emqx_web_hook, encoding_of_payload_field),
|
||||
|
||||
(not emqx_message:is_sys(Msg))
|
||||
andalso filter_topic_match(emqx_message:topic(Msg), Env)
|
||||
|
@ -305,7 +305,7 @@ do_setup() ->
|
|||
meck:new(ehttpc, [passthrough, no_history]),
|
||||
meck:expect(ehttpc, request,
|
||||
fun(_ClientId, Method, {Path, Headers, Body}) ->
|
||||
Self ! {Method, Path, Headers, Body}, {ok, ok, ok}
|
||||
Self ! {Method, Path, Headers, Body}, {ok, 200, ok}
|
||||
end),
|
||||
|
||||
meck:new(emqx_metrics, [passthrough, no_history]),
|
||||
|
@ -327,8 +327,10 @@ peer2addr(Host) ->
|
|||
|
||||
stringfy({shutdown, Reason}) ->
|
||||
stringfy(Reason);
|
||||
stringfy(Term) when is_atom(Term); is_binary(Term) ->
|
||||
stringfy(Term) when is_binary(Term) ->
|
||||
Term;
|
||||
stringfy(Term) when is_atom(Term) ->
|
||||
atom_to_binary(Term, utf8);
|
||||
stringfy(Term) ->
|
||||
unicode:characters_to_binary(io_lib:format("~0p", [Term])).
|
||||
|
||||
|
@ -374,7 +376,7 @@ unsub_properties() ->
|
|||
#{}.
|
||||
|
||||
shutdown_reason() ->
|
||||
oneof([any(), {shutdown, atom()}]).
|
||||
oneof([any(), {shutdown, emqx_ct_proper_types:limited_atom()}]).
|
||||
|
||||
empty_env() ->
|
||||
{undefined}.
|
||||
|
@ -383,7 +385,7 @@ topic_filter_env() ->
|
|||
oneof([{<<"#">>}, {undefined}, {topic()}]).
|
||||
|
||||
payload_encode() ->
|
||||
oneof([base62, base64, undefined]).
|
||||
oneof([base62, base64, plain]).
|
||||
|
||||
disconnected_conninfo() ->
|
||||
?LET(Info, conninfo(),
|
||||
|
|
|
@ -135,13 +135,7 @@ json_basic() ->
|
|||
oneof([true, false, null, number(), json_string()]).
|
||||
|
||||
latin_atom() ->
|
||||
?LET(L, list(latin_char()), list_to_atom(L)).
|
||||
|
||||
latin_char() ->
|
||||
L = lists:concat([lists:seq($0, $9),
|
||||
lists:seq($a, $z),
|
||||
lists:seq($A, $Z)]),
|
||||
oneof(L).
|
||||
emqx_ct_proper_types:limited_latin_atom().
|
||||
|
||||
json_string() -> utf8().
|
||||
|
||||
|
|
Loading…
Reference in New Issue