Skip to content

Commit

Permalink
more detailed scrubber test
Browse files Browse the repository at this point in the history
  • Loading branch information
whossname committed Feb 8, 2022
1 parent 4143751 commit 9439176
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/slack_logger_backend/format_helper_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ defmodule SlackLoggerBackend.FormatHelperTest do
use ExUnit.Case

test "scrubber redacts secrets" do
scrubber = {~r/(password: \")(.+)(\")/, "\\1--redadacted--\\3"}
scrubber = {~r/(password|token|secret)(: \")(.+?)(\")/, "\\1\\2--redacted--\\4"}
Application.put_env(:slack_logger_backend, :scrubber, scrubber)

message =
%{level: "error", message: "username: \"user\", password: \"password\""}
%{
level: "error",
message:
"username: \"user\", password: \"password\", token: \"token\", client_secret: \"secret\""
}
|> FormatHelper.format_event()
|> get_message()

assert message == "username: \"user\", password: \"--redadacted--\""
assert message ==
"username: \"user\", password: \"--redacted--\", token: \"--redacted--\", client_secret: \"--redacted--\""
end

defp get_message(message) do
Expand Down

0 comments on commit 9439176

Please sign in to comment.