proxy: add additional tests for trailing slash

This commit is contained in:
Caleb Doxsey 2020-04-17 07:57:26 -06:00 committed by Caleb Doxsey
parent e1d2501a94
commit 19053c8f06
2 changed files with 5 additions and 0 deletions

View file

@ -53,6 +53,7 @@ test_allowed_route_source {
allowed_route("http://example.com", {"source": "example.com"})
allowed_route("http://example.com", {"source": "http://example.com"})
allowed_route("http://example.com", {"source": "https://example.com"})
allowed_route("http://example.com/", {"source": "https://example.com"})
not allowed_route("http://example.org", {"source": "example.com"})
}
@ -64,6 +65,7 @@ test_allowed_route_prefix {
test_allowed_route_path {
allowed_route("http://example.com", {"path": "/"})
allowed_route("http://example.com/", {"path": "/"})
not allowed_route("http://example.com/admin/somepath", {"path": "/admin"})
not allowed_route("http://example.com", {"path": "/admin"})
}

View file

@ -288,6 +288,9 @@ func TestRouteMatcherFuncFromPolicy(t *testing.T) {
{"https://www.example.com", "", "", "",
"https://www.example.com", true,
"should match when host is the same as source host"},
{"https://www.example.com/", "", "", "",
"https://www.example.com", true,
"should match when host is the same as source host with trailing slash"},
{"https://www.example.com", "", "", "",
"https://www.google.com", false,
"should not match when host is different from source host"},