]> source.dussan.org Git - nextcloud-server.git/commitdiff
add behat tests for 0 quota upload failure
authorMorris Jobke <hey@morrisjobke.de>
Tue, 1 Dec 2015 12:36:55 +0000 (13:36 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Tue, 1 Dec 2015 13:51:32 +0000 (14:51 +0100)
build/integration/data/textfile.txt [new file with mode: 0644]
build/integration/features/bootstrap/Provisioning.php
build/integration/features/bootstrap/WebDav.php
build/integration/features/webdav-related.feature

diff --git a/build/integration/data/textfile.txt b/build/integration/data/textfile.txt
new file mode 100644 (file)
index 0000000..efffdef
--- /dev/null
@@ -0,0 +1,3 @@
+This is a testfile.
+
+Cheers.
\ No newline at end of file
index 05a8885d96def991aba00ce4216c6b75cd7e068d..86d476944fdca1fa224e63e5d49926934a72c267 100644 (file)
@@ -510,6 +510,20 @@ trait Provisioning {
                PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
        }
 
+       /**
+        * @Given user :user has a quota of :quota
+        */
+       public function userHasAQuotaOf($user, $quota)
+       {
+               $body = new \Behat\Gherkin\Node\TableNode([
+                       0 => ['key', 'quota'],
+                       1 => ['value', $quota],
+               ]);
+
+               // method used from BasicStructure trait
+               $this->sendingToWith("PUT", "/cloud/users/" . $user, $body);
+       }
+
        /**
         * @BeforeScenario
         * @AfterScenario
index 567f189c61e3f1076b1593d8683aec0cef2b567f..8f0f30b377aec1ad52a1dda58baf160ebd1fcf01 100644 (file)
@@ -21,7 +21,7 @@ trait WebDav{
                $this->davPath = $davPath;
        }       
 
-       public function makeDavRequest($user, $method, $path, $headers){
+       public function makeDavRequest($user, $method, $path, $headers, $body = null){
                $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path";
                $client = new GClient();
                $options = [];
@@ -36,6 +36,11 @@ trait WebDav{
                                $request->addHeader($key, $value);      
                        }
                }
+
+               if (!is_null($body)) {
+                       $request->setBody($body);
+               }
+
                return $client->send($request);
        }
 
@@ -115,7 +120,20 @@ trait WebDav{
                        }
                }
        }
-       
+
+       /**
+        * @When User :user uploads file :source to :destination
+        */
+       public function userUploadsAFileTo($user, $source, $destination)
+       {
+               $file = \GuzzleHttp\Stream\Stream::factory(fopen($source, 'r'));
+               try {
+                       $this->response = $this->makeDavRequest($user, "PUT", $destination, [], $file);
+               } catch (\GuzzleHttp\Exception\ServerException $e) {
+                       // 4xx and 5xx responses cause an exception
+                       $this->response = $e->getResponse();
+               }
+       }
 
 }
 
index 16955e27063c812c8ce6ced5d3e208e0ea361297..56c4d07f0eb553b9ab4882d0341aeb3d46f7ef35 100644 (file)
@@ -16,6 +16,13 @@ Feature: sharing
                Then Downloaded content should be "example file for developers"
 
 
+       Scenario: Upload forbidden if quota is 0
+               Given using dav path "remote.php/webdav"
+               And As an "admin"
+               And user "user0" exists
+               And user "user0" has a quota of "0"
+               When User "user0" uploads file "data/textfile.txt" to "/asdf.txt"
+               Then the HTTP status code should be "507"