From 586f5608a46d1946dc7d8fa91e8ec8fbb5733a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Bertol=C3=ADn?= Date: Tue, 30 Aug 2016 06:47:39 +0000 Subject: [PATCH 1/2] Orphaned shares test and some requirements --- .../features/bootstrap/BasicStructure.php | 31 +++++++++++++++++++ .../integration/features/bootstrap/WebDav.php | 2 +- build/integration/features/sharing-v1.feature | 18 +++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/BasicStructure.php b/build/integration/features/bootstrap/BasicStructure.php index 4ca2c56e9d7f..708a74c1d576 100644 --- a/build/integration/features/bootstrap/BasicStructure.php +++ b/build/integration/features/bootstrap/BasicStructure.php @@ -145,6 +145,27 @@ public function sendingToWith($verb, $url, $body) { } } + public function sendingToWithDirectUrl($verb, $url, $body) { + $fullUrl = substr($this->baseUrl, 0, -5) . $url; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$this->currentUser, $this->regularUser]; + } + if ($body instanceof \Behat\Gherkin\Node\TableNode) { + $fd = $body->getRowsHash(); + $options['body'] = $fd; + } + + try { + $this->response = $client->send($client->createRequest($verb, $fullUrl, $options)); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + } + } + public function isExpectedUrl($possibleUrl, $finalPart){ $baseUrlChopped = substr($this->baseUrl, 0, -4); $endCharacter = strlen($baseUrlChopped) + strlen($finalPart); @@ -271,6 +292,16 @@ public function modifyTextOfFile($user, $filename, $text) { file_put_contents("../../data/$user/files" . "$filename", "$text"); } + /** + * @When User :user empties trashbin + * @param string $user + */ + public function emptyTrashbin($user) { + $body = new \Behat\Gherkin\Node\TableNode([['allfiles', 'true'], ['dir', '%2F']]); + $this->sendingToWithDirectUrl('POST', "/index.php/apps/files_trashbin/ajax/delete.php", $body); + $this->theHTTPStatusCodeShouldBe('200'); + } + /** * @BeforeSuite */ diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index a63b752a0151..71cfa6624c41 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -415,7 +415,7 @@ public function userUploadsAFileWithContentTo($user, $content, $destination) } /** - * @When User :user deletes file :file + * @When User :user deletes (file|folder) :file * @param string $user * @param string $file */ diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature index 0faf5f516d3e..49f4830e86fc 100644 --- a/build/integration/features/sharing-v1.feature +++ b/build/integration/features/sharing-v1.feature @@ -868,3 +868,21 @@ Feature: sharing And the single response should contain a property "{http://owncloud.org/ns}permissions" with value "SRDNVCK" And as "user1" the folder "merge-test-outside-groups-renamebeforesecondshare" does not exist + Scenario: Empting trashbin + Given As an "admin" + And user "user0" exists + And User "user0" deletes file "/textfile0.txt" + When User "user0" empties trashbin + Then the HTTP status code should be "200" + + Scenario: orphaned shares + Given As an "admin" + And user "user0" exists + And user "user1" exists + And user "user0" created a folder "/common" + And user "user0" created a folder "/common/sub" + And file "/common/sub" of user "user0" is shared with user "user1" + And User "user0" deletes folder "/common" + When User "user0" empties trashbin + Then as "user1" the folder "sub" does not exist + From 744328824429c56788b3b415ea1ec67d315d3eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Bertol=C3=ADn?= Date: Tue, 30 Aug 2016 09:28:27 +0000 Subject: [PATCH 2/2] Adding type parameter because behat cannot ignore it --- build/integration/features/bootstrap/WebDav.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 71cfa6624c41..4ef73cb20018 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -415,11 +415,12 @@ public function userUploadsAFileWithContentTo($user, $content, $destination) } /** - * @When User :user deletes (file|folder) :file + * @When /^User "([^"]*)" deletes (file|folder) "([^"]*)"$/ * @param string $user + * @param string $type * @param string $file */ - public function userDeletesFile($user, $file) { + public function userDeletesFile($user, $type, $file) { try { $this->response = $this->makeDavRequest($user, 'DELETE', $file, []); } catch (\GuzzleHttp\Exception\ServerException $e) {