13111: Add tests for /users/ paths.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 20 Mar 2018 14:52:09 +0000 (10:52 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Mon, 26 Mar 2018 19:24:43 +0000 (15:24 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

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

index b7ec1de692193a2a5526d3198e0d97076de538d1..5f5f69a118d526ced6a2546079f4adb2abf8b9c2 100644 (file)
@@ -22,24 +22,33 @@ import (
 )
 
 func (s *IntegrationSuite) TestCadaverHTTPAuth(c *check.C) {
-       s.testCadaver(c, arvadostest.ActiveToken, func(newUUID string) (string, string, string) {
+       s.testCadaver(c, arvadostest.ActiveToken, func(newCollection arvados.Collection) (string, string, string) {
                r := "/c=" + arvadostest.FooAndBarFilesInDirUUID + "/"
-               w := "/c=" + newUUID + "/"
+               w := "/c=" + newCollection.UUID + "/"
                pdh := "/c=" + strings.Replace(arvadostest.FooAndBarFilesInDirPDH, "+", "-", -1) + "/"
                return r, w, pdh
        })
 }
 
 func (s *IntegrationSuite) TestCadaverPathAuth(c *check.C) {
-       s.testCadaver(c, "", func(newUUID string) (string, string, string) {
+       s.testCadaver(c, "", func(newCollection arvados.Collection) (string, string, string) {
                r := "/c=" + arvadostest.FooAndBarFilesInDirUUID + "/t=" + arvadostest.ActiveToken + "/"
-               w := "/c=" + newUUID + "/t=" + arvadostest.ActiveToken + "/"
+               w := "/c=" + newCollection.UUID + "/t=" + arvadostest.ActiveToken + "/"
                pdh := "/c=" + strings.Replace(arvadostest.FooAndBarFilesInDirPDH, "+", "-", -1) + "/t=" + arvadostest.ActiveToken + "/"
                return r, w, pdh
        })
 }
 
-func (s *IntegrationSuite) testCadaver(c *check.C, password string, pathFunc func(string) (string, string, string)) {
+func (s *IntegrationSuite) TestCadaverUserProject(c *check.C) {
+       s.testCadaver(c, arvadostest.ActiveToken, func(newCollection arvados.Collection) (string, string, string) {
+               r := "/users/active/foo_file_in_dir/"
+               w := "/users/active/" + newCollection.Name
+               pdh := "/c=" + strings.Replace(arvadostest.FooAndBarFilesInDirPDH, "+", "-", -1) + "/"
+               return r, w, pdh
+       })
+}
+
+func (s *IntegrationSuite) testCadaver(c *check.C, password string, pathFunc func(arvados.Collection) (string, string, string)) {
        testdata := []byte("the human tragedy consists in the necessity of living with the consequences of actions performed under the pressure of compulsions we do not understand")
 
        tempdir, err := ioutil.TempDir("", "keep-web-test-")
@@ -62,7 +71,7 @@ func (s *IntegrationSuite) testCadaver(c *check.C, password string, pathFunc fun
        err = arv.RequestAndDecode(&newCollection, "POST", "/arvados/v1/collections", bytes.NewBufferString(url.Values{"collection": {"{}"}}.Encode()), nil)
        c.Assert(err, check.IsNil)
 
-       readPath, writePath, pdhPath := pathFunc(newCollection.UUID)
+       readPath, writePath, pdhPath := pathFunc(newCollection)
 
        matchToday := time.Now().Format("Jan +2")
 
index 21e47c8dc7c3e0a64f8d320e24b5cd9041fe7117..3e7ae5fbd8728a3cb32ee9bfa4f9740ac741b8b1 100644 (file)
@@ -516,6 +516,12 @@ func (s *IntegrationSuite) TestDirectoryListing(c *check.C) {
                        expect:  []string{"dir1/foo", "dir1/bar"},
                        cutDirs: 2,
                },
+               {
+                       uri:     "download.example.com/users/active/" + arvadostest.FooAndBarFilesInDirUUID + "/",
+                       header:  authHeader,
+                       expect:  []string{"dir1/foo", "dir1/bar"},
+                       cutDirs: 3,
+               },
                {
                        uri:     "collections.example.com/collections/download/" + arvadostest.FooAndBarFilesInDirUUID + "/" + arvadostest.ActiveToken + "/",
                        header:  nil,