func TestMaskSecretKeys(t *testing.T) {
tests := []struct {
+ doc string
path string
input map[string]interface{}
expected map[string]interface{}
}{
{
+ doc: "secret create with API version",
path: "/v1.30/secrets/create",
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
expected: map[string]interface{}{"Data": "*****", "Name": "name", "Labels": map[string]interface{}{}},
},
{
+ doc: "secret create with API version and trailing slashes",
path: "/v1.30/secrets/create//",
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
expected: map[string]interface{}{"Data": "*****", "Name": "name", "Labels": map[string]interface{}{}},
},
{
+ doc: "secret create with query param",
path: "/secrets/create?key=val",
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
expected: map[string]interface{}{"Data": "*****", "Name": "name", "Labels": map[string]interface{}{}},
},
{
+ doc: "other paths with API version",
path: "/v1.30/some/other/path",
input: map[string]interface{}{
"password": "pass",
},
},
{
+ doc: "other paths with API version case insensitive",
path: "/v1.30/some/other/path",
input: map[string]interface{}{
"PASSWORD": "pass",
}
for _, testcase := range tests {
- maskSecretKeys(testcase.input, testcase.path)
- assert.Check(t, is.DeepEqual(testcase.expected, testcase.input))
+ t.Run(testcase.doc, func(t *testing.T) {
+ maskSecretKeys(testcase.input, testcase.path)
+ assert.Check(t, is.DeepEqual(testcase.expected, testcase.input))
+ })
}
}