@@ -1197,18 +1197,20 @@ func TestUserInfoEndpointUnauthorizedOnNoCookieSetError(t *testing.T) {
1197 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1197 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1200−func NewAuthOnlyEndpointTest(modifiers ...OptionsModifier) (*ProcessCookieTest, error) {
1200+func NewAuthOnlyEndpointTest(querystring string, modifiers ...OptionsModifier) (*ProcessCookieTest, error) {
1201 pcTest, err := NewProcessCookieTestWithOptionsModifiers(modifiers...)
1201 pcTest, err := NewProcessCookieTestWithOptionsModifiers(modifiers...)
1202 if err != nil {
1202 if err != nil {
1203 return nil, err
1203 return nil, err
1205− pcTest.req, _ = http.NewRequest("GET",
1205+ pcTest.req, _ = http.NewRequest(
1206− pcTest.opts.ProxyPrefix+"/auth", nil)
1207+ fmt.Sprintf("%s/auth%s", pcTest.opts.ProxyPrefix, querystring),
1207 return pcTest, nil
1209 return pcTest, nil
1210func TestAuthOnlyEndpointAccepted(t *testing.T) {
1212func TestAuthOnlyEndpointAccepted(t *testing.T) {
1211− test, err := NewAuthOnlyEndpointTest()
1213+ test, err := NewAuthOnlyEndpointTest("")
1212 if err != nil {
1214 if err != nil {
1213 t.Fatal(err)
1215 t.Fatal(err)
@@ -1226,7 +1228,7 @@ func TestAuthOnlyEndpointAccepted(t *testing.T) {
1228func TestAuthOnlyEndpointUnauthorizedOnNoCookieSetError(t *testing.T) {
1230func TestAuthOnlyEndpointUnauthorizedOnNoCookieSetError(t *testing.T) {
1229− test, err := NewAuthOnlyEndpointTest()
1231+ test, err := NewAuthOnlyEndpointTest("")
1230 if err != nil {
1232 if err != nil {
1231 t.Fatal(err)
1233 t.Fatal(err)
@@ -1238,7 +1240,7 @@ func TestAuthOnlyEndpointUnauthorizedOnNoCookieSetError(t *testing.T) {
1240func TestAuthOnlyEndpointUnauthorizedOnExpiration(t *testing.T) {
1242func TestAuthOnlyEndpointUnauthorizedOnExpiration(t *testing.T) {
1241− test, err := NewAuthOnlyEndpointTest(func(opts *options.Options) {
1243+ test, err := NewAuthOnlyEndpointTest("", func(opts *options.Options) {
1242 opts.Cookie.Expire = time.Duration(24) * time.Hour
1244 opts.Cookie.Expire = time.Duration(24) * time.Hour
1244 if err != nil {
1246 if err != nil {
@@ -1258,7 +1260,7 @@ func TestAuthOnlyEndpointUnauthorizedOnExpiration(t *testing.T) {
1260func TestAuthOnlyEndpointUnauthorizedOnEmailValidationFailure(t *testing.T) {
1262func TestAuthOnlyEndpointUnauthorizedOnEmailValidationFailure(t *testing.T) {
1261− test, err := NewAuthOnlyEndpointTest()
1263+ test, err := NewAuthOnlyEndpointTest("")
1262 if err != nil {
1264 if err != nil {
1263 t.Fatal(err)
1265 t.Fatal(err)
@@ -1960,7 +1962,7 @@ func TestGetJwtSession(t *testing.T) {
1960 verifier := oidc.NewVerifier("https://issuer.example.com", keyset,
1962 verifier := oidc.NewVerifier("https://issuer.example.com", keyset,
1961 &oidc.Config{ClientID: "https://test.myapp.com", SkipExpiryCheck: true})
1963 &oidc.Config{ClientID: "https://test.myapp.com", SkipExpiryCheck: true})
1963− test, err := NewAuthOnlyEndpointTest(func(opts *options.Options) {
1965+ test, err := NewAuthOnlyEndpointTest("", func(opts *options.Options) {
1964 opts.InjectRequestHeaders = []options.Header{
1966 opts.InjectRequestHeaders = []options.Header{
1966 Name: "Authorization",
1968 Name: "Authorization",
@@ -2028,7 +2030,6 @@ func TestGetJwtSession(t *testing.T) {
2032 opts.SkipJwtBearerTokens = true
2033 opts.SkipJwtBearerTokens = true
2033 opts.SetJWTBearerVerifiers(append(opts.GetJWTBearerVerifiers(), verifier))
2034 opts.SetJWTBearerVerifiers(append(opts.GetJWTBearerVerifiers(), verifier))
@@ -2692,32 +2693,106 @@ func TestProxyAllowedGroups(t *testing.T) {
2694func TestAuthOnlyAllowedGroups(t *testing.T) {
2695func TestAuthOnlyAllowedGroups(t *testing.T) {
2695− tests := []struct {
2696+ testCases := []struct {
2696 name string
2697 name string
2697 allowedGroups []string
2698 allowedGroups []string
2698 groups []string
2699 groups []string
2699 expectUnauthorized bool
2701 expectUnauthorized bool
2701− {"NoAllowedGroups", []string{}, []string{}, false},
2704+ name: "NoAllowedGroups",
2705+ allowedGroups: []string{},
2706+ groups: []string{},
2708+ expectUnauthorized: false,
2702− {"NoAllowedGroupsUserHasGroups", []string{}, []string{"a", "b"}, false},
2711+ name: "NoAllowedGroupsUserHasGroups",
2712+ allowedGroups: []string{},
2713+ groups: []string{"a", "b"},
2715+ expectUnauthorized: false,
2703− {"UserInAllowedGroup", []string{"a"}, []string{"a", "b"}, false},
2718+ name: "UserInAllowedGroup",
2719+ allowedGroups: []string{"a"},
2720+ groups: []string{"a", "b"},
2722+ expectUnauthorized: false,
2704− {"UserNotInAllowedGroup", []string{"a"}, []string{"c"}, true},
2725+ name: "UserNotInAllowedGroup",
2726+ allowedGroups: []string{"a"},
2727+ groups: []string{"c"},
2729+ expectUnauthorized: true,
2732+ name: "UserInQuerystringGroup",
2733+ allowedGroups: []string{"a", "b"},
2734+ groups: []string{"a", "c"},
2735+ querystring: "?allowed_group=a",
2736+ expectUnauthorized: false,
2739+ name: "UserInOnlyQuerystringGroup",
2740+ allowedGroups: []string{},
2741+ groups: []string{"a", "c"},
2742+ querystring: "?allowed_groups=a,b",
2743+ expectUnauthorized: false,
2746+ name: "UserInMultiParamQuerystringGroup",
2747+ allowedGroups: []string{"a", "b"},
2748+ groups: []string{"b"},
2749+ querystring: "?allowed_group=a&allowed_group=b",
2750+ expectUnauthorized: false,
2753+ name: "UserInDelimitedQuerystringGroup",
2754+ allowedGroups: []string{"a", "b", "c"},
2755+ groups: []string{"c"},
2756+ querystring: "?allowed_groups=a,c",
2757+ expectUnauthorized: false,
2760+ name: "UserNotInQuerystringGroup",
2761+ allowedGroups: []string{},
2762+ groups: []string{"c"},
2763+ querystring: "?allowed_group=a&allowed_group=b",
2764+ expectUnauthorized: true,
2767+ name: "UserInConfigGroupNotInQuerystringGroup",
2768+ allowedGroups: []string{"a", "b", "c"},
2769+ groups: []string{"c"},
2770+ querystring: "?allowed_group=a&allowed_group=b",
2771+ expectUnauthorized: true,
2774+ name: "UserInQuerystringGroupNotInConfigGroup",
2775+ allowedGroups: []string{"a", "b"},
2776+ groups: []string{"c"},
2777+ querystring: "?allowed_groups=b,c",
2778+ expectUnauthorized: true,
2707− for _, tt := range tests {
2782+ for _, tc := range testCases {
2708− t.Run(tt.name, func(t *testing.T) {
2783+ t.Run(tc.name, func(t *testing.T) {
2709 emailAddress := "test"
2784 emailAddress := "test"
2710 created := time.Now()
2785 created := time.Now()
2712 session := &sessions.SessionState{
2787 session := &sessions.SessionState{
2713− Groups: tt.groups,
2788+ Groups: tc.groups,
2714 Email: emailAddress,
2789 Email: emailAddress,
2715 AccessToken: "oauth_token",
2790 AccessToken: "oauth_token",
2716 CreatedAt: &created,
2791 CreatedAt: &created,
2719− test, err := NewAuthOnlyEndpointTest(func(opts *options.Options) {
2794+ test, err := NewAuthOnlyEndpointTest(tc.querystring, func(opts *options.Options) {
2720− opts.AllowedGroups = tt.allowedGroups
2795+ opts.AllowedGroups = tc.allowedGroups
2722 if err != nil {
2797 if err != nil {
2723 t.Fatal(err)
2798 t.Fatal(err)
@@ -2728,7 +2803,7 @@ func TestAuthOnlyAllowedGroups(t *testing.T) {
2729 test.proxy.ServeHTTP(test.rw, test.req)
2804 test.proxy.ServeHTTP(test.rw, test.req)
2731− if tt.expectUnauthorized {
2806+ if tc.expectUnauthorized {
2732 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
2807 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
2733 } else {
2808 } else {
2734 assert.Equal(t, http.StatusAccepted, test.rw.Code)
2809 assert.Equal(t, http.StatusAccepted, test.rw.Code)