Skip to content

Commit f348924

Browse files
author
eolson
committed
clean up field assignments with default values to make test configuration more concise/readable
1 parent c1b8a47 commit f348924

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

middleware/basic_auth_test.go

+6-13
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func TestBasicAuth(t *testing.T) {
2525
return false, nil
2626
}
2727

28-
// Define the test cases
2928
tests := []struct {
3029
name string
3130
authHeader string
@@ -36,46 +35,40 @@ func TestBasicAuth(t *testing.T) {
3635
expectedErrMsg string
3736
}{
3837
{
39-
name: "Valid credentials",
40-
authHeader: basic + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")),
41-
expectedCode: http.StatusOK,
42-
skipperResult: false,
38+
name: "Valid credentials",
39+
authHeader: basic + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")),
40+
expectedCode: http.StatusOK,
4341
},
4442
{
45-
name: "Case-insensitive header scheme",
46-
authHeader: strings.ToUpper(basic) + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")),
47-
expectedCode: http.StatusOK,
48-
skipperResult: false,
43+
name: "Case-insensitive header scheme",
44+
authHeader: strings.ToUpper(basic) + " " + base64.StdEncoding.EncodeToString([]byte("joe:secret")),
45+
expectedCode: http.StatusOK,
4946
},
5047
{
5148
name: "Invalid credentials",
5249
authHeader: basic + " " + base64.StdEncoding.EncodeToString([]byte("joe:invalid-password")),
5350
expectedCode: http.StatusUnauthorized,
5451
expectedAuth: basic + ` realm="someRealm"`,
55-
skipperResult: false,
5652
expectedErr: true,
5753
expectedErrMsg: "Unauthorized",
5854
},
5955
{
6056
name: "Invalid base64 string",
6157
authHeader: basic + " invalidString",
6258
expectedCode: http.StatusBadRequest,
63-
skipperResult: false,
6459
expectedErr: true,
6560
expectedErrMsg: "Bad Request",
6661
},
6762
{
6863
name: "Missing Authorization header",
6964
expectedCode: http.StatusUnauthorized,
70-
skipperResult: false,
7165
expectedErr: true,
7266
expectedErrMsg: "Unauthorized",
7367
},
7468
{
7569
name: "Invalid Authorization header",
7670
authHeader: base64.StdEncoding.EncodeToString([]byte("invalid")),
7771
expectedCode: http.StatusUnauthorized,
78-
skipperResult: false,
7972
expectedErr: true,
8073
expectedErrMsg: "Unauthorized",
8174
},

0 commit comments

Comments
 (0)