test: fix another broken test

This commit is contained in:
Thales Macedo Garitezi 2023-12-19 20:02:54 -03:00
parent 1ad3100cad
commit 7fc069da46
1 changed files with 16 additions and 5 deletions

View File

@ -32,7 +32,9 @@ init_per_suite(Config) ->
emqx_conf, emqx_conf,
emqx_connector, emqx_connector,
emqx_bridge_http, emqx_bridge_http,
emqx_bridge emqx_bridge_mqtt,
emqx_bridge,
emqx_rule_engine
], ],
#{work_dir => ?config(priv_dir, Config)} #{work_dir => ?config(priv_dir, Config)}
), ),
@ -154,14 +156,18 @@ setup_fake_telemetry_data() ->
ok. ok.
t_update_ssl_conf(Config) -> t_update_ssl_conf(Config) ->
Path = proplists:get_value(config_path, Config), [_Root, Type, Name] = proplists:get_value(config_path, Config),
CertDir = filename:join([emqx:mutable_certs_dir() | Path]), CertDir = filename:join([emqx:mutable_certs_dir(), connectors, Type, Name]),
EnableSSLConf = #{ EnableSSLConf = #{
<<"bridge_mode">> => false, <<"bridge_mode">> => false,
<<"clean_start">> => true, <<"clean_start">> => true,
<<"keepalive">> => <<"60s">>, <<"keepalive">> => <<"60s">>,
<<"proto_ver">> => <<"v4">>, <<"proto_ver">> => <<"v4">>,
<<"server">> => <<"127.0.0.1:1883">>, <<"server">> => <<"127.0.0.1:1883">>,
<<"egress">> => #{
<<"local">> => #{<<"topic">> => <<"t">>},
<<"remote">> => #{<<"topic">> => <<"remote/t">>}
},
<<"ssl">> => <<"ssl">> =>
#{ #{
<<"cacertfile">> => cert_file("cafile"), <<"cacertfile">> => cert_file("cafile"),
@ -171,10 +177,15 @@ t_update_ssl_conf(Config) ->
<<"verify">> => <<"verify_peer">> <<"verify">> => <<"verify_peer">>
} }
}, },
{ok, _} = emqx:update_config(Path, EnableSSLConf), CreateCfg = [
{bridge_name, Name},
{bridge_type, Type},
{bridge_config, #{}}
],
{ok, _} = emqx_bridge_testlib:create_bridge_api(CreateCfg, EnableSSLConf),
?assertMatch({ok, [_, _, _]}, file:list_dir(CertDir)), ?assertMatch({ok, [_, _, _]}, file:list_dir(CertDir)),
NoSSLConf = EnableSSLConf#{<<"ssl">> := #{<<"enable">> => false}}, NoSSLConf = EnableSSLConf#{<<"ssl">> := #{<<"enable">> => false}},
{ok, _} = emqx:update_config(Path, NoSSLConf), {ok, _} = emqx_bridge_testlib:update_bridge_api(CreateCfg, NoSSLConf),
{ok, _} = emqx_tls_certfile_gc:force(), {ok, _} = emqx_tls_certfile_gc:force(),
?assertMatch({error, enoent}, file:list_dir(CertDir)), ?assertMatch({error, enoent}, file:list_dir(CertDir)),
ok. ok.