File tree 2 files changed +25
-2
lines changed
spec/lib/pact_broker/webhooks
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def description
48
48
end
49
49
50
50
def display_password
51
- password . nil? ? nil : "**********"
51
+ password . nil? ? nil : ( PactBroker :: Webhooks :: Render . includes_parameter? ( password ) ? password : "**********" )
52
52
end
53
53
54
54
def redacted_headers
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module Webhooks
8
8
method : 'POST' ,
9
9
url : url ,
10
10
username : "username" ,
11
- password : " password" ,
11
+ password : password ,
12
12
uuid : "1234" ,
13
13
body : body ,
14
14
headers : headers
@@ -27,6 +27,7 @@ module Webhooks
27
27
}
28
28
end
29
29
30
+ let ( :password ) { "password" }
30
31
let ( :headers ) { { 'headername' => 'headervalue' } }
31
32
let ( :url ) { "http://example.org/hook?foo=bar" }
32
33
let ( :base_url ) { "http://broker" }
@@ -156,6 +157,28 @@ module Webhooks
156
157
end
157
158
end
158
159
end
160
+
161
+ describe "display_password" do
162
+ subject { WebhookRequestTemplate . new ( attributes ) }
163
+
164
+ context "when it is nil" do
165
+ let ( :password ) { nil }
166
+
167
+ its ( :display_password ) { is_expected . to be nil }
168
+ end
169
+
170
+ context "when the password contains a parameter" do
171
+ let ( :password ) { "${pactbroker.foo}" }
172
+
173
+ its ( :display_password ) { is_expected . to eq password }
174
+ end
175
+
176
+ context "when the password does not contains a parameter" do
177
+ let ( :password ) { "foo" }
178
+
179
+ its ( :display_password ) { is_expected . to eq "**********" }
180
+ end
181
+ end
159
182
end
160
183
end
161
184
end
You can’t perform that action at this time.
0 commit comments