diff --git a/test/aprsme/log_sanitizer_test.exs b/test/aprsme/log_sanitizer_test.exs index dc622b4..040b813 100644 --- a/test/aprsme/log_sanitizer_test.exs +++ b/test/aprsme/log_sanitizer_test.exs @@ -195,6 +195,29 @@ defmodule Aprsme.LogSanitizerTest do result = LogSanitizer.sanitize_error_context(%{password: "x", stacktrace: []}) assert result[:password] == "[REDACTED]" end + + test "non-list stacktrace falls through to else-branch (line 135)" do + result = LogSanitizer.sanitize_error_context(%{stacktrace: "not-a-list"}) + assert result[:stacktrace] == "not-a-list" + end + + test "non-map context returns the input unchanged (line 140)" do + assert LogSanitizer.sanitize_error_context(:not_a_map) == :not_a_map + assert LogSanitizer.sanitize_error_context("string") == "string" + end + end + + describe "redact_match catch-all branch (line 56)" do + test "sanitize_string with redact-able token without '=' or ':' separator hits catch-all" do + # The redact_match helper splits on '=' and ':'. A pattern matching the + # sensitive regex but containing neither separator should hit the + # catch-all (line 56). + # Concrete sensitive substrings without separators are constructed + # by sanitize_string regex; we just exercise the helper through + # the public sanitize/1 with a value that triggers the secret pattern. + result = LogSanitizer.sanitize("password test") + assert is_binary(result) + end end describe "log_data/1" do