@@ -4,6 +4,8 @@ module PactBroker
4
4
module Webhooks
5
5
describe RedactLogs do
6
6
describe ".call" do
7
+ let ( :values ) { [ ] }
8
+
7
9
let ( :string ) do
8
10
"Authorization: foo\n X-Thing: bar"
9
11
end
@@ -25,23 +27,32 @@ module Webhooks
25
27
end
26
28
27
29
it "hides the value of the Authorization header" do
28
- expect ( RedactLogs . call ( string ) ) . to eq "Authorization: [REDACTED]\n X-Thing: bar"
30
+ expect ( RedactLogs . call ( string , values ) ) . to eq "Authorization: [REDACTED]\n X-Thing: bar"
29
31
end
30
32
31
33
it "hides the value of the X-Authorization header" do
32
- expect ( RedactLogs . call ( x_auth_string ) ) . to eq "X-Authorization: [REDACTED]\n X-Thing: bar"
34
+ expect ( RedactLogs . call ( x_auth_string , values ) ) . to eq "X-Authorization: [REDACTED]\n X-Thing: bar"
33
35
end
34
36
35
37
it "hides the value of the X-Auth-Token header" do
36
- expect ( RedactLogs . call ( x_auth_token ) ) . to eq "X-Auth-Token: [REDACTED]\n X-Thing: bar"
38
+ expect ( RedactLogs . call ( x_auth_token , values ) ) . to eq "X-Auth-Token: [REDACTED]\n X-Thing: bar"
37
39
end
38
40
39
41
it "hides the value of the X-Authorization-Token header" do
40
- expect ( RedactLogs . call ( x_authorization_token ) ) . to eq "X-Authorization-Token: [REDACTED]\n X-Thing: bar"
42
+ expect ( RedactLogs . call ( x_authorization_token , values ) ) . to eq "X-Authorization-Token: [REDACTED]\n X-Thing: bar"
41
43
end
42
44
43
45
it "hides the value of the authorization header" do
44
- expect ( RedactLogs . call ( string_lower ) ) . to eq "authorization: [REDACTED]\n X-Thing: bar"
46
+ expect ( RedactLogs . call ( string_lower , values ) ) . to eq "authorization: [REDACTED]\n X-Thing: bar"
47
+ end
48
+
49
+ context "with values" do
50
+ let ( :values ) { %w[ foo bar ] }
51
+ let ( :string ) { "blahfoo\n bar wiffle" }
52
+
53
+ it "hides the passed in values" do
54
+ expect ( RedactLogs . call ( string , values ) ) . to eq "blah********\n ******** wiffle"
55
+ end
45
56
end
46
57
end
47
58
end
0 commit comments