Add tests for
- case-insensitive matching of fields
- recursive masking
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit db5f811216e70bcb4a10e477c1558d6c68f618c5)
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 18dac2cf32faeaada3bd4e8e2bffa576ad4329fe)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -23,7 +23,6 @@ func TestMaskSecretKeys(t *testing.T) {
|
| 23 | 23 |
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
|
| 24 | 24 |
expected: map[string]interface{}{"Data": "*****", "Name": "name", "Labels": map[string]interface{}{}},
|
| 25 | 25 |
}, |
| 26 |
- |
|
| 27 | 26 |
{
|
| 28 | 27 |
path: "/secrets/create?key=val", |
| 29 | 28 |
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
|
| ... | ... |
@@ -32,8 +31,13 @@ func TestMaskSecretKeys(t *testing.T) {
|
| 32 | 32 |
{
|
| 33 | 33 |
path: "/v1.30/some/other/path", |
| 34 | 34 |
input: map[string]interface{}{
|
| 35 |
- "password": "pass", |
|
| 35 |
+ "password": "pass", |
|
| 36 |
+ "secret": "secret", |
|
| 37 |
+ "jointoken": "jointoken", |
|
| 38 |
+ "unlockkey": "unlockkey", |
|
| 39 |
+ "signingcakey": "signingcakey", |
|
| 36 | 40 |
"other": map[string]interface{}{
|
| 41 |
+ "password": "pass", |
|
| 37 | 42 |
"secret": "secret", |
| 38 | 43 |
"jointoken": "jointoken", |
| 39 | 44 |
"unlockkey": "unlockkey", |
| ... | ... |
@@ -41,8 +45,13 @@ func TestMaskSecretKeys(t *testing.T) {
|
| 41 | 41 |
}, |
| 42 | 42 |
}, |
| 43 | 43 |
expected: map[string]interface{}{
|
| 44 |
- "password": "*****", |
|
| 44 |
+ "password": "*****", |
|
| 45 |
+ "secret": "*****", |
|
| 46 |
+ "jointoken": "*****", |
|
| 47 |
+ "unlockkey": "*****", |
|
| 48 |
+ "signingcakey": "*****", |
|
| 45 | 49 |
"other": map[string]interface{}{
|
| 50 |
+ "password": "*****", |
|
| 46 | 51 |
"secret": "*****", |
| 47 | 52 |
"jointoken": "*****", |
| 48 | 53 |
"unlockkey": "*****", |
| ... | ... |
@@ -50,6 +59,21 @@ func TestMaskSecretKeys(t *testing.T) {
|
| 50 | 50 |
}, |
| 51 | 51 |
}, |
| 52 | 52 |
}, |
| 53 |
+ {
|
|
| 54 |
+ path: "/v1.30/some/other/path", |
|
| 55 |
+ input: map[string]interface{}{
|
|
| 56 |
+ "PASSWORD": "pass", |
|
| 57 |
+ "other": map[string]interface{}{
|
|
| 58 |
+ "PASSWORD": "pass", |
|
| 59 |
+ }, |
|
| 60 |
+ }, |
|
| 61 |
+ expected: map[string]interface{}{
|
|
| 62 |
+ "PASSWORD": "*****", |
|
| 63 |
+ "other": map[string]interface{}{
|
|
| 64 |
+ "PASSWORD": "*****", |
|
| 65 |
+ }, |
|
| 66 |
+ }, |
|
| 67 |
+ }, |
|
| 53 | 68 |
} |
| 54 | 69 |
|
| 55 | 70 |
for _, testcase := range tests {
|