aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-12-02 10:13:15 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-12-02 10:13:15 +0100
commit438d0be844d212dcc5dbf3933ced46de0bdce486 (patch)
tree839c988abdf3dc22f7a29de8398b83fdd5e6a512
parentc46ea3024836fc020ad6552ef7b579c3be1faf63 (diff)
parent6baed0c998449d110452184cf16c694eb22705b9 (diff)
downloadnextcloud-server-438d0be844d212dcc5dbf3933ced46de0bdce486.tar.gz
nextcloud-server-438d0be844d212dcc5dbf3933ced46de0bdce486.zip
Merge pull request #20867 from owncloud/add-quota-behat-test
Add quota behat test
-rw-r--r--build/integration/data/textfile.txt3
-rw-r--r--build/integration/features/bootstrap/Provisioning.php18
-rw-r--r--build/integration/features/bootstrap/WebDav.php22
-rw-r--r--build/integration/features/webdav-related.feature7
-rwxr-xr-xbuild/integration/run.sh2
5 files changed, 47 insertions, 5 deletions
diff --git a/build/integration/data/textfile.txt b/build/integration/data/textfile.txt
new file mode 100644
index 00000000000..efffdeff159
--- /dev/null
+++ b/build/integration/data/textfile.txt
@@ -0,0 +1,3 @@
+This is a testfile.
+
+Cheers. \ No newline at end of file
diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php
index 05a8885d96d..9a21c0bb1d4 100644
--- a/build/integration/features/bootstrap/Provisioning.php
+++ b/build/integration/features/bootstrap/Provisioning.php
@@ -175,7 +175,7 @@ trait Provisioning {
* @Given /^user "([^"]*)" belongs to group "([^"]*)"$/
*/
public function assureUserBelongsToGroup($user, $group){
- if (!$this->userBelongsToGroup($user, $group)){
+ if (!$this->userBelongsToGroup($user, $group)){
$previous_user = $this->currentUser;
$this->currentUser = "admin";
$this->addingUserToGroup($user, $group);
@@ -431,7 +431,7 @@ trait Provisioning {
$this->theSubadminGroupsShouldBe($groupsList);
}
- /**
+ /**
* Parses the xml answer to get the array of users returned.
* @param ResponseInterface $resp
* @return array
@@ -511,6 +511,20 @@ trait Provisioning {
}
/**
+ * @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
*/
diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php
index 567f189c61e..8f0f30b377a 100644
--- a/build/integration/features/bootstrap/WebDav.php
+++ b/build/integration/features/bootstrap/WebDav.php
@@ -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();
+ }
+ }
}
diff --git a/build/integration/features/webdav-related.feature b/build/integration/features/webdav-related.feature
index 16955e27063..56c4d07f0eb 100644
--- a/build/integration/features/webdav-related.feature
+++ b/build/integration/features/webdav-related.feature
@@ -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"
diff --git a/build/integration/run.sh b/build/integration/run.sh
index 9a2fe8e1895..76c01068deb 100755
--- a/build/integration/run.sh
+++ b/build/integration/run.sh
@@ -21,7 +21,7 @@ echo $PHPPID_FED
export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
export TEST_SERVER_FED_URL="http://localhost:$PORT_FED/ocs/"
-vendor/bin/behat -f junit -f pretty
+vendor/bin/behat -f junit -f pretty $1
RESULT=$?
kill $PHPPID