Fix the password display problem when passing the chart link (#1281)

* Fix the password display problem when passing the
chart link

Signed-off-by: Eduardo Naves <eduardonaves41@gmail.com>
This commit is contained in:
Eduardo Naves
2024-01-24 09:01:04 +08:00
committed by GitHub
parent 6707a3d392
commit 430677d43c
2 changed files with 41 additions and 1 deletions
+22
View File
@@ -3455,3 +3455,25 @@ func TestAppendChartDownloadTLSFlags(t *testing.T) {
})
}
}
func TestHideChartURL(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"http://username:password@example.com/", "http://---:---@example.com/"},
{"http://example.com@", "http://---:---@"},
{"https://username:password@example.com/", "https://---:---@example.com/"},
{"https://username:@password@example.com/", "https://---:---@example.com/"},
{"https://username::password@example.com/", "https://---:---@example.com/"},
{"https://username:httpd@example.com/", "https://---:---@example.com/"},
{"https://username:httpsd@example.com/", "https://---:---@example.com/"},
{"https://example.com/", "https://example.com/"},
}
for _, test := range tests {
result, _ := hideChartCredentials(test.input)
if result != test.expected {
t.Errorf("For input '%s', expected '%s', but got '%s'", test.input, test.expected, result)
}
}
}