|
|
@@ -45,6 +45,33 @@ no_redact_template_var_test() ->
|
|
|
})
|
|
|
).
|
|
|
|
|
|
+no_redact_file_paths_test() ->
|
|
|
+ ?assertEqual(
|
|
|
+ #{
|
|
|
+ password => <<"file:///abs/path/a">>,
|
|
|
+ <<"secret">> => <<"file://relative/path/b">>,
|
|
|
+ account_key => "file://string/path/x",
|
|
|
+ private_key => "file://string/path/y"
|
|
|
+ },
|
|
|
+ redact(#{
|
|
|
+ password => <<"file:///abs/path/a">>,
|
|
|
+ <<"secret">> => <<"file://relative/path/b">>,
|
|
|
+ account_key => "file://string/path/x",
|
|
|
+ private_key => "file://string/path/y"
|
|
|
+ })
|
|
|
+ ).
|
|
|
+
|
|
|
+deobfuscate_file_path_secrets_test_() ->
|
|
|
+ Original1 = #{foo => #{bar => #{headers => #{"authorization" => "file://a"}}}},
|
|
|
+ Original2 = #{foo => #{bar => #{headers => #{"authorization" => "a"}}}},
|
|
|
+ Redacted2 = #{foo => #{bar => #{headers => #{"authorization" => "******"}}}},
|
|
|
+ [
|
|
|
+ ?_assertEqual(Original1, redact(Original1)),
|
|
|
+ ?_assertEqual(Original1, emqx_utils_redact:deobfuscate(Original1, Original1)),
|
|
|
+ ?_assertEqual(Redacted2, redact(Original2)),
|
|
|
+ ?_assertEqual(Original2, emqx_utils_redact:deobfuscate(Redacted2, Original2))
|
|
|
+ ].
|
|
|
+
|
|
|
redact(X) -> emqx_utils:redact(X).
|
|
|
|
|
|
is_redacted(Key, Value) ->
|