summaryrefslogtreecommitdiff
path: root/api/server/middleware
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2019-07-02 13:21:04 +0200
committerTibor Vass <tibor@docker.com>2019-07-09 21:42:12 +0000
commit18dac2cf32faeaada3bd4e8e2bffa576ad4329fe (patch)
treeb91a5cded95750c4192fe65cdb84c39b293b7cb9 /api/server/middleware
parentf550cb579219de4d8284c4a46f44191d66bdc4fd (diff)
downloaddocker-18dac2cf32faeaada3bd4e8e2bffa576ad4329fe.tar.gz
TestMaskSecretKeys: add more test-cases
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>
Diffstat (limited to 'api/server/middleware')
-rw-r--r--api/server/middleware/debug_test.go30
1 files changed, 27 insertions, 3 deletions
diff --git a/api/server/middleware/debug_test.go b/api/server/middleware/debug_test.go
index a64b73e0d7..3d78d7e084 100644
--- a/api/server/middleware/debug_test.go
+++ b/api/server/middleware/debug_test.go
@@ -23,7 +23,6 @@ func TestMaskSecretKeys(t *testing.T) {
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
expected: map[string]interface{}{"Data": "*****", "Name": "name", "Labels": map[string]interface{}{}},
},
-
{
path: "/secrets/create?key=val",
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
@@ -32,8 +31,13 @@ func TestMaskSecretKeys(t *testing.T) {
{
path: "/v1.30/some/other/path",
input: map[string]interface{}{
- "password": "pass",
+ "password": "pass",
+ "secret": "secret",
+ "jointoken": "jointoken",
+ "unlockkey": "unlockkey",
+ "signingcakey": "signingcakey",
"other": map[string]interface{}{
+ "password": "pass",
"secret": "secret",
"jointoken": "jointoken",
"unlockkey": "unlockkey",
@@ -41,8 +45,13 @@ func TestMaskSecretKeys(t *testing.T) {
},
},
expected: map[string]interface{}{
- "password": "*****",
+ "password": "*****",
+ "secret": "*****",
+ "jointoken": "*****",
+ "unlockkey": "*****",
+ "signingcakey": "*****",
"other": map[string]interface{}{
+ "password": "*****",
"secret": "*****",
"jointoken": "*****",
"unlockkey": "*****",
@@ -50,6 +59,21 @@ func TestMaskSecretKeys(t *testing.T) {
},
},
},
+ {
+ path: "/v1.30/some/other/path",
+ input: map[string]interface{}{
+ "PASSWORD": "pass",
+ "other": map[string]interface{}{
+ "PASSWORD": "pass",
+ },
+ },
+ expected: map[string]interface{}{
+ "PASSWORD": "*****",
+ "other": map[string]interface{}{
+ "PASSWORD": "*****",
+ },
+ },
+ },
}
for _, testcase := range tests {