github.com/prysmaticlabs/prysm@v1.4.4/shared/logutil/logutil_test.go (about) 1 package logutil 2 3 import ( 4 "testing" 5 6 "github.com/prysmaticlabs/prysm/shared/testutil/require" 7 ) 8 9 var urltests = []struct { 10 url string 11 maskedUrl string 12 }{ 13 {"https://a:b@xyz.net", "https://***@xyz.net"}, 14 {"https://eth-goerli.alchemyapi.io/v2/tOZG5mjl3.zl_nZdZTNIBUzsDq62R_dkOtY", 15 "https://eth-goerli.alchemyapi.io/***"}, 16 {"https://google.com/search?q=golang", "https://google.com/***"}, 17 {"https://user@example.com/foo%2fbar", "https://***@example.com/***"}, 18 {"http://john@example.com/#x/y%2Fz", "http://***@example.com/#***"}, 19 {"https://me:pass@example.com/foo/bar?x=1&y=2", "https://***@example.com/***"}, 20 } 21 22 func TestMaskCredentialsLogging(t *testing.T) { 23 for _, test := range urltests { 24 require.Equal(t, MaskCredentialsLogging(test.url), test.maskedUrl) 25 } 26 }