(t *testing.T)
| 380 | } |
| 381 | |
| 382 | func TestSanitizeRequestURL(t *testing.T) { |
| 383 | |
| 384 | tests := []struct { |
| 385 | input, output string |
| 386 | }{ |
| 387 | { |
| 388 | // Test zero values |
| 389 | "", "", |
| 390 | }, |
| 391 | { |
| 392 | "http://localhost:4985/default/_oidc_callback?code=4/1zaCA0RXtFqw93PmcP9fqOMMHfyBDhI0fS2AzeQw-5E", |
| 393 | "http://localhost:4985/default/_oidc_callback?code=******", |
| 394 | }, |
| 395 | { |
| 396 | "http://localhost:4985/default/_oidc_refresh?refresh_token==1/KPuhjLJrTZO9OExSypWtqiDioXf3nzAUJnewmyhK94s", |
| 397 | "http://localhost:4985/default/_oidc_refresh?refresh_token=******", |
| 398 | }, |
| 399 | { |
| 400 | // Ensure non-matching parameters aren't getting sanitized |
| 401 | "http://localhost:4985/default/_oidc_callback?code=4/1zaCA0RXtFqw93PmcP9fqOMMHfyBDhI0fS2AzeQw-5E&state=123456", |
| 402 | "http://localhost:4985/default/_oidc_callback?code=******&state=123456", |
| 403 | }, |
| 404 | { |
| 405 | "http://localhost:4985/default/_changes?since=5&feed=longpoll", |
| 406 | "http://localhost:4985/default/_changes?since=5&feed=longpoll", |
| 407 | }, |
| 408 | { |
| 409 | // Ensure matching non-parameters aren't getting sanitized |
| 410 | "http://localhost:4985/default/doctokencode", |
| 411 | "http://localhost:4985/default/doctokencode", |
| 412 | }, |
| 413 | { |
| 414 | "http://localhost:4985/default/doctoken=code=", |
| 415 | "http://localhost:4985/default/doctoken=code=", |
| 416 | }, |
| 417 | } |
| 418 | |
| 419 | for _, test := range tests { |
| 420 | req, err := http.NewRequest(http.MethodGet, test.input, nil) |
| 421 | assert.NoError(t, err, "Unable to create request") |
| 422 | sanitizedURL := SanitizeRequestURL(req, nil) |
| 423 | assert.Equal(t, test.output, sanitizedURL) |
| 424 | } |
| 425 | |
| 426 | } |
| 427 | |
| 428 | func TestSanitizeRequestURLRedaction(t *testing.T) { |
| 429 |
nothing calls this directly
no test coverage detected