diff options
| author | Sebastiaan van Stijn <github@gone.nl> | 2019-07-02 13:29:24 +0200 |
|---|---|---|
| committer | Tibor Vass <tibor@docker.com> | 2019-07-09 21:42:12 +0000 |
| commit | ebb542b3f88d7f5551f6b6e1d8d2774a2c166409 (patch) | |
| tree | 113f26baa1357b8340fdf1e7015d1f0400faa2cf /api/server/middleware | |
| parent | 18dac2cf32faeaada3bd4e8e2bffa576ad4329fe (diff) | |
| download | docker-ebb542b3f88d7f5551f6b6e1d8d2774a2c166409.tar.gz | |
TestMaskSecretKeys: use subtests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 32d70c7e21631224674cd60021d3ec908c2d888c)
Signed-off-by: Tibor Vass <tibor@docker.com>
Diffstat (limited to 'api/server/middleware')
| -rw-r--r-- | api/server/middleware/debug_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/api/server/middleware/debug_test.go b/api/server/middleware/debug_test.go index 3d78d7e084..e19a0ced2f 100644 --- a/api/server/middleware/debug_test.go +++ b/api/server/middleware/debug_test.go @@ -9,26 +9,31 @@ import ( 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", @@ -60,6 +65,7 @@ func TestMaskSecretKeys(t *testing.T) { }, }, { + doc: "other paths with API version case insensitive", path: "/v1.30/some/other/path", input: map[string]interface{}{ "PASSWORD": "pass", @@ -77,7 +83,9 @@ func TestMaskSecretKeys(t *testing.T) { } 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)) + }) } } |
