(t *testing.T)
| 249 | } |
| 250 | |
| 251 | func TestSanitizeErrorMessage_RealWorldExamples(t *testing.T) { |
| 252 | tests := []struct { |
| 253 | name string |
| 254 | message string |
| 255 | expected string |
| 256 | }{ |
| 257 | { |
| 258 | name: "GitHub Actions error", |
| 259 | message: "Failed to authenticate: GITHUB_TOKEN is invalid", |
| 260 | expected: "Failed to authenticate: [REDACTED] is invalid", |
| 261 | }, |
| 262 | { |
| 263 | name: "AWS credentials error", |
| 264 | message: "AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required", |
| 265 | expected: "[REDACTED] and [REDACTED] are required", |
| 266 | }, |
| 267 | { |
| 268 | name: "Database connection error", |
| 269 | message: "Could not connect using DB_PASSWORD: connection refused", |
| 270 | expected: "Could not connect using [REDACTED]: connection refused", |
| 271 | }, |
| 272 | { |
| 273 | name: "API error with token", |
| 274 | message: "Request failed with ApiToken: 401 Unauthorized", |
| 275 | expected: "Request failed with [REDACTED]: 401 Unauthorized", |
| 276 | }, |
| 277 | } |
| 278 | |
| 279 | for _, tt := range tests { |
| 280 | t.Run(tt.name, func(t *testing.T) { |
| 281 | result := SanitizeErrorMessage(tt.message) |
| 282 | assertSanitizeResult(t, "SanitizeErrorMessage", tt.message, result, tt.expected) |
| 283 | }) |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | func BenchmarkSanitizeErrorMessage_NoSecrets(b *testing.B) { |
| 288 | message := "This is a regular error message with no secrets to redact" |
nothing calls this directly
no test coverage detected