From 7413e2a88ca7479f06acc3ab25f9958150dcae97 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Mon, 26 Sep 2016 10:44:14 +0000 Subject: [PATCH 1/3] Added test checking quota after usage Signed-off-by: Lukas Reschke --- .../features/bootstrap/BasicStructure.php | 7 +++++++ build/integration/features/bootstrap/WebDav.php | 14 ++++++++++++++ build/integration/features/webdav-related.feature | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php index df46d0b1983..c2a826521ad 100644 --- a/build/integration/features/bootstrap/BasicStructure.php +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -313,6 +313,13 @@ trait BasicStructure { file_put_contents("../../data/$user/files" . "$filename", "$text"); } + public function createFileSpecificSize($user, $name, $size){ + $file = fopen("data/" . "$name", 'w'); + fseek($file, $size - 1 ,SEEK_CUR); + fwrite($file,'a'); // write a dummy char at SIZE position + fclose($file); + } + /** * @BeforeSuite */ diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 02f3e82a4c3..f4904e5ae7a 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -424,6 +424,20 @@ trait WebDav { } } + /** + * @When User :user adds a file of :bytes bytes to :destination + * @param string $user + * @param string $bytes + * @param string $destination + */ + public function userAddsAFileTo($user, $bytes, $destination){ + $filename = "filespecificSize.txt"; + $this->createFileSpecificSize($user, $filename, $bytes); + PHPUnit_Framework_Assert::assertEquals(1, file_exists("data/$filename")); + $this->userUploadsAFileTo($user, "data/$filename", $destination); + $this->removeFile("data/", $filename); + } + /** * @When User :user uploads file with content :content to :destination */ diff --git a/build/integration/features/webdav-related.feature b/build/integration/features/webdav-related.feature index a59d65a2674..86ceafb1fc5 100644 --- a/build/integration/features/webdav-related.feature +++ b/build/integration/features/webdav-related.feature @@ -77,6 +77,16 @@ Feature: webdav-related When User "user0" uploads file "data/textfile.txt" to "/testquota/asdf.txt" Then the HTTP status code should be "201" + Scenario: Retrieving folder quota when quota is set and a file was uploaded + Given using dav path "remote.php/webdav" + And As an "admin" + And user "user0" exists + And user "user0" has a quota of "1 KB" + And user "user0" adds a file of 93 bytes to "/prueba.txt" + When as "user0" gets properties of folder "/" with + |{DAV:}quota-available-bytes| + Then the single response should contain a property "{DAV:}quota-available-bytes" with value "600" + Scenario: download a public shared file with range Given user "user0" exists And As an "user0" From e011065a085db7b6195256f6d53bb01a652bcee1 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Mon, 26 Sep 2016 12:10:24 +0000 Subject: [PATCH 2/3] Added quota calculation test when a file is recieved Signed-off-by: Lukas Reschke --- .../features/bootstrap/BasicStructure.php | 2 +- build/integration/features/bootstrap/WebDav.php | 3 ++- build/integration/features/webdav-related.feature | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php index c2a826521ad..30d78ebd23a 100644 --- a/build/integration/features/bootstrap/BasicStructure.php +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -313,7 +313,7 @@ trait BasicStructure { file_put_contents("../../data/$user/files" . "$filename", "$text"); } - public function createFileSpecificSize($user, $name, $size){ + public function createFileSpecificSize($name, $size){ $file = fopen("data/" . "$name", 'w'); fseek($file, $size - 1 ,SEEK_CUR); fwrite($file,'a'); // write a dummy char at SIZE position diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index f4904e5ae7a..be181f2bcb7 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -432,10 +432,11 @@ trait WebDav { */ public function userAddsAFileTo($user, $bytes, $destination){ $filename = "filespecificSize.txt"; - $this->createFileSpecificSize($user, $filename, $bytes); + $this->createFileSpecificSize($filename, $bytes); PHPUnit_Framework_Assert::assertEquals(1, file_exists("data/$filename")); $this->userUploadsAFileTo($user, "data/$filename", $destination); $this->removeFile("data/", $filename); + PHPUnit_Framework_Assert::assertEquals(1, file_exists("../../data/$user/files$destination")); } /** diff --git a/build/integration/features/webdav-related.feature b/build/integration/features/webdav-related.feature index 86ceafb1fc5..4a92c65d057 100644 --- a/build/integration/features/webdav-related.feature +++ b/build/integration/features/webdav-related.feature @@ -87,6 +87,18 @@ Feature: webdav-related |{DAV:}quota-available-bytes| Then the single response should contain a property "{DAV:}quota-available-bytes" with value "600" + Scenario: Retrieving folder quota when quota is set and a file was recieved + Given using dav path "remote.php/webdav" + And As an "admin" + And user "user0" exists + And user "user1" exists + And user "user1" has a quota of "1 KB" + And user "user0" adds a file of 93 bytes to "/user0.txt" + And file "user0.txt" of user "user0" is shared with user "user1" + When as "user1" gets properties of folder "/" with + |{DAV:}quota-available-bytes| + Then the single response should contain a property "{DAV:}quota-available-bytes" with value "693" + Scenario: download a public shared file with range Given user "user0" exists And As an "user0" From 554d0c58c370edf8b8237f394b37949d775edb30 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 2 Oct 2016 21:18:20 +0200 Subject: [PATCH 3/3] Fix size Nextcloud has a letter (byte) more than ownCloud. So update test --- build/integration/features/webdav-related.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/integration/features/webdav-related.feature b/build/integration/features/webdav-related.feature index 4a92c65d057..01d437f519f 100644 --- a/build/integration/features/webdav-related.feature +++ b/build/integration/features/webdav-related.feature @@ -85,7 +85,7 @@ Feature: webdav-related And user "user0" adds a file of 93 bytes to "/prueba.txt" When as "user0" gets properties of folder "/" with |{DAV:}quota-available-bytes| - Then the single response should contain a property "{DAV:}quota-available-bytes" with value "600" + Then the single response should contain a property "{DAV:}quota-available-bytes" with value "592" Scenario: Retrieving folder quota when quota is set and a file was recieved Given using dav path "remote.php/webdav" @@ -97,7 +97,7 @@ Feature: webdav-related And file "user0.txt" of user "user0" is shared with user "user1" When as "user1" gets properties of folder "/" with |{DAV:}quota-available-bytes| - Then the single response should contain a property "{DAV:}quota-available-bytes" with value "693" + Then the single response should contain a property "{DAV:}quota-available-bytes" with value "685" Scenario: download a public shared file with range Given user "user0" exists