From b78dcae1d491be99ec6dffa6705b2c987cb1393b Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 23 Nov 2016 09:43:55 +0000 Subject: [PATCH 1/5] WIP commit, adding report support Signed-off-by: Lukas Reschke --- .../integration/features/bootstrap/WebDav.php | 56 ++++++++++++++++++- build/integration/features/favorites.feature | 12 ++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 6438a871fb..f19ae1a86e 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -406,6 +406,40 @@ trait WebDav { return $response; } + /*Returns the elements of a report command*/ + public function reportFolder($user, $path, $properties = null){ + $client = $this->getSabreClient($user); + + $body = [ 'body' => ' + + + + + + + + + + + + + + + + + + + + + 1 + + ']; + + $response = $client->request('REPORT', $this->makeSabrePath($user, $path), $body); + + return $response; + } + public function makeSabrePath($user, $path) { return $this->encodePath($this->getDavFilesPath($user) . $path); } @@ -637,7 +671,6 @@ trait WebDav { $this->asGetsPropertiesOfFolderWith($user, 'entry', $path, $propertiesTable); $pathETAG[$path] = $this->response['{DAV:}getetag']; $this->storedETAG[$user]= $pathETAG; - print_r($this->storedETAG[$user][$path]); } /** @@ -681,4 +714,25 @@ trait WebDav { } } } + + /** + * @Then /^user "([^"]*)" in folder "([^"]*)" should have favorited the following elements$/ + * @param string $user + * @param string $folder + * @param \Behat\Gherkin\Node\TableNode|null $expectedElements + */ + public function checkFavoritedElements($user, $folder, $expectedElements){ + $elementList = $this->reportFolder($user, $folder); + if ($expectedElements instanceof \Behat\Gherkin\Node\TableNode) { + $elementRows = $expectedElements->getRows(); + $elementsSimplified = $this->simplifyArray($elementRows); + foreach($elementsSimplified as $expectedElement) { + $webdavPath = "/" . $this->getDavFilesPath($user) . $expectedElement; + if (!array_key_exists($webdavPath,$elementList)){ + PHPUnit_Framework_Assert::fail("$webdavPath" . " is not in report answer"); + } + } + } + } + } diff --git a/build/integration/features/favorites.feature b/build/integration/features/favorites.feature index 5e31e1902f..a2ee579436 100644 --- a/build/integration/features/favorites.feature +++ b/build/integration/features/favorites.feature @@ -78,3 +78,15 @@ Feature: favorite |{http://owncloud.org/ns}favorite| And the single response should contain a property "{http://owncloud.org/ns}favorite" with value "" + Scenario: Get favorited elements of a folder + Given using old dav path + And As an "admin" + And user "user0" exists + When user "user0" favorites element "/FOLDER" + And user "user0" favorites element "/textfile0.txt" + And user "user0" favorites element "/textfile1.txt" + Then user "user0" in folder "/" should have favorited the following elements + | /FOLDER | + | /textfile0.txt | + | /textfile1.txt | + From 02de82df91910ad8f206f379a5eeaee9fb332b74 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 23 Nov 2016 12:02:09 +0000 Subject: [PATCH 2/5] Fixed failing problems Signed-off-by: Lukas Reschke --- build/integration/features/bootstrap/WebDav.php | 8 ++++---- build/integration/features/favorites.feature | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index f19ae1a86e..9cb9d4a304 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -410,7 +410,7 @@ trait WebDav { public function reportFolder($user, $path, $properties = null){ $client = $this->getSabreClient($user); - $body = [ 'body' => ' + $body = ' @@ -433,11 +433,11 @@ trait WebDav { 1 - ']; + '; $response = $client->request('REPORT', $this->makeSabrePath($user, $path), $body); - - return $response; + $parsedResponse = $client->parseMultistatus($response['body']); + return $parsedResponse; } public function makeSabrePath($user, $path) { diff --git a/build/integration/features/favorites.feature b/build/integration/features/favorites.feature index a2ee579436..c00ed05eef 100644 --- a/build/integration/features/favorites.feature +++ b/build/integration/features/favorites.feature @@ -86,7 +86,7 @@ Feature: favorite And user "user0" favorites element "/textfile0.txt" And user "user0" favorites element "/textfile1.txt" Then user "user0" in folder "/" should have favorited the following elements - | /FOLDER | + | /FOLDER | | /textfile0.txt | | /textfile1.txt | From e76732c03aee9e63da245044a16c5cfe1b0cba20 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 23 Nov 2016 17:43:57 +0000 Subject: [PATCH 3/5] Added flexibility to properties Signed-off-by: Lukas Reschke --- .../integration/features/bootstrap/WebDav.php | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/build/integration/features/bootstrap/WebDav.php b/build/integration/features/bootstrap/WebDav.php index 9cb9d4a304..57ca638ec7 100644 --- a/build/integration/features/bootstrap/WebDav.php +++ b/build/integration/features/bootstrap/WebDav.php @@ -406,32 +406,22 @@ trait WebDav { return $response; } - /*Returns the elements of a report command*/ - public function reportFolder($user, $path, $properties = null){ + /* Returns the elements of a report command + * @param string $user + * @param string $path + * @param string $properties properties which needs to be included in the report + * @param string $filterRules filter-rules to choose what needs to appear in the report + */ + public function reportFolder($user, $path, $properties, $filterRules){ $client = $this->getSabreClient($user); $body = ' - - - - - - - - - - - - - - - - + ' . $properties . ' - 1 + ' . $filterRules . ' '; @@ -722,7 +712,10 @@ trait WebDav { * @param \Behat\Gherkin\Node\TableNode|null $expectedElements */ public function checkFavoritedElements($user, $folder, $expectedElements){ - $elementList = $this->reportFolder($user, $folder); + $elementList = $this->reportFolder($user, + $folder, + '', + '1'); if ($expectedElements instanceof \Behat\Gherkin\Node\TableNode) { $elementRows = $expectedElements->getRows(); $elementsSimplified = $this->simplifyArray($elementRows); From fbbd833ed1e8afde2b73334d3e2f86df303a4274 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Thu, 24 Nov 2016 12:00:56 +0000 Subject: [PATCH 4/5] Added more favorites report cases Signed-off-by: Lukas Reschke --- build/integration/features/favorites.feature | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/build/integration/features/favorites.feature b/build/integration/features/favorites.feature index c00ed05eef..ab6bf51f25 100644 --- a/build/integration/features/favorites.feature +++ b/build/integration/features/favorites.feature @@ -90,3 +90,47 @@ Feature: favorite | /textfile0.txt | | /textfile1.txt | + Scenario: Get favorited elements of a folder using new path + Given using new dav path + And As an "admin" + And user "user0" exists + When user "user0" favorites element "/FOLDER" + And user "user0" favorites element "/textfile0.txt" + And user "user0" favorites element "/textfile1.txt" + Then user "user0" in folder "/" should have favorited the following elements + | /FOLDER | + | /textfile0.txt | + | /textfile1.txt | + + Scenario: Get favorited elements of a subfolder + Given using old dav path + And As an "admin" + And user "user0" exists + And user "user0" created a folder "/subfolder" + And User "user0" moves file "/textfile0.txt" to "/subfolder/textfile0.txt" + And User "user0" moves file "/textfile1.txt" to "/subfolder/textfile1.txt" + And User "user0" moves file "/textfile2.txt" to "/subfolder/textfile2.txt" + When user "user0" favorites element "/subfolder/textfile0.txt" + And user "user0" favorites element "/subfolder/textfile1.txt" + And user "user0" favorites element "/subfolder/textfile2.txt" + And user "user0" unfavorites element "/subfolder/textfile1.txt" + Then user "user0" in folder "/subfolder" should have favorited the following elements + | /subfolder/textfile0.txt | + | /subfolder/textfile2.txt | + + Scenario: Get favorited elements of a subfolder using new path + Given using old dav path + And As an "admin" + And user "user0" exists + And user "user0" created a folder "/subfolder" + And User "user0" moves file "/textfile0.txt" to "/subfolder/textfile0.txt" + And User "user0" moves file "/textfile1.txt" to "/subfolder/textfile1.txt" + And User "user0" moves file "/textfile2.txt" to "/subfolder/textfile2.txt" + When user "user0" favorites element "/subfolder/textfile0.txt" + And user "user0" favorites element "/subfolder/textfile1.txt" + And user "user0" favorites element "/subfolder/textfile2.txt" + And user "user0" unfavorites element "/subfolder/textfile1.txt" + Then user "user0" in folder "/subfolder" should have favorited the following elements + | /subfolder/textfile0.txt | + | /subfolder/textfile2.txt | + From b0a3b2572454b9da0e48fa39d5a967d5b02fef94 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Thu, 24 Nov 2016 14:13:58 +0000 Subject: [PATCH 5/5] Added functionaly for not shared elements Signed-off-by: Lukas Reschke --- build/integration/features/bootstrap/TagsContext.php | 8 ++++---- build/integration/features/tags.feature | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build/integration/features/bootstrap/TagsContext.php b/build/integration/features/bootstrap/TagsContext.php index 91fb585d64..46ce869c86 100644 --- a/build/integration/features/bootstrap/TagsContext.php +++ b/build/integration/features/bootstrap/TagsContext.php @@ -516,13 +516,13 @@ class TagsContext implements \Behat\Behat\Context\Context { } /** - * @When :taggingUser adds the tag :tagName to :fileName shared by :sharingUser + * @When /^"([^"]*)" adds the tag "([^"]*)" to "([^"]*)" (shared|owned) by "([^"]*)"$/ * @param string $taggingUser * @param string $tagName * @param string $fileName * @param string $sharingUser */ - public function addsTheTagToSharedBy($taggingUser, $tagName, $fileName, $sharingUser) { + public function addsTheTagToSharedBy($taggingUser, $tagName, $fileName, $sharedOrOwnedBy, $sharingUser) { $fileId = $this->getFileIdForPath($fileName, $sharingUser); $tagId = $this->findTagIdByName($tagName); @@ -542,13 +542,13 @@ class TagsContext implements \Behat\Behat\Context\Context { } /** - * @Then :fileName shared by :sharingUser has the following tags + * @Then /^"([^"]*)" (shared|owned) by "([^"]*)" has the following tags$/ * @param string $fileName * @param string $sharingUser * @param TableNode $table * @throws \Exception */ - public function sharedByHasTheFollowingTags($fileName, $sharingUser, TableNode $table) { + public function sharedByHasTheFollowingTags($fileName, $sharedOrOwnedBy, $sharingUser, TableNode $table) { $loadedExpectedTags = $table->getTable(); $expectedTags = []; foreach($loadedExpectedTags as $expected) { diff --git a/build/integration/features/tags.feature b/build/integration/features/tags.feature index d793c0d3c6..3578441908 100644 --- a/build/integration/features/tags.feature +++ b/build/integration/features/tags.feature @@ -425,3 +425,12 @@ Feature: tags Then The response should have a status code "201" And the user "user0" cannot assign the "not user-assignable" tag with name "TagWithGroups" + Scenario: Assign a normal tag to a file + Given user "user0" exists + And "admin" creates a "normal" tag with name "Etiqueta" + And As an "user0" + When "user0" adds the tag "Etiqueta" to "/textfile0.txt" owned by "user0" + Then The response should have a status code "201" + And "textfile0.txt" owned by "user0" has the following tags + | Etiqueta | +