diff --git a/lib/pact_broker/config/runtime_configuration_logging_methods.rb b/lib/pact_broker/config/runtime_configuration_logging_methods.rb index 7dfb1ec00..f21b0b1fe 100644 --- a/lib/pact_broker/config/runtime_configuration_logging_methods.rb +++ b/lib/pact_broker/config/runtime_configuration_logging_methods.rb @@ -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 diff --git a/spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb b/spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb index 132d71c21..4ed82a129 100644 --- a/spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb +++ b/spec/lib/pact_broker/config/runtime_configuration_logging_methods_spec.rb @@ -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