Skip to content

Commit

Permalink
fix: correct logic when redacting database URL without a password
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Nov 6, 2021
1 parent ae10d8e commit 30d66cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ def redact name, value
if value && name.to_s.end_with?("_url")
begin
uri = URI(value)
uri.password = "*****"
uri.to_s
if uri.password
uri.password = "*****"
uri.to_s
else
value
end
rescue StandardError
"*****"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ module Config
expect(subject).to include "database_password=*****"
expect(subject).to include "database_url=protocol://username:*****@host/database"
end

context "with a database URL with no password" do
let(:initial_values) { { database_password: "foo", database_url: "sqlite:///pact_broker.sqlite3" } }

it "maintians the specified value" do
expect(subject).to include "database_url=sqlite:///pact_broker.sqlite3"
end
end
end
end
end

0 comments on commit 30d66cf

Please sign in to comment.