@@ -10,49 +10,16 @@ import (
1010func TestMaskSecretKeys (t * testing.T ) {
1111 tests := []struct {
1212 doc string
13- path string
1413 input map [string ]interface {}
1514 expected map [string ]interface {}
1615 }{
1716 {
18- doc : "secret create with API version" ,
19- path : "/v1.30/secrets/create" ,
17+ doc : "secret/config create and update requests" ,
2018 input : map [string ]interface {}{"Data" : "foo" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
2119 expected : map [string ]interface {}{"Data" : "*****" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
2220 },
2321 {
24- doc : "secret create with API version and trailing slashes" ,
25- path : "/v1.30/secrets/create//" ,
26- input : map [string ]interface {}{"Data" : "foo" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
27- expected : map [string ]interface {}{"Data" : "*****" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
28- },
29- {
30- doc : "secret create with query param" ,
31- path : "/secrets/create?key=val" ,
32- input : map [string ]interface {}{"Data" : "foo" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
33- expected : map [string ]interface {}{"Data" : "*****" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
34- },
35- {
36- doc : "secret update with API version" ,
37- path : "/v1.30/secrets/mysecret/update" ,
38- input : map [string ]interface {}{"Data" : "foo" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
39- expected : map [string ]interface {}{"Data" : "*****" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
40- },
41- {
42- doc : "secret update with API version and trailing slashes" ,
43- path : "/v1.30/secrets/mysecret/update//" ,
44- input : map [string ]interface {}{"Data" : "foo" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
45- expected : map [string ]interface {}{"Data" : "*****" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
46- },
47- {
48- doc : "secret update with query parameter" ,
49- path : "/secrets/mysecret/update?version=34" ,
50- input : map [string ]interface {}{"Data" : "foo" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
51- expected : map [string ]interface {}{"Data" : "*****" , "Name" : "name" , "Labels" : map [string ]interface {}{}},
52- },
53- {
54- doc : "other paths with API version" ,
55- path : "/v1.30/some/other/path" ,
22+ doc : "masking other fields (recursively)" ,
5623 input : map [string ]interface {}{
5724 "password" : "pass" ,
5825 "secret" : "secret" ,
@@ -83,8 +50,7 @@ func TestMaskSecretKeys(t *testing.T) {
8350 },
8451 },
8552 {
86- doc : "other paths with API version case insensitive" ,
87- path : "/v1.30/some/other/path" ,
53+ doc : "case insensitive field matching" ,
8854 input : map [string ]interface {}{
8955 "PASSWORD" : "pass" ,
9056 "other" : map [string ]interface {}{
@@ -102,7 +68,7 @@ func TestMaskSecretKeys(t *testing.T) {
10268
10369 for _ , testcase := range tests {
10470 t .Run (testcase .doc , func (t * testing.T ) {
105- maskSecretKeys (testcase .input , testcase . path )
71+ maskSecretKeys (testcase .input )
10672 assert .Check (t , is .DeepEqual (testcase .expected , testcase .input ))
10773 })
10874 }
0 commit comments