13111: Serve /by_id/ dir.
authorTom Clegg <tclegg@veritasgenetics.com>
Thu, 12 Apr 2018 14:14:31 +0000 (10:14 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Thu, 12 Apr 2018 14:14:31 +0000 (10:14 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/keep-web/cadaver_test.go
services/keep-web/handler.go

index 22ddd84df09e1883fa0aa1d83d540211c0efc39d..db5d373be76934e6fd48d98498a059040b70c9bd 100644 (file)
@@ -265,6 +265,22 @@ func (s *IntegrationSuite) testCadaver(c *check.C, password string, pathFunc fun
        }
 }
 
+func (s *IntegrationSuite) TestCadaverByID(c *check.C) {
+       for _, path := range []string{"/by_id", "/by_id/"} {
+               stdout := s.runCadaver(c, arvadostest.ActiveToken, path, "ls")
+               c.Check(stdout, check.Matches, `(?ms).*collection is empty.*`)
+       }
+       for _, path := range []string{
+               "/by_id/" + arvadostest.FooPdh,
+               "/by_id/" + arvadostest.FooPdh + "/",
+               "/by_id/" + arvadostest.FooCollection,
+               "/by_id/" + arvadostest.FooCollection + "/",
+       } {
+               stdout := s.runCadaver(c, arvadostest.ActiveToken, path, "ls")
+               c.Check(stdout, check.Matches, `(?ms).*\s+foo\s+3 .*`)
+       }
+}
+
 func (s *IntegrationSuite) TestCadaverUsersDir(c *check.C) {
        for _, path := range []string{"/"} {
                stdout := s.runCadaver(c, arvadostest.ActiveToken, path, "ls")
index 389ab73a0cc2159564a8884f33d7cd2feaa64850..06185882dcd781bc133e0c42a0756dc31e21342e 100644 (file)
@@ -163,6 +163,12 @@ var (
                "HEAD": true,
                "POST": true,
        }
+       // top-level dirs to serve with siteFS
+       siteFSDir = map[string]bool{
+               "":      true, // root directory
+               "by_id": true,
+               "users": true,
+       }
 )
 
 // ServeHTTP implements http.Handler.
@@ -250,7 +256,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
        } else if r.URL.Path == "/status.json" {
                h.serveStatus(w, r)
                return
-       } else if r.URL.Path == "/" || (len(pathParts) >= 1 && pathParts[0] == "users") {
+       } else if siteFSDir[pathParts[0]] {
                useSiteFS = true
        } else if len(pathParts) >= 1 && strings.HasPrefix(pathParts[0], "c=") {
                // /c=ID[/PATH...]