From 5a0b4dd8063575995cbcb746a0fb31266a0de3db Mon Sep 17 00:00:00 2001 From: eolson Date: Wed, 16 Oct 2024 17:45:35 -0700 Subject: [PATCH] clean up field assignments with default values to make test configuration more concise/readable --- middleware/basic_auth_test.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/middleware/basic_auth_test.go b/middleware/basic_auth_test.go index 788c339e8..b3abfa172 100644 --- a/middleware/basic_auth_test.go +++ b/middleware/basic_auth_test.go @@ -25,7 +25,6 @@ func TestBasicAuth(t *testing.T) { return false, nil } - // Define the test cases tests := []struct { name string authHeader string @@ -36,23 +35,20 @@ func TestBasicAuth(t *testing.T) { expectedErrMsg string }{ { - name: "Valid credentials", - authHeader: basic + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")), - expectedCode: http.StatusOK, - skipperResult: false, + name: "Valid credentials", + authHeader: basic + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")), + expectedCode: http.StatusOK, }, { - name: "Case-insensitive header scheme", - authHeader: strings.ToUpper(basic) + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")), - expectedCode: http.StatusOK, - skipperResult: false, + name: "Case-insensitive header scheme", + authHeader: strings.ToUpper(basic) + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")), + expectedCode: http.StatusOK, }, { name: "Invalid credentials", authHeader: basic + " " + base64.StdEncoding.EncodeToString([]byte("joe:invalid-password")), expectedCode: http.StatusUnauthorized, expectedAuth: basic + ` realm="someRealm"`, - skipperResult: false, expectedErr: true, expectedErrMsg: "Unauthorized", }, @@ -60,14 +56,12 @@ func TestBasicAuth(t *testing.T) { name: "Invalid base64 string", authHeader: basic + " invalidString", expectedCode: http.StatusBadRequest, - skipperResult: false, expectedErr: true, expectedErrMsg: "Bad Request", }, { name: "Missing Authorization header", expectedCode: http.StatusUnauthorized, - skipperResult: false, expectedErr: true, expectedErrMsg: "Unauthorized", }, @@ -75,7 +69,6 @@ func TestBasicAuth(t *testing.T) { name: "Invalid Authorization header", authHeader: base64.StdEncoding.EncodeToString([]byte("invalid")), expectedCode: http.StatusUnauthorized, - skipperResult: false, expectedErr: true, expectedErrMsg: "Unauthorized", },