(t *testing.T)
| 2786 | } |
| 2787 | |
| 2788 | func TestAllowedRequestWithForwardedUriHeader(t *testing.T) { |
| 2789 | upstreamServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 2790 | w.WriteHeader(200) |
| 2791 | })) |
| 2792 | t.Cleanup(upstreamServer.Close) |
| 2793 | |
| 2794 | opts := baseTestOptions() |
| 2795 | opts.ReverseProxy = true |
| 2796 | opts.UpstreamServers = options.UpstreamConfig{ |
| 2797 | Upstreams: []options.Upstream{ |
| 2798 | { |
| 2799 | ID: upstreamServer.URL, |
| 2800 | Path: "/", |
| 2801 | URI: upstreamServer.URL, |
| 2802 | }, |
| 2803 | }, |
| 2804 | } |
| 2805 | opts.SkipAuthRegex = []string{ |
| 2806 | "^/skip/auth/regex$", |
| 2807 | "^/public/.*/endpoint$", |
| 2808 | } |
| 2809 | opts.SkipAuthRoutes = []string{ |
| 2810 | "GET=^/skip/auth/routes/get", |
| 2811 | "^/foo/.*/bar$", |
| 2812 | } |
| 2813 | err := validation.Validate(opts) |
| 2814 | assert.NoError(t, err) |
| 2815 | proxy, err := NewOAuthProxy(opts, func(_ string) bool { return true }) |
| 2816 | if err != nil { |
| 2817 | t.Fatal(err) |
| 2818 | } |
| 2819 | |
| 2820 | testCases := []struct { |
| 2821 | name string |
| 2822 | method string |
| 2823 | url string |
| 2824 | allowed bool |
| 2825 | }{ |
| 2826 | { |
| 2827 | name: "Regex GET allowed", |
| 2828 | method: http.MethodGet, |
| 2829 | url: "/skip/auth/regex", |
| 2830 | allowed: true, |
| 2831 | }, |
| 2832 | { |
| 2833 | name: "Regex POST allowed ", |
| 2834 | method: http.MethodPost, |
| 2835 | url: "/skip/auth/regex", |
| 2836 | allowed: true, |
| 2837 | }, |
| 2838 | { |
| 2839 | name: "Regex denied", |
| 2840 | method: http.MethodGet, |
| 2841 | url: "/wrong/denied", |
| 2842 | allowed: false, |
| 2843 | }, |
| 2844 | { |
| 2845 | name: "Regex allowed with fragment-free path", |
nothing calls this directly
no test coverage detected