diff --git a/lib/pact_broker/webhooks/webhook_request_template.rb b/lib/pact_broker/webhooks/webhook_request_template.rb index 786a1eebb..73c44b99d 100644 --- a/lib/pact_broker/webhooks/webhook_request_template.rb +++ b/lib/pact_broker/webhooks/webhook_request_template.rb @@ -48,7 +48,7 @@ def description end def display_password - password.nil? ? nil : "**********" + password.nil? ? nil : (PactBroker::Webhooks::Render.includes_parameter?(password) ? password : "**********") end def redacted_headers diff --git a/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb b/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb index 8d4d69c4d..7d3d113e4 100644 --- a/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb +++ b/spec/lib/pact_broker/webhooks/webhook_request_template_spec.rb @@ -8,7 +8,7 @@ module Webhooks method: 'POST', url: url, username: "username", - password: "password", + password: password, uuid: "1234", body: body, headers: headers @@ -27,6 +27,7 @@ module Webhooks } end + let(:password) { "password" } let(:headers) { {'headername' => 'headervalue'} } let(:url) { "http://example.org/hook?foo=bar" } let(:base_url) { "http://broker" } @@ -156,6 +157,28 @@ module Webhooks end end end + + describe "display_password" do + subject { WebhookRequestTemplate.new(attributes) } + + context "when it is nil" do + let(:password) { nil } + + its(:display_password) { is_expected.to be nil } + end + + context "when the password contains a parameter" do + let(:password) { "${pactbroker.foo}" } + + its(:display_password) { is_expected.to eq password } + end + + context "when the password does not contains a parameter" do + let(:password) { "foo" } + + its(:display_password) { is_expected.to eq "**********" } + end + end end end end