From 61b1731e5c8cb6ecc905247ab76734c5716590fe Mon Sep 17 00:00:00 2001 From: JianBo He Date: Tue, 17 May 2022 15:16:03 +0800 Subject: [PATCH] fix(gw): merge the listener and authn confs --- apps/emqx_gateway/src/emqx_gateway_conf.erl | 8 ++++++-- apps/emqx_gateway/test/emqx_sn_protocol_SUITE.erl | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/emqx_gateway/src/emqx_gateway_conf.erl b/apps/emqx_gateway/src/emqx_gateway_conf.erl index af858921a..43236f42d 100644 --- a/apps/emqx_gateway/src/emqx_gateway_conf.erl +++ b/apps/emqx_gateway/src/emqx_gateway_conf.erl @@ -400,10 +400,14 @@ pre_config_update(_, {update_gateway, GwName, Conf}, RawConf) -> case maps:get(GwName, RawConf, undefined) of undefined -> badres_gateway(not_found, GwName); - _ -> + GwRawConf -> Conf1 = maps:without([<<"listeners">>, ?AUTHN_BIN], Conf), 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; pre_config_update(_, {unload_gateway, GwName}, RawConf) -> _ = tune_gw_certs( diff --git a/apps/emqx_gateway/test/emqx_sn_protocol_SUITE.erl b/apps/emqx_gateway/test/emqx_sn_protocol_SUITE.erl index 084249764..41e007770 100644 --- a/apps/emqx_gateway/test/emqx_sn_protocol_SUITE.erl +++ b/apps/emqx_gateway/test/emqx_sn_protocol_SUITE.erl @@ -43,7 +43,7 @@ -define(FLAG_RETAIN(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(PREDEF_TOPIC_ID1, 1). @@ -106,15 +106,17 @@ end_per_suite(_) -> emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_conf]). restart_mqttsn_with_subs_resume_on() -> + Conf = emqx:get_raw_config([gateway, mqttsn]), emqx_gateway_conf:update_gateway( mqttsn, - #{<<"subs_resume">> => <<"true">>} + Conf#{<<"subs_resume">> => <<"true">>} ). restart_mqttsn_with_subs_resume_off() -> + Conf = emqx:get_raw_config([gateway, mqttsn]), emqx_gateway_conf:update_gateway( mqttsn, - #{<<"subs_resume">> => <<"false">>} + Conf#{<<"subs_resume">> => <<"false">>} ). default_config() ->