]> source.dussan.org Git - nextcloud-server.git/commitdiff
Adding quota plugin to new dav endpoint (#25615) 654/head
authorThomas Müller <DeepDiver1975@users.noreply.github.com>
Fri, 29 Jul 2016 04:40:39 +0000 (06:40 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Fri, 29 Jul 2016 10:31:56 +0000 (12:31 +0200)
* Adding quota plugin to new dav endpoint

* Added integrated test failing in old endpoint

* Added 0B quota test

apps/dav/lib/Server.php
build/integration/features/bootstrap/WebDav.php
build/integration/features/dav-v2.feature

index e80f9ae125ab2e9744f456c4c032d0a73ea98676..9058548489ce9c6ebcfd3174c8400d7c3fd1c8a4 100644 (file)
@@ -173,6 +173,9 @@ class Server {
                                                )
                                        )
                                );
+                               $this->server->addPlugin(
+                                       new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
+
                        }
                });
        }
index 9b0050d82dd5e9e286711bf8a6c98e4f98f38745..71f938c7ec4e5dac5500b77dc39af66d4b0d55c2 100644 (file)
@@ -50,6 +50,18 @@ trait WebDav {
                $this->davPath = $davPath;
        }
 
+       /**
+        * @return string
+        */
+       public function getFilesPath() {
+               if ($this->davPath === 'remote.php/dav') {
+                       $basePath = '/files/' . $this->currentUser . '/';
+               } else {
+                       $basePath = '/';
+               }
+               return $basePath;
+       }
+
        public function makeDavRequest($user, $method, $path, $headers, $body = null){
                $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path";
                $client = new GClient();
@@ -413,9 +425,9 @@ trait WebDav {
         * @param string $user
         * @param string $destination
         */
-       public function userCreatedAFolder($user, $destination){
+       public function userCreatedAFolder($user, $destination) {
                try {
-                       $this->response = $this->makeDavRequest($user, "MKCOL", $destination, []);
+                       $this->response = $this->makeDavRequest($user, "MKCOL", $this->getFilesPath() . ltrim($destination, $this->getFilesPath()), []);
                } catch (\GuzzleHttp\Exception\ServerException $e) {
                        // 4xx and 5xx responses cause an exception
                        $this->response = $e->getResponse();
index 2b3aeff94542cb56aaa924c5c01cf9a63c27d7c4..a57b7f26c43643d1bf627d6337ce8086aca88cc4 100644 (file)
@@ -53,3 +53,30 @@ Feature: dav-v2
                Given Logging in using web as "admin"
                When Sending a "PROPFIND" to "/remote.php/dav/files/admin/welcome.txt" with requesttoken
                Then the HTTP status code should be "207"
+
+       Scenario: Uploading a file having 0B as quota
+               Given using dav path "remote.php/dav"
+               And As an "admin"
+               And user "user0" exists
+               And user "user0" has a quota of "0 B"
+               And As an "user0"
+               When User "user0" uploads file "data/textfile.txt" to "/files/user0/asdf.txt"
+               Then the HTTP status code should be "507"
+
+       Scenario: Uploading a file as recipient using webdav new endpoint having quota
+               Given using dav path "remote.php/dav"
+               And As an "admin"
+               And user "user0" exists
+               And user "user1" exists
+               And user "user0" has a quota of "10 MB"
+               And user "user1" has a quota of "10 MB"
+               And As an "user1"
+               And user "user1" created a folder "/testquota"
+               And as "user1" creating a share with
+                 | path | testquota |
+                 | shareType | 0 |
+                 | permissions | 31 |
+                 | shareWith | user0 |
+               And As an "user0"
+               When User "user0" uploads file "data/textfile.txt" to "/files/user0/testquota/asdf.txt"
+               Then the HTTP status code should be "201"