test(gw): fix bad test cases
This commit is contained in:
parent
ac3af8260d
commit
45ca168216
|
@ -44,6 +44,11 @@
|
||||||
, remove_authn/2
|
, remove_authn/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
%% internal exports
|
||||||
|
-export([ unconvert_listeners/1
|
||||||
|
, convert_listeners/2
|
||||||
|
]).
|
||||||
|
|
||||||
%% callbacks for emqx_config_handler
|
%% callbacks for emqx_config_handler
|
||||||
-export([ pre_config_update/2
|
-export([ pre_config_update/2
|
||||||
, post_config_update/4
|
, post_config_update/4
|
||||||
|
|
|
@ -38,7 +38,7 @@ end_per_suite(_Conf) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_gateway]).
|
emqx_ct_helpers:stop_apps([emqx_gateway]).
|
||||||
|
|
||||||
init_per_testcase(_CaseName, Conf) ->
|
init_per_testcase(_CaseName, Conf) ->
|
||||||
_ = emqx_gateway_conf:remove_gateway(stomp),
|
_ = emqx_gateway_conf:unload_gateway(stomp),
|
||||||
Conf.
|
Conf.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -80,7 +80,7 @@ init_per_testcase(_CaseName, Conf) ->
|
||||||
<<"user_id_type">> => <<"username">>
|
<<"user_id_type">> => <<"username">>
|
||||||
}).
|
}).
|
||||||
|
|
||||||
t_load_remove_gateway(_) ->
|
t_load_unload_gateway(_) ->
|
||||||
StompConf1 = compose(?CONF_STOMP_BAISC_1,
|
StompConf1 = compose(?CONF_STOMP_BAISC_1,
|
||||||
?CONF_STOMP_AUTHN_1,
|
?CONF_STOMP_AUTHN_1,
|
||||||
?CONF_STOMP_LISTENER_1
|
?CONF_STOMP_LISTENER_1
|
||||||
|
@ -97,8 +97,8 @@ t_load_remove_gateway(_) ->
|
||||||
ok = emqx_gateway_conf:update_gateway(stomp, StompConf2),
|
ok = emqx_gateway_conf:update_gateway(stomp, StompConf2),
|
||||||
assert_confs(StompConf2, emqx:get_raw_config([gateway, stomp])),
|
assert_confs(StompConf2, emqx:get_raw_config([gateway, stomp])),
|
||||||
|
|
||||||
ok = emqx_gateway_conf:remove_gateway(stomp),
|
ok = emqx_gateway_conf:unload_gateway(stomp),
|
||||||
ok = emqx_gateway_conf:remove_gateway(stomp),
|
ok = emqx_gateway_conf:unload_gateway(stomp),
|
||||||
|
|
||||||
{error, not_found} =
|
{error, not_found} =
|
||||||
emqx_gateway_conf:update_gateway(stomp, StompConf2),
|
emqx_gateway_conf:update_gateway(stomp, StompConf2),
|
||||||
|
@ -226,9 +226,11 @@ compose_listener_authn(Basic, Listener, Authn) ->
|
||||||
listener(maps:put(<<"authentication">>, Authn, Listener))).
|
listener(maps:put(<<"authentication">>, Authn, Listener))).
|
||||||
|
|
||||||
listener(L) ->
|
listener(L) ->
|
||||||
#{<<"listeners">> => #{<<"tcp">> => #{<<"default">> => L}}}.
|
#{<<"listeners">> => [L#{<<"type">> => <<"tcp">>,
|
||||||
|
<<"name">> => <<"default">>}]}.
|
||||||
|
|
||||||
assert_confs(Expected, Effected) ->
|
assert_confs(Expected0, Effected) ->
|
||||||
|
Expected = maybe_unconvert_listeners(Expected0),
|
||||||
case do_assert_confs(Expected, Effected) of
|
case do_assert_confs(Expected, Effected) of
|
||||||
false ->
|
false ->
|
||||||
io:format(standard_error, "Expected config: ~p,\n"
|
io:format(standard_error, "Expected config: ~p,\n"
|
||||||
|
@ -248,3 +250,11 @@ do_assert_confs(Expected, Effected) when is_map(Expected),
|
||||||
end, Ks1);
|
end, Ks1);
|
||||||
do_assert_confs(Expected, Effected) ->
|
do_assert_confs(Expected, Effected) ->
|
||||||
Expected =:= Effected.
|
Expected =:= Effected.
|
||||||
|
|
||||||
|
maybe_unconvert_listeners(Conf) ->
|
||||||
|
case maps:take(<<"listeners">>, Conf) of
|
||||||
|
error -> Conf;
|
||||||
|
{Ls, Conf1} ->
|
||||||
|
Conf1#{<<"listeners">> =>
|
||||||
|
emqx_gateway_conf:unconvert_listeners(Ls)}
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue