Skip to content

Commit f7042d2

Browse files
committed
add more bearer token edge cases
1 parent 75f477e commit f7042d2

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

spec/lib/redacting_logger_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,41 @@
170170
case: "redacts authorization bearer token with case insensitivity",
171171
message: '-H "authorizAtion: beaRer ab123456789a1abcd1~_.-+456ABCDE=" -H "Content-Type: application/json"',
172172
expected_message: '-H "[REDACTED]" -H "Content-Type: application/json"'
173+
},
174+
{
175+
case: "redacts authorization bearer token with extra spaces and tabs",
176+
message: "authorization: bearer abcd1234",
177+
expected_message: "[REDACTED]"
178+
},
179+
{
180+
case: "redacts authorization bearer token with special characters",
181+
message: "authorization: bearer aBcD-_=~+/1234",
182+
expected_message: "[REDACTED]"
183+
},
184+
{
185+
case: "redacts authorization bearer token at start of string",
186+
message: "authorization: bearer tokenatstart",
187+
expected_message: "[REDACTED]"
188+
},
189+
{
190+
case: "redacts authorization bearer token at end of string",
191+
message: "some text authorization: bearer tokenatend",
192+
expected_message: "some text [REDACTED]"
193+
},
194+
{
195+
case: "redacts multiple authorization bearer tokens in one string",
196+
message: "authorization: bearer token1 and authorization: bearer token2",
197+
expected_message: "[REDACTED] and [REDACTED]"
198+
},
199+
{
200+
case: "redacts authorization bearer token with minimum plausible length",
201+
message: "authorization: bearer a",
202+
expected_message: "[REDACTED]"
203+
},
204+
{
205+
case: "redacts authorization bearer token with maximum plausible length",
206+
message: "authorization: bearer #{'a' * 256}",
207+
expected_message: "[REDACTED]"
173208
}
174209
].each do |test|
175210
it "redacts #{test[:case]}" do

0 commit comments

Comments
 (0)