@@ -54,7 +54,7 @@ func TestRobotsTxt(t *testing.T) {
5454 t.Fatal(err)
5555 }
5656 rw := httptest.NewRecorder()
57− req, _ := http.NewRequest(http.MethodGet, "/robots.txt", nil)
57+ req, _ := http.NewRequest("GET", "/robots.txt", nil)
5858 proxy.ServeHTTP(rw, req)
5959 assert.Equal(t, 200, rw.Code)
6060 assert.Equal(t, "User-agent: *\nDisallow: /\n", rw.Body.String())
@@ -241,7 +241,7 @@ func TestBasicAuthPassword(t *testing.T) {
241241
242242 // Save the required session
243243 rw := httptest.NewRecorder()
244− req, _ := http.NewRequest(http.MethodGet, "/", nil)
244+ req, _ := http.NewRequest("GET", "/", nil)
245245 err = proxy.sessionStore.Save(rw, req, &sessions.SessionState{
246246 Email: emailAddress,
247247 })
@@ -250,7 +250,7 @@ func TestBasicAuthPassword(t *testing.T) {
250250 // Extract the cookie value to inject into the test request
251251 cookie := rw.Header().Values("Set-Cookie")[0]
252252
253− req, _ = http.NewRequest(http.MethodGet, "/", nil)
253+ req, _ = http.NewRequest("GET", "/", nil)
254254 req.Header.Set("Cookie", cookie)
255255 rw = httptest.NewRecorder()
256256 proxy.ServeHTTP(rw, req)
@@ -300,14 +300,14 @@ func TestPassGroupsHeadersWithGroups(t *testing.T) {
300300
301301 // Save the required session
302302 rw := httptest.NewRecorder()
303− req, _ := http.NewRequest(http.MethodGet, "/", nil)
303+ req, _ := http.NewRequest("GET", "/", nil)
304304 err = proxy.sessionStore.Save(rw, req, session)
305305 assert.NoError(t, err)
306306
307307 // Extract the cookie value to inject into the test request
308308 cookie := rw.Header().Values("Set-Cookie")[0]
309309
310− req, _ = http.NewRequest(http.MethodGet, "/", nil)
310+ req, _ = http.NewRequest("GET", "/", nil)
311311 req.Header.Set("Cookie", cookie)
312312 rw = httptest.NewRecorder()
313313 proxy.ServeHTTP(rw, req)
@@ -457,7 +457,7 @@ func (patTest *PassAccessTokenTest) getEndpointWithCookie(cookie string, endpoin
457457 return 0, ""
458458 }
459459
460− req, err := http.NewRequest(http.MethodGet, endpoint, strings.NewReader(""))
460+ req, err := http.NewRequest("GET", endpoint, strings.NewReader(""))
461461 if err != nil {
462462 return 0, ""
463463 }
@@ -608,7 +608,7 @@ func NewSignInPageTest(skipProvider bool) (*SignInPageTest, error) {
608608
609609func (sipTest *SignInPageTest) GetEndpoint(endpoint string) (int, string) {
610610 rw := httptest.NewRecorder()
611− req, _ := http.NewRequest(http.MethodGet, endpoint, strings.NewReader(""))
611+ req, _ := http.NewRequest("GET", endpoint, strings.NewReader(""))
612612 sipTest.proxy.ServeHTTP(rw, req)
613613 return rw.Code, rw.Body.String()
614614}
@@ -713,50 +713,6 @@ func TestManualSignInCorrectCredentials(t *testing.T) {
713713 assert.Equal(t, http.StatusFound, statusCode)
714714}
715715
716−func TestSignInPageClearsExistingSessionCookie(t *testing.T) {
717− opts := baseTestOptions()
718− err := validation.Validate(opts)
719− require.NoError(t, err)
720−
721− proxy, err := NewOAuthProxy(opts, func(string) bool {
722− return true
723− })
724− require.NoError(t, err)
725−
726− // Create a real session cookie using the actual session store.
727− saveRW := httptest.NewRecorder()
728− saveReq := httptest.NewRequest(http.MethodGet, "/", nil)
729− err = proxy.sessionStore.Save(saveRW, saveReq, &sessions.SessionState{
730− Email: "john.doe@example.com",
731− })
732− require.NoError(t, err)
733−
734− cookies := saveRW.Result().Cookies()
735− require.NotEmpty(t, cookies)
736−
737− // Send that cookie to the sign-in page.
738− req := httptest.NewRequest(http.MethodGet, "/oauth2/sign_in", nil)
739− for _, c := range cookies {
740− req.AddCookie(c)
741− }
742−
743− rw := httptest.NewRecorder()
744− proxy.ServeHTTP(rw, req)
745−
746− assert.Equal(t, http.StatusOK, rw.Code)
747−
748− cleared := false
749− for _, c := range rw.Result().Cookies() {
750− if c.Name == proxy.CookieOptions.Name {
751− cleared = true
752− assert.Equal(t, "", c.Value)
753− assert.Less(t, c.MaxAge, 0)
754− }
755− }
756−
757− assert.True(t, cleared, "expected sign-in page to clear existing session cookie")
758−}
759−
760716func TestSignInPageIncludesTargetRedirect(t *testing.T) {
761717 sipTest, err := NewSignInPageTest(false)
762718 if err != nil {
@@ -894,7 +850,7 @@ func NewProcessCookieTest(opts ProcessCookieTestOpts, modifiers ...OptionsModifi
894850 // access_token validation.
895851 pcTest.proxy.CookieOptions.Refresh = time.Duration(0)
896852 pcTest.rw = httptest.NewRecorder()
897− pcTest.req, _ = http.NewRequest(http.MethodGet, "/", strings.NewReader(""))
853+ pcTest.req, _ = http.NewRequest("GET", "/", strings.NewReader(""))
898854 pcTest.validateUser = true
899855 return &pcTest, nil
900856}
@@ -1027,7 +983,7 @@ func NewUserInfoEndpointTest() (*ProcessCookieTest, error) {
1027983 if err != nil {
1028984 return nil, err
1029985 }
1030− pcTest.req, _ = http.NewRequest(http.MethodGet,
986+ pcTest.req, _ = http.NewRequest("GET",
1031987 pcTest.opts.ProxyPrefix+"/userinfo", nil)
1032988 return pcTest, nil
1033989}
@@ -1135,7 +1091,7 @@ func NewAuthOnlyEndpointTest(querystring string, modifiers ...OptionsModifier) (
11351091 return nil, err
11361092 }
11371093 pcTest.req, _ = http.NewRequest(
1138− http.MethodGet,
1094+ "GET",
11391095 fmt.Sprintf("%s/auth%s", pcTest.opts.ProxyPrefix, querystring),
11401096 nil)
11411097 return pcTest, nil
@@ -1274,7 +1230,7 @@ func TestAuthOnlyEndpointSetXAuthRequestHeaders(t *testing.T) {
12741230 pcTest.validateUser = true
12751231
12761232 pcTest.rw = httptest.NewRecorder()
1277− pcTest.req, _ = http.NewRequest(http.MethodGet,
1233+ pcTest.req, _ = http.NewRequest("GET",
12781234 pcTest.opts.ProxyPrefix+authOnlyPath, nil)
12791235
12801236 created := time.Now()
@@ -1367,7 +1323,7 @@ func TestAuthOnlyEndpointSetBasicAuthTrueRequestHeaders(t *testing.T) {
13671323 pcTest.validateUser = true
13681324
13691325 pcTest.rw = httptest.NewRecorder()
1370− pcTest.req, _ = http.NewRequest(http.MethodGet,
1326+ pcTest.req, _ = http.NewRequest("GET",
13711327 pcTest.opts.ProxyPrefix+authOnlyPath, nil)
13721328
13731329 created := time.Now()
@@ -1447,7 +1403,7 @@ func TestAuthOnlyEndpointSetBasicAuthFalseRequestHeaders(t *testing.T) {
14471403 pcTest.validateUser = true
14481404
14491405 pcTest.rw = httptest.NewRecorder()
1450− pcTest.req, _ = http.NewRequest(http.MethodGet,
1406+ pcTest.req, _ = http.NewRequest("GET",
14511407 pcTest.opts.ProxyPrefix+authOnlyPath, nil)
14521408
14531409 created := time.Now()
@@ -1495,7 +1451,7 @@ func TestAuthSkippedForPreflightRequests(t *testing.T) {
14951451 }
14961452 proxy.provider = NewTestProvider(upstreamURL, "")
14971453 rw := httptest.NewRecorder()
1498− req, _ := http.NewRequest(http.MethodOptions, "/preflight-request", nil)
1454+ req, _ := http.NewRequest("OPTIONS", "/preflight-request", nil)
14991455 proxy.ServeHTTP(rw, req)
15001456
15011457 assert.Equal(t, 200, rw.Code)
@@ -1652,19 +1608,19 @@ func TestRequestSignature(t *testing.T) {
16521608 resp string
16531609 }{
16541610 "No request signature": {
1655− method: http.MethodGet,
1611+ method: "GET",
16561612 body: "",
16571613 key: "",
16581614 resp: "no signature received",
16591615 },
16601616 "Get request": {
1661− method: http.MethodGet,
1617+ method: "GET",
16621618 body: "",
16631619 key: "7d9e1aa87a5954e6f9fc59266b3af9d7c35fda2d",
16641620 resp: "signatures match",
16651621 },
16661622 "Post request": {
1667− method: http.MethodPost,
1623+ method: "POST",
16681624 body: `{ "hello": "world!" }`,
16691625 key: "d90df39e2d19282840252612dd7c81421a372f61",
16701626 resp: "signatures match",
@@ -2189,7 +2145,7 @@ func TestTrustedIPs(t *testing.T) {
21892145 reverseProxy: false,
21902146 realClientIPHeader: "X-Real-IP", // Default value
21912147 req: func() *http.Request {
2192− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2148+ req, _ := http.NewRequest("GET", "/", nil)
21932149 return req
21942150 }(),
21952151 expectTrusted: false,
@@ -2201,7 +2157,7 @@ func TestTrustedIPs(t *testing.T) {
22012157 reverseProxy: false,
22022158 realClientIPHeader: "X-Real-IP",
22032159 req: func() *http.Request {
2204− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2160+ req, _ := http.NewRequest("GET", "/", nil)
22052161 req.RemoteAddr = "@"
22062162 return req
22072163 }(),
@@ -2214,7 +2170,7 @@ func TestTrustedIPs(t *testing.T) {
22142170 reverseProxy: false,
22152171 realClientIPHeader: "X-Real-IP",
22162172 req: func() *http.Request {
2217− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2173+ req, _ := http.NewRequest("GET", "/", nil)
22182174 req.RemoteAddr = "@"
22192175 return req
22202176 }(),
@@ -2227,7 +2183,7 @@ func TestTrustedIPs(t *testing.T) {
22272183 reverseProxy: false,
22282184 realClientIPHeader: "X-Real-IP", // Default value
22292185 req: func() *http.Request {
2230− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2186+ req, _ := http.NewRequest("GET", "/", nil)
22312187 req.RemoteAddr = "127.0.0.1:43670"
22322188 return req
22332189 }(),
@@ -2240,7 +2196,7 @@ func TestTrustedIPs(t *testing.T) {
22402196 reverseProxy: true,
22412197 realClientIPHeader: "X-Real-IP", // Default value
22422198 req: func() *http.Request {
2243− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2199+ req, _ := http.NewRequest("GET", "/", nil)
22442200 req.RemoteAddr = "127.0.0.1:44324"
22452201 return req
22462202 }(),
@@ -2253,7 +2209,7 @@ func TestTrustedIPs(t *testing.T) {
22532209 reverseProxy: true,
22542210 realClientIPHeader: "X-Forwarded-For",
22552211 req: func() *http.Request {
2256− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2212+ req, _ := http.NewRequest("GET", "/", nil)
22572213 req.Header.Add("X-Forwarded-For", "127.0.0.1")
22582214 return req
22592215 }(),
@@ -2266,7 +2222,7 @@ func TestTrustedIPs(t *testing.T) {
22662222 reverseProxy: true,
22672223 realClientIPHeader: "X-Forwarded-For",
22682224 req: func() *http.Request {
2269− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2225+ req, _ := http.NewRequest("GET", "/", nil)
22702226 req.Header.Add("X-Forwarded-For", "::1")
22712227 return req
22722228 }(),
@@ -2279,7 +2235,7 @@ func TestTrustedIPs(t *testing.T) {
22792235 reverseProxy: true,
22802236 realClientIPHeader: "X-Forwarded-For",
22812237 req: func() *http.Request {
2282− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2238+ req, _ := http.NewRequest("GET", "/", nil)
22832239 req.Header.Add("X-Forwarded-For", "12.34.56.78")
22842240 return req
22852241 }(),
@@ -2292,7 +2248,7 @@ func TestTrustedIPs(t *testing.T) {
22922248 reverseProxy: true,
22932249 realClientIPHeader: "X-Forwarded-For",
22942250 req: func() *http.Request {
2295− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2251+ req, _ := http.NewRequest("GET", "/", nil)
22962252 req.Header.Add("X-Forwarded-For", "::2")
22972253 return req
22982254 }(),
@@ -2305,7 +2261,7 @@ func TestTrustedIPs(t *testing.T) {
23052261 reverseProxy: true,
23062262 realClientIPHeader: "X-Forwarded-For",
23072263 req: func() *http.Request {
2308− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2264+ req, _ := http.NewRequest("GET", "/", nil)
23092265 req.Header.Add("X-Real-IP", "::1")
23102266 return req
23112267 }(),
@@ -2318,7 +2274,7 @@ func TestTrustedIPs(t *testing.T) {
23182274 reverseProxy: true,
23192275 realClientIPHeader: "X-Forwarded-For",
23202276 req: func() *http.Request {
2321− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2277+ req, _ := http.NewRequest("GET", "/", nil)
23222278 req.Header.Add("X-Forwarded-For", "adsfljk29242as!!")
23232279 return req
23242280 }(),
@@ -2331,7 +2287,7 @@ func TestTrustedIPs(t *testing.T) {
23312287 reverseProxy: false,
23322288 realClientIPHeader: "X-Real-IP",
23332289 req: func() *http.Request {
2334− req, _ := http.NewRequest(http.MethodGet, "/", nil)
2290+ req, _ := http.NewRequest("GET", "/", nil)
23352291 req.RemoteAddr = "adsfljk29242as!!"
23362292 return req
23372293 }(),
@@ -2427,12 +2383,12 @@ func Test_buildRoutesAllowlist(t *testing.T) {
24272383 },
24282384 expectedRoutes: []expectedAllowedRoute{
24292385 {
2430− method: http.MethodGet,
2386+ method: "GET",
24312387 negate: false,
24322388 regexString: "^/foo/bar",
24332389 },
24342390 {
2435− method: http.MethodPost,
2391+ method: "POST",
24362392 negate: false,
24372393 regexString: "^/baz/[0-9]+/thing",
24382394 },
@@ -2485,11 +2441,11 @@ func Test_buildRoutesAllowlist(t *testing.T) {
24852441 regexString: "^/baz/[0-9]+/thing/regex",
24862442 },
24872443 {
2488− method: http.MethodGet,
2444+ method: "GET",
24892445 regexString: "^/foo/bar",
24902446 },
24912447 {
2492− method: http.MethodPost,
2448+ method: "POST",
24932449 regexString: "^/baz/[0-9]+/thing",
24942450 },
24952451 {
@@ -2641,7 +2597,7 @@ func TestApiRoutes(t *testing.T) {
26412597
26422598 for _, tc := range testCases {
26432599 t.Run(tc.name, func(t *testing.T) {
2644− req, err := http.NewRequest(http.MethodGet, tc.url, nil)
2600+ req, err := http.NewRequest("GET", tc.url, nil)
26452601 req.Header.Set("Accept", tc.contentType)
26462602 assert.NoError(t, err)
26472603
@@ -2679,11 +2635,9 @@ func TestAllowedRequest(t *testing.T) {
26792635 }
26802636 opts.SkipAuthRegex = []string{
26812637 "^/skip/auth/regex$",
2682− "^/public/.*/endpoint$",
26832638 }
26842639 opts.SkipAuthRoutes = []string{
26852640 "GET=^/skip/auth/routes/get",
2686− "^/foo/.*/bar$",
26872641 }
26882642 err := validation.Validate(opts)
26892643 assert.NoError(t, err)
@@ -2700,37 +2654,25 @@ func TestAllowedRequest(t *testing.T) {
27002654 }{
27012655 {
27022656 name: "Regex GET allowed",
2703− method: http.MethodGet,
2657+ method: "GET",
27042658 url: "/skip/auth/regex",
27052659 allowed: true,
27062660 },
27072661 {
27082662 name: "Regex POST allowed ",
2709− method: http.MethodPost,
2663+ method: "POST",
27102664 url: "/skip/auth/regex",
27112665 allowed: true,
27122666 },
27132667 {
27142668 name: "Regex denied",
2715− method: http.MethodGet,
2669+ method: "GET",
27162670 url: "/wrong/denied",
27172671 allowed: false,
27182672 },
2719− {
2720− name: "Regex allowed with fragment-free path",
2721− method: http.MethodGet,
2722− url: "/public/legit/endpoint",
2723− allowed: true,
2724− },
2725− {
2726− name: "Regex denied when path contains encoded fragment suffix",
2727− method: http.MethodGet,
2728− url: "/public/secret%23/endpoint",
2729− allowed: false,
2730− },
27312673 {
27322674 name: "Route allowed",
2733− method: http.MethodGet,
2675+ method: "GET",
27342676 url: "/skip/auth/routes/get",
27352677 allowed: true,
27362678 },
@@ -2742,28 +2684,16 @@ func TestAllowedRequest(t *testing.T) {
27422684 },
27432685 {
27442686 name: "Route denied with wrong path",
2745− method: http.MethodGet,
2687+ method: "GET",
27462688 url: "/skip/auth/routes/wrong/path",
27472689 allowed: false,
27482690 },
27492691 {
27502692 name: "Route denied with wrong path and method",
2751− method: http.MethodPost,
2693+ method: "POST",
27522694 url: "/skip/auth/routes/wrong/path",
27532695 allowed: false,
27542696 },
2755− {
2756− name: "Route allowed with fragment-free path",
2757− method: http.MethodGet,
2758− url: "/foo/public/bar",
2759− allowed: true,
2760− },
2761− {
2762− name: "Route denied when path contains encoded fragment suffix",
2763− method: http.MethodGet,
2764− url: "/foo/secret%23/bar",
2765− allowed: false,
2766− },
27672697 }
27682698
27692699 for _, tc := range testCases {
@@ -2804,11 +2734,9 @@ func TestAllowedRequestWithForwardedUriHeader(t *testing.T) {
28042734 }
28052735 opts.SkipAuthRegex = []string{
28062736 "^/skip/auth/regex$",
2807− "^/public/.*/endpoint$",
28082737 }
28092738 opts.SkipAuthRoutes = []string{
28102739 "GET=^/skip/auth/routes/get",
2811− "^/foo/.*/bar$",
28122740 }
28132741 err := validation.Validate(opts)
28142742 assert.NoError(t, err)
@@ -2825,37 +2753,25 @@ func TestAllowedRequestWithForwardedUriHeader(t *testing.T) {
28252753 }{
28262754 {
28272755 name: "Regex GET allowed",
2828− method: http.MethodGet,
2756+ method: "GET",
28292757 url: "/skip/auth/regex",
28302758 allowed: true,
28312759 },
28322760 {
28332761 name: "Regex POST allowed ",
2834− method: http.MethodPost,
2762+ method: "POST",
28352763 url: "/skip/auth/regex",
28362764 allowed: true,
28372765 },
28382766 {
28392767 name: "Regex denied",
2840− method: http.MethodGet,
2768+ method: "GET",
28412769 url: "/wrong/denied",
28422770 allowed: false,
28432771 },
2844− {
2845− name: "Regex allowed with fragment-free path",
2846− method: http.MethodGet,
2847− url: "/public/legit/endpoint",
2848− allowed: true,
2849− },
2850− {
2851− name: "Regex denied when X-Forwarded-Uri contains an encoded fragment suffix",
2852− method: http.MethodGet,
2853− url: "/public/secret%23/endpoint",
2854− allowed: false,
2855− },
28562772 {
28572773 name: "Route allowed",
2858− method: http.MethodGet,
2774+ method: "GET",
28592775 url: "/skip/auth/routes/get",
28602776 allowed: true,
28612777 },
@@ -2867,35 +2783,22 @@ func TestAllowedRequestWithForwardedUriHeader(t *testing.T) {
28672783 },
28682784 {
28692785 name: "Route denied with wrong path",
2870− method: http.MethodGet,
2786+ method: "GET",
28712787 url: "/skip/auth/routes/wrong/path",
28722788 allowed: false,
28732789 },
28742790 {
28752791 name: "Route denied with wrong path and method",
2876− method: http.MethodPost,
2792+ method: "POST",
28772793 url: "/skip/auth/routes/wrong/path",
28782794 allowed: false,
28792795 },
2880− {
2881− name: "Route allowed with fragment-free path",
2882− method: http.MethodGet,
2883− url: "/foo/public/bar",
2884− allowed: true,
2885− },
2886− {
2887− name: "Route denied when X-Forwarded-Uri contains an encoded fragment suffix",
2888− method: http.MethodGet,
2889− url: "/foo/secret%23/bar",
2890− allowed: false,
2891− },
28922796 }
28932797
28942798 for _, tc := range testCases {
28952799 t.Run(tc.name, func(t *testing.T) {
28962800 req, err := http.NewRequest(tc.method, opts.ProxyPrefix+authOnlyPath, nil)
28972801 req.Header.Set("X-Forwarded-Uri", tc.url)
2898− req.RemoteAddr = "127.0.0.1:4180"
28992802 assert.NoError(t, err)
29002803
29012804 rw := httptest.NewRecorder()
@@ -2910,43 +2813,6 @@ func TestAllowedRequestWithForwardedUriHeader(t *testing.T) {
29102813 }
29112814}
29122815
2913−func TestAllowedRequestWithForwardedUriHeaderRequiresTrustedProxy(t *testing.T) {
2914− upstreamServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2915− w.WriteHeader(200)
2916− }))
2917− t.Cleanup(upstreamServer.Close)
2918−
2919− opts := baseTestOptions()
2920− opts.ReverseProxy = true
2921− opts.TrustedProxyIPs = []string{"127.0.0.1/32"}
2922− opts.UpstreamServers = options.UpstreamConfig{
2923− Upstreams: []options.Upstream{
2924− {
2925− ID: upstreamServer.URL,
2926− Path: "/",
2927− URI: upstreamServer.URL,
2928− },
2929− },
2930− }
2931− opts.SkipAuthRegex = []string{"^/skip/auth/regex$"}
2932−
2933− err := validation.Validate(opts)
2934− assert.NoError(t, err)
2935−
2936− proxy, err := NewOAuthProxy(opts, func(_ string) bool { return true })
2937− assert.NoError(t, err)
2938−
2939− req, err := http.NewRequest(http.MethodGet, opts.ProxyPrefix+authOnlyPath, nil)
2940− assert.NoError(t, err)
2941− req.RemoteAddr = "192.0.2.10:4180"
2942− req.Header.Set("X-Forwarded-Uri", "/skip/auth/regex")
2943−
2944− rw := httptest.NewRecorder()
2945− proxy.ServeHTTP(rw, req)
2946−
2947− assert.Equal(t, 401, rw.Code)
2948−}
2949−
29502816func TestAllowedRequestNegateWithoutMethod(t *testing.T) {
29512817 upstreamServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
29522818 w.WriteHeader(200)
@@ -2986,37 +2852,37 @@ func TestAllowedRequestNegateWithoutMethod(t *testing.T) {
29862852 }{
29872853 {
29882854 name: "Some static file allowed",
2989− method: http.MethodGet,
2855+ method: "GET",
29902856 url: "/static/file.txt",
29912857 allowed: true,
29922858 },
29932859 {
29942860 name: "POST to contact form allowed",
2995− method: http.MethodPost,
2861+ method: "POST",
29962862 url: "/contact",
29972863 allowed: true,
29982864 },
29992865 {
30002866 name: "Regex POST allowed",
3001− method: http.MethodPost,
2867+ method: "POST",
30022868 url: "/api/public-entity",
30032869 allowed: true,
30042870 },
30052871 {
30062872 name: "Regex POST with trailing slash allowed",
3007− method: http.MethodPost,
2873+ method: "POST",
30082874 url: "/api/public-entity/",
30092875 allowed: true,
30102876 },
30112877 {
30122878 name: "Regex GET api route denied",
3013− method: http.MethodGet,
2879+ method: "GET",
30142880 url: "/api/users",
30152881 allowed: false,
30162882 },
30172883 {
30182884 name: "Regex POST api route denied",
3019− method: http.MethodPost,
2885+ method: "POST",
30202886 url: "/api/users",
30212887 allowed: false,
30222888 },
@@ -3086,37 +2952,37 @@ func TestAllowedRequestNegateWithMethod(t *testing.T) {
30862952 }{
30872953 {
30882954 name: "Some static file allowed",
3089− method: http.MethodGet,
2955+ method: "GET",
30902956 url: "/static/file.txt",
30912957 allowed: true,
30922958 },
30932959 {
30942960 name: "POST to contact form not allowed",
3095− method: http.MethodPost,
2961+ method: "POST",
30962962 url: "/contact",
30972963 allowed: false,
30982964 },
30992965 {
31002966 name: "Regex POST allowed",
3101− method: http.MethodPost,
2967+ method: "POST",
31022968 url: "/api/public-entity",
31032969 allowed: true,
31042970 },
31052971 {
31062972 name: "Regex POST with trailing slash allowed",
3107− method: http.MethodPost,
2973+ method: "POST",
31082974 url: "/api/public-entity/",
31092975 allowed: true,
31102976 },
31112977 {
31122978 name: "Regex GET api route denied",
3113− method: http.MethodGet,
2979+ method: "GET",
31142980 url: "/api/users",
31152981 allowed: false,
31162982 },
31172983 {
31182984 name: "Regex POST api route denied",
3119− method: http.MethodPost,
2985+ method: "POST",
31202986 url: "/api/users",
31212987 allowed: false,
31222988 },
@@ -3256,7 +3122,7 @@ func TestProxyAllowedGroups(t *testing.T) {
32563122 t.Fatal(err)
32573123 }
32583124
3259− test.req, _ = http.NewRequest(http.MethodGet, fmt.Sprintf("/%s", tt.querystring), nil)
3125+ test.req, _ = http.NewRequest("GET", fmt.Sprintf("/%s", tt.querystring), nil)
32603126
32613127 test.req.Header.Add("accept", applicationJSON)
32623128 err = test.SaveSession(session)
@@ -3400,7 +3266,7 @@ func TestAuthOnlyAllowedGroupsWithSkipMethods(t *testing.T) {
34003266 {
34013267 name: "UserWithGroupSkipAuthPreflight",
34023268 groups: []string{"a", "c"},
3403− method: http.MethodOptions,
3269+ method: "OPTIONS",
34043270 ip: "1.2.3.5:43670",
34053271 withSession: true,
34063272 expectedStatusCode: http.StatusAccepted,
@@ -3408,7 +3274,7 @@ func TestAuthOnlyAllowedGroupsWithSkipMethods(t *testing.T) {
34083274 {
34093275 name: "UserWithGroupTrustedIp",
34103276 groups: []string{"a", "c"},
3411− method: http.MethodGet,
3277+ method: "GET",
34123278 ip: "1.2.3.4:43670",
34133279 withSession: true,
34143280 expectedStatusCode: http.StatusAccepted,
@@ -3416,7 +3282,7 @@ func TestAuthOnlyAllowedGroupsWithSkipMethods(t *testing.T) {
34163282 {
34173283 name: "UserWithoutGroupSkipAuthPreflight",
34183284 groups: []string{"c"},
3419− method: http.MethodOptions,
3285+ method: "OPTIONS",
34203286 ip: "1.2.3.5:43670",
34213287 withSession: true,
34223288 expectedStatusCode: http.StatusForbidden,
@@ -3424,21 +3290,21 @@ func TestAuthOnlyAllowedGroupsWithSkipMethods(t *testing.T) {
34243290 {
34253291 name: "UserWithoutGroupTrustedIp",
34263292 groups: []string{"c"},
3427− method: http.MethodGet,
3293+ method: "GET",
34283294 ip: "1.2.3.4:43670",
34293295 withSession: true,
34303296 expectedStatusCode: http.StatusForbidden,
34313297 },
34323298 {
34333299 name: "UserWithoutSessionSkipAuthPreflight",
3434− method: http.MethodOptions,
3300+ method: "OPTIONS",
34353301 ip: "1.2.3.5:43670",
34363302 withSession: false,
34373303 expectedStatusCode: http.StatusAccepted,
34383304 },
34393305 {
34403306 name: "UserWithoutSessionTrustedIp",
3441− method: http.MethodGet,
3307+ method: "GET",
34423308 ip: "1.2.3.4:43670",
34433309 withSession: false,
34443310 expectedStatusCode: http.StatusAccepted,
@@ -3538,24 +3404,6 @@ func TestAuthOnlyAllowedEmailDomains(t *testing.T) {
35383404 querystring: "?allowed_email_domains=a.b.c.example.com,*.c.example.com",
35393405 expectedStatusCode: http.StatusAccepted,
35403406 },
3541− {
3542− name: "UserWithMultipleAtSignsExactDomain",
3543− email: "attacker@evil.com@example.com",
3544− querystring: "?allowed_email_domains=example.com",
3545− expectedStatusCode: http.StatusForbidden,
3546− },
3547− {
3548− name: "UserWithMultipleAtSignsWildcardDomain",
3549− email: "attacker@evil.com@foo.example.com",
3550− querystring: "?allowed_email_domains=*.example.com",
3551− expectedStatusCode: http.StatusForbidden,
3552− },
3553− {
3554− name: "UserWithMultipleAtSignsDotPrefixedDomain",
3555− email: "attacker@evil.com@foo.example.com",
3556− querystring: "?allowed_email_domains=.example.com",
3557− expectedStatusCode: http.StatusForbidden,
3558− },
35593407 }
35603408
35613409 for _, tc := range testCases {
@@ -3790,14 +3638,14 @@ func TestIdTokenPlaceholderInSignOut(t *testing.T) {
37903638
37913639 // Save the required session
37923640 rw := httptest.NewRecorder()
3793− req, _ := http.NewRequest(http.MethodGet, "/", nil)
3641+ req, _ := http.NewRequest("GET", "/", nil)
37943642 err = proxy.sessionStore.Save(rw, req, session)
37953643 assert.NoError(t, err)
37963644
37973645 rw = httptest.NewRecorder()
37983646
37993647 rdUrl := url.QueryEscape("https://my-oidc-provider.example.com/sign_out_page?id_token_hint={id_token}&post_logout_redirect_uri=https://my-app.example.com/")
3800− req, _ = http.NewRequest(http.MethodGet, "/oauth2/sign_out?rd="+rdUrl, nil)
3648+ req, _ = http.NewRequest("GET", "/oauth2/sign_out?rd="+rdUrl, nil)
38013649 req = middlewareapi.AddRequestScope(req, &middlewareapi.RequestScope{
38023650 RequestID: "11111111-2222-4333-8444-555555555555",
38033651 Session: session,