From 1f235ffee935696e15fb06c2da8aa7c7e31c9810 Mon Sep 17 00:00:00 2001 From: Erik Timan Date: Thu, 26 Jan 2023 10:30:13 +0100 Subject: [PATCH] refactor(emqx_ee_connector): redo readact key function --- .../src/emqx_ee_connector_influxdb.erl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib-ee/emqx_ee_connector/src/emqx_ee_connector_influxdb.erl b/lib-ee/emqx_ee_connector/src/emqx_ee_connector_influxdb.erl index 1370ed2c2..402202b11 100644 --- a/lib-ee/emqx_ee_connector/src/emqx_ee_connector_influxdb.erl +++ b/lib-ee/emqx_ee_connector/src/emqx_ee_connector_influxdb.erl @@ -341,9 +341,10 @@ password(_) -> redact_auth(Term) -> emqx_misc:redact(Term, fun is_auth_key/1). -is_auth_key(<<"Authorization">>) -> true; -is_auth_key(<<"authorization">>) -> true; -is_auth_key(_) -> false. +is_auth_key(Key) when is_binary(Key) -> + string:equal("authorization", Key, true); +is_auth_key(_) -> + false. %% ------------------------------------------------------------------------------------------------- %% Query @@ -628,6 +629,13 @@ is_unrecoverable_error(_) -> -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). +is_auth_key_test_() -> + [ + ?_assert(is_auth_key(<<"Authorization">>)), + ?_assertNot(is_auth_key(<<"Something">>)), + ?_assertNot(is_auth_key(89)) + ]. + %% for coverage desc_test_() -> [