@@ -2242,21 +2242,24 @@ func TestTrustedIPs(t *testing.T) {
2244func Test_buildRoutesAllowlist(t *testing.T) {
2244func Test_buildRoutesAllowlist(t *testing.T) {
2245+ type expectedAllowedRoute struct {
2245 testCases := []struct {
2250 testCases := []struct {
2246− name string
2251+ name string
2247− skipAuthRegex []string
2252+ skipAuthRegex []string
2248− skipAuthRoutes []string
2253+ skipAuthRoutes []string
2249− expectedMethods []string
2254+ expectedRoutes []expectedAllowedRoute
2250− expectedRegexes []string
2251− shouldError bool
2255+ shouldError bool
2254− name: "No skip auth configured",
2258+ name: "No skip auth configured",
2255− skipAuthRegex: []string{},
2259+ skipAuthRegex: []string{},
2256− skipAuthRoutes: []string{},
2260+ skipAuthRoutes: []string{},
2257− expectedMethods: []string{},
2261+ expectedRoutes: []expectedAllowedRoute{},
2258− expectedRegexes: []string{},
2259− shouldError: false,
2262+ shouldError: false,
2262 name: "Only skipAuthRegex configured",
2265 name: "Only skipAuthRegex configured",
@@ -2265,13 +2268,15 @@ func Test_buildRoutesAllowlist(t *testing.T) {
2265 "^/baz/[0-9]+/thing",
2268 "^/baz/[0-9]+/thing",
2267 skipAuthRoutes: []string{},
2270 skipAuthRoutes: []string{},
2268− expectedMethods: []string{
2271+ expectedRoutes: []expectedAllowedRoute{
2270− "",
2273+ method: "",
2272− expectedRegexes: []string{
2273− "^/foo/bar",
2274+ regexString: "^/foo/bar",
2274− "^/baz/[0-9]+/thing",
2278+ regexString: "^/baz/[0-9]+/thing",
2276 shouldError: false,
2281 shouldError: false,
@@ -2285,19 +2290,27 @@ func Test_buildRoutesAllowlist(t *testing.T) {
2285 "WEIRD=^/methods/are/allowed",
2290 "WEIRD=^/methods/are/allowed",
2286 "PATCH=/second/equals?are=handled&just=fine",
2291 "PATCH=/second/equals?are=handled&just=fine",
2288− expectedMethods: []string{
2293+ expectedRoutes: []expectedAllowedRoute{
2289− "GET",
2295+ method: "GET",
2295− expectedRegexes: []string{
2296− "^/foo/bar",
2296+ regexString: "^/foo/bar",
2297− "^/baz/[0-9]+/thing",
2300+ regexString: "^/baz/[0-9]+/thing",
2298− "^/all/methods$",
2304+ regexString: "^/all/methods$",
2299− "^/methods/are/allowed",
2308+ regexString: "^/methods/are/allowed",
2300− "/second/equals?are=handled&just=fine",
2312+ regexString: "/second/equals?are=handled&just=fine",
2302 shouldError: false,
2315 shouldError: false,
@@ -2312,19 +2325,27 @@ func Test_buildRoutesAllowlist(t *testing.T) {
2312 "POST=^/baz/[0-9]+/thing",
2325 "POST=^/baz/[0-9]+/thing",
2313 "^/all/methods$",
2326 "^/all/methods$",
2315− expectedMethods: []string{
2328+ expectedRoutes: []expectedAllowedRoute{
2317− "",
2330+ method: "",
2331+ regexString: "^/foo/bar/regex",
2335+ regexString: "^/baz/[0-9]+/thing/regex",
2318− "GET",
2338+ method: "GET",
2339+ regexString: "^/foo/bar",
2319− "POST",
2342+ method: "POST",
2322− expectedRegexes: []string{
2324− "^/baz/[0-9]+/thing/regex",
2343+ regexString: "^/baz/[0-9]+/thing",
2325− "^/foo/bar",
2344+ },
2326− "^/baz/[0-9]+/thing",
2345+ {
2327− "^/all/methods$",
2347+ regexString: "^/all/methods$",
2329 shouldError: false,
2350 shouldError: false,
@@ -2335,10 +2356,9 @@ func Test_buildRoutesAllowlist(t *testing.T) {
2335 "^/baz/[0-9]+/thing",
2356 "^/baz/[0-9]+/thing",
2336 "(bad[regex",
2357 "(bad[regex",
2338− skipAuthRoutes: []string{},
2359+ skipAuthRoutes: []string{},
2339− expectedMethods: []string{},
2360+ expectedRoutes: []expectedAllowedRoute{},
2340− expectedRegexes: []string{},
2341− shouldError: true,
2361+ shouldError: true,
2344 name: "Invalid skipAuthRoutes entry",
2364 name: "Invalid skipAuthRoutes entry",
@@ -2349,9 +2369,8 @@ func Test_buildRoutesAllowlist(t *testing.T) {
2349 "^/all/methods$",
2369 "^/all/methods$",
2350 "PUT=(bad[regex",
2370 "PUT=(bad[regex",
2352− expectedMethods: []string{},
2372+ expectedRoutes: []expectedAllowedRoute{},
2353− expectedRegexes: []string{},
2354− shouldError: true,
2373+ shouldError: true,
@@ -2369,10 +2388,9 @@ func Test_buildRoutesAllowlist(t *testing.T) {
2369 assert.NoError(t, err)
2388 assert.NoError(t, err)
2371 for i, route := range routes {
2390 for i, route := range routes {
2372− assert.Greater(t, len(tc.expectedMethods), i)
2391+ assert.Greater(t, len(tc.expectedRoutes), i)
2373− assert.Equal(t, route.method, tc.expectedMethods[i])
2392+ assert.Equal(t, route.method, tc.expectedRoutes[i].method)
2374− assert.Greater(t, len(tc.expectedRegexes), i)
2375− assert.Equal(t, route.pathRegex.String(), tc.expectedRegexes[i])
2393+ assert.Equal(t, route.pathRegex.String(), tc.expectedRoutes[i].regexString)