17464: Add tests for paths by /users/ and by PDH
authorPeter Amstutz <peter.amstutz@curii.com>
Thu, 17 Jun 2021 19:49:04 +0000 (15:49 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 18 Jun 2021 15:35:01 +0000 (11:35 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

sdk/go/arvadostest/fixtures.go
services/keep-web/handler_test.go

index 0c05441a81f452bbc47ea3f23a3d72893bce0d17..4b7ad6dd59fa426e8b1e71c546ee43a851d99c54 100644 (file)
@@ -31,6 +31,8 @@ const (
        UserAgreementPDH        = "b519d9cb706a29fc7ea24dbea2f05851+93"
        HelloWorldPdh           = "55713e6a34081eb03609e7ad5fcad129+62"
 
+       MultilevelCollection1 = "zzzzz-4zz18-pyw8yp9g3pr7irn"
+
        AProjectUUID    = "zzzzz-j7d0g-v955i6s2oi1cbso"
        ASubprojectUUID = "zzzzz-j7d0g-axqo7eu9pwvna1x"
 
index 65dfb4312f7ff33ba64403967721c91255d15c02..e883e806ccf509fc87a73f592300619e61901fd3 100644 (file)
@@ -1216,7 +1216,8 @@ func (s *IntegrationSuite) checkUploadDownloadRequest(c *check.C, h *handler, re
                c.Check(logbuf.String(), check.Matches, `(?ms).*msg="File `+direction+`".*`)
                c.Check(logbuf.String(), check.Not(check.Matches), `(?ms).*level=error.*`)
 
-               for nextLogId == lastLogId {
+               count := 0
+               for ; nextLogId == lastLogId && count < 20; count++ {
                        time.Sleep(50 * time.Millisecond)
                        err = client.RequestAndDecode(&logentries, "GET", "arvados/v1/logs", nil,
                                arvados.ResourceListParams{
@@ -1229,7 +1230,7 @@ func (s *IntegrationSuite) checkUploadDownloadRequest(c *check.C, h *handler, re
                                nextLogId = logentries.Items[0].ID
                        }
                }
-
+               c.Check(count, check.Not(check.Equals), 20)
                c.Check(logentries.Items[0].ObjectUUID, check.Equals, userUuid)
                c.Check(logentries.Items[0].Properties["collection_uuid"], check.Equals, collectionUuid)
                c.Check(logentries.Items[0].Properties["collection_file_path"], check.Equals, filepath)
@@ -1244,6 +1245,8 @@ func (s *IntegrationSuite) TestDownloadLoggingPermission(c *check.C) {
        h := handler{Config: config}
        u := mustParseURL("http://" + arvadostest.FooCollection + ".keep-web.example/foo")
 
+       config.cluster.Collections.TrustAllContent = true
+
        for _, adminperm := range []bool{true, false} {
                for _, userperm := range []bool{true, false} {
                        config.cluster.Collections.WebDAVPermission.Admin.Download = adminperm
@@ -1276,6 +1279,38 @@ func (s *IntegrationSuite) TestDownloadLoggingPermission(c *check.C) {
                                arvadostest.ActiveUserUUID, arvadostest.FooCollection, "foo")
                }
        }
+
+       config.cluster.Collections.WebDAVPermission.User.Download = true
+
+       for _, tryurl := range []string{"http://" + arvadostest.MultilevelCollection1 + ".keep-web.example/dir1/subdir/file1",
+               "http://keep-web/users/active/multilevel_collection_1/dir1/subdir/file1"} {
+
+               u = mustParseURL(tryurl)
+               req := &http.Request{
+                       Method:     "GET",
+                       Host:       u.Host,
+                       URL:        u,
+                       RequestURI: u.RequestURI(),
+                       Header: http.Header{
+                               "Authorization": {"Bearer " + arvadostest.ActiveToken},
+                       },
+               }
+               s.checkUploadDownloadRequest(c, &h, req, http.StatusOK, "download", true,
+                       arvadostest.ActiveUserUUID, arvadostest.MultilevelCollection1, "dir1/subdir/file1")
+       }
+
+       u = mustParseURL("http://" + strings.Replace(arvadostest.FooCollectionPDH, "+", "-", 1) + ".keep-web.example/foo")
+       req := &http.Request{
+               Method:     "GET",
+               Host:       u.Host,
+               URL:        u,
+               RequestURI: u.RequestURI(),
+               Header: http.Header{
+                       "Authorization": {"Bearer " + arvadostest.ActiveToken},
+               },
+       }
+       s.checkUploadDownloadRequest(c, &h, req, http.StatusOK, "download", true,
+               arvadostest.ActiveUserUUID, arvadostest.FooCollection, "foo")
 }
 
 func (s *IntegrationSuite) TestUploadLoggingPermission(c *check.C) {