File: cve-2019-13509-02-TestMaskSecretKeys-use-subtests.patch

package info (click to toggle)
docker.io 18.09.1%2Bdfsg1-7.1%2Bdeb10u3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 66,144 kB
  • sloc: sh: 9,753; makefile: 827; ansic: 239; python: 162; asm: 10
file content (70 lines) | stat: -rw-r--r-- 2,750 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From: Sebastiaan van Stijn <github@gone.nl>
Date: Tue, 2 Jul 2019 13:29:24 +0200
Subject: [PATCH] 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>
(cherry picked from commit ebb542b3f88d7f5551f6b6e1d8d2774a2c166409)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Origin: https://github.com/docker/engine/pull/298
---
 api/server/middleware/debug_test.go | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/engine/api/server/middleware/debug_test.go b/engine/api/server/middleware/debug_test.go
index 3d78d7e08450..e19a0ced2fbd 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))
+		})
 	}
 }