mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
c687381870
Path-specific rules were removed, so this is no longer used.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 530e63c1a61b105a6f7fc143c5acb9b5cd87f958)
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit f8a0f26843
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
75 lines
1.9 KiB
Go
75 lines
1.9 KiB
Go
package middleware // import "github.com/docker/docker/api/server/middleware"
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gotest.tools/assert"
|
|
is "gotest.tools/assert/cmp"
|
|
)
|
|
|
|
func TestMaskSecretKeys(t *testing.T) {
|
|
tests := []struct {
|
|
doc string
|
|
input map[string]interface{}
|
|
expected map[string]interface{}
|
|
}{
|
|
{
|
|
doc: "secret/config create and update requests",
|
|
input: map[string]interface{}{"Data": "foo", "Name": "name", "Labels": map[string]interface{}{}},
|
|
expected: map[string]interface{}{"Data": "*****", "Name": "name", "Labels": map[string]interface{}{}},
|
|
},
|
|
{
|
|
doc: "masking other fields (recursively)",
|
|
input: map[string]interface{}{
|
|
"password": "pass",
|
|
"secret": "secret",
|
|
"jointoken": "jointoken",
|
|
"unlockkey": "unlockkey",
|
|
"signingcakey": "signingcakey",
|
|
"other": map[string]interface{}{
|
|
"password": "pass",
|
|
"secret": "secret",
|
|
"jointoken": "jointoken",
|
|
"unlockkey": "unlockkey",
|
|
"signingcakey": "signingcakey",
|
|
},
|
|
},
|
|
expected: map[string]interface{}{
|
|
"password": "*****",
|
|
"secret": "*****",
|
|
"jointoken": "*****",
|
|
"unlockkey": "*****",
|
|
"signingcakey": "*****",
|
|
"other": map[string]interface{}{
|
|
"password": "*****",
|
|
"secret": "*****",
|
|
"jointoken": "*****",
|
|
"unlockkey": "*****",
|
|
"signingcakey": "*****",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
doc: "case insensitive field matching",
|
|
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 {
|
|
t.Run(testcase.doc, func(t *testing.T) {
|
|
maskSecretKeys(testcase.input)
|
|
assert.Check(t, is.DeepEqual(testcase.expected, testcase.input))
|
|
})
|
|
}
|
|
}
|