Skip to content
Snippets Groups Projects
Commit 9aea7304 authored by Rohith Jayawardene's avatar Rohith Jayawardene Committed by GitHub
Browse files

Merge pull request #242 from gambol99/tests

Routing Issues Check
parents af6b0ab5 31e0fbc8
No related branches found
No related tags found
No related merge requests found
...@@ -326,6 +326,57 @@ func TestOauthRequests(t *testing.T) { ...@@ -326,6 +326,57 @@ func TestOauthRequests(t *testing.T) {
newFakeProxy(cfg).RunTests(t, requests) newFakeProxy(cfg).RunTests(t, requests)
} }
func TestStrangeRoutingError(t *testing.T) {
cfg := newFakeKeycloakConfig()
cfg.Resources = []*Resource{
{
URL: "/api/v1/event/123456789",
Methods: allHTTPMethods,
Roles: []string{"user"},
},
{
URL: "/api/v1/event/404",
Methods: allHTTPMethods,
Roles: []string{"monitoring"},
},
{
URL: "/api/v1/audit/*",
Methods: allHTTPMethods,
Roles: []string{"auditor", "dev"},
},
{
URL: "/*",
Methods: allHTTPMethods,
Roles: []string{"dev"},
},
}
requests := []fakeRequest{
{ // should work
URI: "/api/v1/event/123456789",
HasToken: true,
Redirects: true,
Roles: []string{"user"},
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
},
{ // good
URI: "/api/v1/event/404",
HasToken: true,
Redirects: false,
Roles: []string{"monitoring"},
ExpectedProxy: true,
ExpectedCode: http.StatusOK,
},
{ // this should fail here
URI: "/api/v1/event/1000",
Redirects: false,
ExpectedCode: http.StatusUnauthorized,
},
}
newFakeProxy(cfg).RunTests(t, requests)
}
func TestNoProxyingRequests(t *testing.T) { func TestNoProxyingRequests(t *testing.T) {
c := newFakeKeycloakConfig() c := newFakeKeycloakConfig()
c.Resources = []*Resource{ c.Resources = []*Resource{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment