5824: Handle various combinations of c= and t= more consistently. Use vhosts in integ...
[arvados.git] / services / keep-web / handler_test.go
index a1f5e1a01b64b33fcbf8b80cdc8beeed684d72b2..50fd7175050c1a22a796f104db6cc31fd57cc605 100644 (file)
@@ -42,6 +42,10 @@ func (s *IntegrationSuite) TestVhost404(c *check.C) {
        }
 }
 
+// An authorizer modifies an HTTP request to make use of the given
+// token -- by adding it to a header, cookie, query param, or whatever
+// -- and returns the HTTP status code we should expect from keep-web if
+// the token is invalid.
 type authorizer func(*http.Request, string) int
 
 func (s *IntegrationSuite) TestVhostViaAuthzHeader(c *check.C) {
@@ -93,7 +97,19 @@ func authzViaPOST(r *http.Request, tok string) int {
 // Try some combinations of {url, token} using the given authorization
 // mechanism, and verify the result is correct.
 func doVhostRequests(c *check.C, authz authorizer) {
-       hostPath := arvadostest.FooCollection + ".example.com/foo"
+       for _, hostPath := range []string{
+               arvadostest.FooCollection + ".example.com/foo",
+               arvadostest.FooCollection + "--dl.example.com/foo",
+               arvadostest.FooCollection + "--dl.example.com/_/foo",
+               arvadostest.FooPdh + ".example.com/foo",
+               strings.Replace(arvadostest.FooPdh, "+", "-", -1) + "--dl.example.com/foo",
+       } {
+               c.Log("doRequests: ", hostPath)
+               doVhostRequestsWithHostPath(c, authz, hostPath)
+       }
+}
+
+func doVhostRequestsWithHostPath(c *check.C, authz authorizer, hostPath string) {
        for _, tok := range []string{
                arvadostest.ActiveToken,
                arvadostest.ActiveToken[:15],