Skip to content

Commit

Permalink
Fix displaying redacted basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Aug 18, 2023
1 parent c89e8c6 commit 7ad4bc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/req/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ defmodule Req.Request do
%{request.options | auth: {:bearer, "[redacted]"}}

%{auth: {_username, _password}} ->
%{request.options | auth: {["redacted"], "[redacted]"}}
%{request.options | auth: {"[redacted]", "[redacted]"}}

_ ->
request.options
Expand Down
2 changes: 2 additions & 0 deletions test/req_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ defmodule ReqTest do
test "redact" do
assert inspect(Req.new(auth: {:bearer, "foo"})) =~ ~s|auth: {:bearer, "[redacted]"}|

assert inspect(Req.new(auth: {"foo", "bar"})) =~ ~s|auth: {"[redacted]", "[redacted]"}|

assert inspect(Req.new(headers: [authorization: "bearer foo"])) =~
~s|{"authorization", "[redacted]"}|
end
Expand Down

0 comments on commit 7ad4bc8

Please sign in to comment.