(t *testing.T)
| 572 | } |
| 573 | |
| 574 | func TestRedactBasicAuthURL(t *testing.T) { |
| 575 | tests := []struct { |
| 576 | input, |
| 577 | expected string |
| 578 | }{ |
| 579 | { |
| 580 | input: "http://hostname", |
| 581 | expected: "http://hostname", |
| 582 | }, |
| 583 | { |
| 584 | input: "http://username:password@hostname", |
| 585 | expected: "http://xxxxx:xxxxx@hostname", |
| 586 | }, |
| 587 | { |
| 588 | input: "https://username:password@example.org:8123", |
| 589 | expected: "https://xxxxx:xxxxx@example.org:8123", |
| 590 | }, |
| 591 | { |
| 592 | input: "https://username:password@example.org/path", |
| 593 | expected: "https://xxxxx:xxxxx@example.org/path", |
| 594 | }, |
| 595 | { |
| 596 | input: "https://username:password@example.org:8123/path?key=val&email=me@example.org", |
| 597 | expected: "https://xxxxx:xxxxx@example.org:8123/path?key=val&email=me@example.org", |
| 598 | }, |
| 599 | { |
| 600 | input: "https://foo%40bar.baz:my-%24ecret-p%40%25%24w0rd@example.com:8888/bar", |
| 601 | expected: "https://xxxxx:xxxxx@example.com:8888/bar", |
| 602 | }, |
| 603 | { |
| 604 | input: "https://example.com/does-not-count-as-url-embedded:basic-auth-credentials@qux", |
| 605 | expected: "https://example.com/does-not-count-as-url-embedded:basic-auth-credentials@qux", |
| 606 | }, |
| 607 | { |
| 608 | input: "http://example.org", |
| 609 | expected: "http://example.org", |
| 610 | }, |
| 611 | { |
| 612 | input: "http://example.org:1234", |
| 613 | expected: "http://example.org:1234", |
| 614 | }, |
| 615 | { |
| 616 | input: "http://foo:bar@example.org", |
| 617 | expected: "http://xxxxx:xxxxx@example.org", |
| 618 | }, |
| 619 | { |
| 620 | input: "http://foo:bar@example.org:1234", |
| 621 | expected: "http://xxxxx:xxxxx@example.org:1234", |
| 622 | }, |
| 623 | { |
| 624 | input: "http://foo:p@ssw0rd@example.org", |
| 625 | expected: "http://xxxxx:xxxxx@example.org", |
| 626 | }, |
| 627 | { |
| 628 | input: "http://foo:@example.org", |
| 629 | expected: "http://xxxxx:xxxxx@example.org", |
| 630 | }, |
| 631 | { |
nothing calls this directly
no test coverage detected