fix(gw): merge the listener and authn confs

This commit is contained in:
JianBo He 2022-05-17 15:16:03 +08:00
parent 57bd862298
commit 61b1731e5c
2 changed files with 11 additions and 5 deletions

View File

@ -400,10 +400,14 @@ pre_config_update(_, {update_gateway, GwName, Conf}, RawConf) ->
case maps:get(GwName, RawConf, undefined) of case maps:get(GwName, RawConf, undefined) of
undefined -> undefined ->
badres_gateway(not_found, GwName); badres_gateway(not_found, GwName);
_ -> GwRawConf ->
Conf1 = maps:without([<<"listeners">>, ?AUTHN_BIN], Conf), Conf1 = maps:without([<<"listeners">>, ?AUTHN_BIN], Conf),
NConf = tune_gw_certs(fun convert_certs/2, GwName, Conf1), NConf = tune_gw_certs(fun convert_certs/2, GwName, Conf1),
{ok, emqx_map_lib:deep_put([GwName], RawConf, NConf)} NConf1 = maps:merge(
maps:with([<<"listeners">>, ?AUTHN_BIN], GwRawConf),
NConf
),
{ok, emqx_map_lib:deep_put([GwName], RawConf, NConf1)}
end; end;
pre_config_update(_, {unload_gateway, GwName}, RawConf) -> pre_config_update(_, {unload_gateway, GwName}, RawConf) ->
_ = tune_gw_certs( _ = tune_gw_certs(

View File

@ -43,7 +43,7 @@
-define(FLAG_RETAIN(X), X). -define(FLAG_RETAIN(X), X).
-define(FLAG_SESSION(X), X). -define(FLAG_SESSION(X), X).
-define(LOG(Format, Args), ct:pal("TEST: " ++ Format, Args)). -define(LOG(Format, Args), ct:log("TEST: " ++ Format, Args)).
-define(MAX_PRED_TOPIC_ID, 2). -define(MAX_PRED_TOPIC_ID, 2).
-define(PREDEF_TOPIC_ID1, 1). -define(PREDEF_TOPIC_ID1, 1).
@ -106,15 +106,17 @@ end_per_suite(_) ->
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_conf]). emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_conf]).
restart_mqttsn_with_subs_resume_on() -> restart_mqttsn_with_subs_resume_on() ->
Conf = emqx:get_raw_config([gateway, mqttsn]),
emqx_gateway_conf:update_gateway( emqx_gateway_conf:update_gateway(
mqttsn, mqttsn,
#{<<"subs_resume">> => <<"true">>} Conf#{<<"subs_resume">> => <<"true">>}
). ).
restart_mqttsn_with_subs_resume_off() -> restart_mqttsn_with_subs_resume_off() ->
Conf = emqx:get_raw_config([gateway, mqttsn]),
emqx_gateway_conf:update_gateway( emqx_gateway_conf:update_gateway(
mqttsn, mqttsn,
#{<<"subs_resume">> => <<"false">>} Conf#{<<"subs_resume">> => <<"false">>}
). ).
default_config() -> default_config() ->