MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestRedactBasicAuthURL

Function TestRedactBasicAuthURL

base/util_test.go:574–658  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

572}
573
574func 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 {

Callers

nothing calls this directly

Calls 4

TestCtxFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected