From 7674f2f76b07058aa3bbf44675b7c2482c61811a Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Sat, 11 Sep 2021 22:20:26 +0200 Subject: Simplify the interface of parseSingleAuthHeader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't create a single-element map only for the only caller to laboriously extract an element of that map; just return a single entry. Should not change behavior. Signed-off-by: Miloslav Trmač --- pkg/auth/auth_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'pkg/auth/auth_test.go') diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index 634215acf..0e6bd42ef 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -302,24 +302,22 @@ func TestParseSingleAuthHeader(t *testing.T) { for _, tc := range []struct { input string shouldErr bool - expected map[string]types.DockerAuthConfig + expected types.DockerAuthConfig }{ { input: "", // An empty (or missing) header - expected: map[string]types.DockerAuthConfig{"0": {}}, + expected: types.DockerAuthConfig{}, }, { input: "null", - expected: map[string]types.DockerAuthConfig{"0": {}}, + expected: types.DockerAuthConfig{}, }, // Invalid JSON {input: "@", shouldErr: true}, // Success { - input: base64.URLEncoding.EncodeToString([]byte(`{"username":"u1","password":"p1"}`)), - expected: map[string]types.DockerAuthConfig{ - "0": {Username: "u1", Password: "p1"}, - }, + input: base64.URLEncoding.EncodeToString([]byte(`{"username":"u1","password":"p1"}`)), + expected: types.DockerAuthConfig{Username: "u1", Password: "p1"}, }, } { req, err := http.NewRequest(http.MethodPost, "/", nil) -- cgit v1.2.3-54-g00ecf