From: Sebastiaan van Stijn Date: Tue, 2 Jul 2019 11:29:24 +0000 (+0200) Subject: TestMaskSecretKeys: use subtests X-Git-Tag: archive/raspbian/18.09.1+dfsg1-7.1+rpi1+deb10u1^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=88c8ba9f38f4de1f35e2ebdc3a8ed71ac9cabd7f;p=docker.io.git TestMaskSecretKeys: use subtests Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 32d70c7e21631224674cd60021d3ec908c2d888c) Signed-off-by: Tibor Vass (cherry picked from commit ebb542b3f88d7f5551f6b6e1d8d2774a2c166409) Signed-off-by: Sebastiaan van Stijn Origin: https://github.com/docker/engine/pull/298 Gbp-Pq: Name cve-2019-13509-02-TestMaskSecretKeys-use-subtests.patch --- diff --git a/engine/api/server/middleware/debug_test.go b/engine/api/server/middleware/debug_test.go index 3d78d7e0..e19a0ced 100644 --- a/engine/api/server/middleware/debug_test.go +++ b/engine/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)) + }) } }