|
160 | 160 | case: "redacts a RubyGems token", |
161 | 161 | message: "using rubygems token: rubygems_0123456789abcdef0123456789abcdef0123456789abcdef", |
162 | 162 | expected_message: "using rubygems token: [REDACTED]" |
| 163 | + }, |
| 164 | + { |
| 165 | + case: "redacts authorization bearer token", |
| 166 | + message: '-H "Authorization: Bearer ab123456789a1abcd1~_.-+456ABCDE=" -H "Content-Type: application/json"', |
| 167 | + expected_message: '-H "[REDACTED]" -H "Content-Type: application/json"' |
| 168 | + }, |
| 169 | + { |
| 170 | + case: "redacts authorization bearer token with case insensitivity", |
| 171 | + message: '-H "authorizAtion: beaRer ab123456789a1abcd1~_.-+456ABCDE=" -H "Content-Type: application/json"', |
| 172 | + 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]" |
163 | 208 | } |
164 | 209 | ].each do |test| |
165 | 210 | it "redacts #{test[:case]}" do |
|
0 commit comments