Add LogSanitizer tests for sanitize_error_context non-list/non-map branches
This commit is contained in:
parent
2b1a06a6cd
commit
e95e2bfe32
1 changed files with 23 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue