Skip to content

Commit

Permalink
Add noproxy tests (#239)
Browse files Browse the repository at this point in the history
* Update docu

* Add additional noproxy tests
  • Loading branch information
p53 committed Dec 9, 2022
1 parent 2c24adc commit 11ec1be
Showing 1 changed file with 91 additions and 1 deletion.
92 changes: 91 additions & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ func TestNoProxy(t *testing.T) {
ExecutionSettings []fakeRequest
}{
{
Name: "TestEmptyXForwarded",
Name: "TestNoProxyWithNoRedirectsWhiteListed",
ProxySettings: func(c *Config) {
c.EnableDefaultDenyStrict = true
c.NoRedirects = true
Expand Down Expand Up @@ -972,6 +972,96 @@ func TestNoProxy(t *testing.T) {
},
},
},
{
Name: "TestNoProxyWithNoRedirectsPrivateUnauthenticated",
ProxySettings: func(c *Config) {
c.EnableDefaultDenyStrict = true
c.NoRedirects = true
c.NoProxy = true
c.Resources = []*authorization.Resource{
{
URL: "/public/*",
Methods: utils.AllHTTPMethods,
WhiteListed: true,
},
{
URL: "/private",
Methods: []string{"GET"},
},
}
},
ExecutionSettings: []fakeRequest{
{
URI: "/private",
ExpectedProxy: false,
ExpectedCode: http.StatusUnauthorized,
ExpectedContent: func(body string, testNum int) {
assert.Equal(t, body, "")
},
},
},
},
{
Name: "TestNoProxyWithRedirectsPrivateUnauthenticated",
ProxySettings: func(c *Config) {
c.EnableDefaultDeny = true
c.NoRedirects = false
c.NoProxy = true
c.Resources = []*authorization.Resource{
{
URL: "/public/*",
Methods: utils.AllHTTPMethods,
WhiteListed: true,
},
{
URL: "/private",
Methods: []string{"GET"},
},
}
},
ExecutionSettings: []fakeRequest{
{
URI: "/private",
ExpectedProxy: false,
Redirects: true,
ExpectedCode: http.StatusSeeOther,
ExpectedContent: func(body string, testNum int) {
assert.Equal(t, body, "")
},
},
},
},
{
Name: "TestNoProxyWithRedirectsPrivateAuthenticated",
ProxySettings: func(c *Config) {
c.EnableDefaultDeny = true
c.NoRedirects = false
c.NoProxy = true
c.Resources = []*authorization.Resource{
{
URL: "/public/*",
Methods: utils.AllHTTPMethods,
WhiteListed: true,
},
{
URL: "/private",
Methods: []string{"GET"},
},
}
},
ExecutionSettings: []fakeRequest{
{
URI: "/private",
ExpectedProxy: false,
HasLogin: true,
Redirects: true,
ExpectedCode: http.StatusOK,
ExpectedContent: func(body string, testNum int) {
assert.Equal(t, body, "")
},
},
},
},
}

for _, testCase := range testCases {
Expand Down

0 comments on commit 11ec1be

Please sign in to comment.