12483: Add webdav COPY method.
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 28 Nov 2017 15:17:55 +0000 (10:17 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Tue, 28 Nov 2017 15:17:55 +0000 (10:17 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

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

index 52d30b04cc5824a71df411758a3463d10ea3c299..e80facc3e0435350297dec50c1422a5621970523 100644 (file)
@@ -141,6 +141,17 @@ func (s *IntegrationSuite) TestWebdavWithCadaver(c *check.C) {
                        cmd:   "put '" + localfile.Name() + "' newdir2/testfile2\n",
                        match: `(?ms).*Uploading .* succeeded.*`,
                },
+               {
+                       path:  writePath,
+                       cmd:   "copy newdir2/testfile2 testfile3\n",
+                       match: `(?ms).*succeeded.*`,
+               },
+               {
+                       path:  writePath,
+                       cmd:   "get testfile3 '" + checkfile.Name() + "'\n",
+                       match: `(?ms).*succeeded.*`,
+                       data:  testdata,
+               },
                {
                        path:  writePath,
                        cmd:   "get newdir2/testfile2 '" + checkfile.Name() + "'\n",
index c9148a562eb3bc86e53ec27944cffa2a8a6010ff..131214d08ce932901eddab8021ff196b4a3a527f 100644 (file)
@@ -139,6 +139,7 @@ func (uos *updateOnSuccess) WriteHeader(code int) {
 
 var (
        writeMethod = map[string]bool{
+               "COPY":   true,
                "DELETE": true,
                "MKCOL":  true,
                "MOVE":   true,
@@ -146,6 +147,7 @@ var (
                "RMCOL":  true,
        }
        webdavMethod = map[string]bool{
+               "COPY":     true,
                "DELETE":   true,
                "MKCOL":    true,
                "MOVE":     true,
@@ -200,7 +202,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
                        return
                }
                w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, Range")
-               w.Header().Set("Access-Control-Allow-Methods", "DELETE, GET, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PUT, RMCOL")
+               w.Header().Set("Access-Control-Allow-Methods", "COPY, DELETE, GET, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PUT, RMCOL")
                w.Header().Set("Access-Control-Allow-Origin", "*")
                w.Header().Set("Access-Control-Max-Age", "86400")
                statusCode = http.StatusOK
index 85a8e500d42397401187332aedd9bf884c93e5ac..21e47c8dc7c3e0a64f8d320e24b5cd9041fe7117 100644 (file)
@@ -45,7 +45,7 @@ func (s *UnitSuite) TestCORSPreflight(c *check.C) {
        c.Check(resp.Code, check.Equals, http.StatusOK)
        c.Check(resp.Body.String(), check.Equals, "")
        c.Check(resp.Header().Get("Access-Control-Allow-Origin"), check.Equals, "*")
-       c.Check(resp.Header().Get("Access-Control-Allow-Methods"), check.Equals, "DELETE, GET, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PUT, RMCOL")
+       c.Check(resp.Header().Get("Access-Control-Allow-Methods"), check.Equals, "COPY, DELETE, GET, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PUT, RMCOL")
        c.Check(resp.Header().Get("Access-Control-Allow-Headers"), check.Equals, "Authorization, Content-Type, Range")
 
        // Check preflight for a disallowed request