From 798aff761dce3840c0f0558b333a1c7d3e4373d0 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Wed, 24 Aug 2022 11:34:39 +0545 Subject: [PATCH 1/3] Update expected to failure for local api for lock properties --- .../expected-failures-localAPI-on-OCIS-storage.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index bf78a60bf5a..b88b3880288 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -33,3 +33,13 @@ The expected failures in this file are from features in the owncloud/ocis repo. ### [PROPFIND on accepted shares with identical names containing brackets exit with 404](https://github.com/owncloud/ocis/issues/4421) - [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12) + +#### [Webdav LOCK operations](https://github.com/owncloud/ocis/issues/1284) +- [apiSpaces/lockSpaces.feature:31](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L31) +- [apiSpaces/lockSpaces.feature:32](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L32) +- [apiSpaces/lockSpaces.feature:52](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L52) +- [apiSpaces/lockSpaces.feature:53](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L53) +- [apiSpaces/lockSpaces.feature:73](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L73) +- [apiSpaces/lockSpaces.feature:74](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L74) +- [apiSpaces/lockSpaces.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L91) +- [apiSpaces/lockSpaces.feature:92](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L92) From d7104d469c146c1d3f8873ca44bf4a9fd663492b Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Wed, 24 Aug 2022 11:45:46 +0545 Subject: [PATCH 2/3] Added /Shares related to lock prop --- .../features/apiSpaces/lockSpaces.feature | 92 ++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 97 ++++++++++++++++++- 2 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 tests/acceptance/features/apiSpaces/lockSpaces.feature diff --git a/tests/acceptance/features/apiSpaces/lockSpaces.feature b/tests/acceptance/features/apiSpaces/lockSpaces.feature new file mode 100644 index 00000000000..a91deeb1ddb --- /dev/null +++ b/tests/acceptance/features/apiSpaces/lockSpaces.feature @@ -0,0 +1,92 @@ +@api @skipOnOcV10 +Feature: lock + # Note: This Feature includes all the tests from core (apiWebdavLock suite) related to /Shares since in core no implementation is there for space Shares Jail + + Background: + Given these users have been created with default attributes and without skeleton files: + | username | + | Alice | + | Brian | + | Carol | + And user "Alice" has created folder "PARENT" + And user "Brian" has created folder "PARENT" + And user "Carol" has created folder "PARENT" + And using spaces DAV path + + + Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the owner + Given user "Alice" has shared folder "PARENT" with user "Brian" + And user "Brian" has accepted share "/PARENT" offered by user "Alice" + And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Carol" has accepted share "/PARENT" offered by user "Brian" + And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties + | lockscope | | + When user "Carol" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API + And user "Brian" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API + And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API + Then the HTTP status code of responses on all endpoints should be "423" + And as "Alice" file "/PARENT/textfile.txt" should not exist + Examples: + | lock-scope | + | shared | + | exclusive | + + + Scenario Outline: lock should propagate correctly when uploaded overwriting to a reshare that was locked by the owner + Given user "Alice" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt" + And user "Brian" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt" + And user "Carol" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt" + And user "Alice" has shared folder "PARENT" with user "Brian" + And user "Brian" has accepted share "/PARENT" offered by user "Alice" + And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Carol" has accepted share "/PARENT" offered by user "Brian" + And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties + | lockscope | | + When user "Carol" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/parent.txt" using the WebDAV API + And user "Brian" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/parent.txt" using the WebDAV API + And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/parent.txt" using the WebDAV API + Then the HTTP status code of responses on all endpoints should be "423" + And the content of file "/PARENT/parent.txt" for user "Alice" should be "ownCloud test text file parent" + Examples: + | lock-scope | + | shared | + | exclusive | + + + Scenario Outline: lock should propagate correctly when the public uploads to a reshared share that was locked by the original owner + Given user "Alice" has shared folder "PARENT" with user "Brian" + And user "Brian" has accepted share "/PARENT" offered by user "Alice" + And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Carol" has accepted share "/PARENT" offered by user "Brian" + And user "Carol" has created a public link share inside of space "Shares Jail" with settings: + | path | PARENT | + | shareType | 3 | + | permissions | 15 | + | name | public link | + And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties + | lockscope | | + When the public uploads file "test.txt" with content "test" using the new public WebDAV API + Then the HTTP status code should be "423" + And as "Alice" file "/PARENT/textfile.txt" should not exist + Examples: + | lock-scope | + | shared | + | exclusive | + + + Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the resharing user + Given user "Alice" has shared folder "PARENT" with user "Brian" + And user "Brian" has accepted share "/PARENT" offered by user "Alice" + And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Carol" has accepted share "/PARENT" offered by user "Brian" + And user "Brian" has locked folder "/PARENT" inside space "Shares Jail" setting the following properties + | lockscope | | + When user "Carol" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API + And user "Brian" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API + And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API + Then the HTTP status code of responses on all endpoints should be "423" + And as "Alice" file "/PARENT/textfile.txt" should not exist + Examples: + | lock-scope | + | shared | + | exclusive | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 9233a7ed404..b52b9977cf1 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -97,6 +97,12 @@ class SpacesContext implements Context { */ private $storedEtags = []; + /** + * + * @var string[][] + */ + private $tokenOfLastLock = []; + private $etagPropfindBody = '' . 'sendDeleteSpaceRequest($userName, $value["name"]); } - } + } } } } @@ -1565,6 +1571,42 @@ public function theUserUploadsAFileToSpace( ); } + /** + * @When /^user "([^"]*)" uploads a file "([^"]*)" inside space "([^"]*)" to "([^"]*)" using the WebDAV API$/ + * + * @param string $user + * @param string $source + * @param string $spaceName + * @param string $destination + * + * @return void + * @throws GuzzleException + * @throws Exception + */ + public function theUserUploadsSpecificFileToSpace( + string $user, + string $source, + string $spaceName, + string $destination + ): void { + $space = $this->getSpaceByName($user, $spaceName); + $file = \fopen($this->featureContext->acceptanceTestsDirLocation() . $source, 'r'); + $this->featureContext->setResponse( + HttpRequestHelper::sendRequest( + $space["root"]["webDavUrl"] . "/" . $destination, + "", + 'PUT', + $user, + $this->featureContext->getPasswordForUser($user), + [], + $file + ) + ); + $this->featureContext->pushToLastHttpStatusCodesArray( + (string) $this->featureContext->getResponse()->getStatusCode() + ); + } + /** * @When /^user "([^"]*)" uploads a file inside space "([^"]*)" owned by the user "([^"]*)" with content "([^"]*)" to "([^"]*)" using the WebDAV API$/ * @@ -3016,6 +3058,59 @@ public function userHasStoredEtagOfElementOnPathFromSpace($user, $path, $storePa } } + /** + * @Given /^user "([^"]*)" has locked folder "([^"]*)" inside space "([^"]*)" setting the following properties$/ + * + * @param string $user + * @param string $resource + * @param TableNode $properties + * @param string $spaceName + * + * @throws Exception | GuzzleException + */ + public function userHasLockedResourceOfSpace(string $user, string $resource, TableNode $properties, string $spaceName) { + $body + = "" . + " "; + $headers = []; + $this->featureContext->verifyTableNodeRows($properties, [], ['lockscope', 'depth', 'timeout']); + $propertiesRows = $properties->getRowsHash(); + foreach ($propertiesRows as $property => $value) { + if ($property === "depth" || $property === "timeout") { + //properties that are set in the header not in the xml + $headers[$property] = $value; + } else { + $body .= ""; + } + } + $body .= ""; + $space = $this->getSpaceByName($user, $spaceName); + $fullUrl = $space['root']['webDavUrl'] . '/' . ltrim($resource, '/'); + $this->featureContext->setResponse( + HttpRequestHelper::sendRequest( + $fullUrl, + "", + 'LOCK', + $user, + $this->featureContext->getPasswordForUser($user), + [], + $body + ) + ); + $this->featureContext->theHTTPStatusCodeShouldBe( + 200, + __METHOD__ . " Failed to lock the resource $resource" + ); + $responseXml = $this->featureContext->getResponseXml(null, __METHOD__); + $this->featureContext->setResponseXmlObject($responseXml); + $xmlPart = $responseXml->xpath("//d:locktoken/d:href"); + if (\is_array($xmlPart) && isset($xmlPart[0])) { + $this->tokenOfLastLock[$user][$resource] = (string) $xmlPart[0]; + } else { + Assert::fail("could not find lock token after trying to lock '$resource'"); + } + } + /** * @When /^user "([^"]*)" creates a public link share of the space "([^"]*)" with settings:$/ * From f12aa29d1ad15d821f046a543b48de98c606ff26 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Mon, 29 Aug 2022 16:05:25 +0545 Subject: [PATCH 3/3] PR review Address --- ...ected-failures-localAPI-on-OCIS-storage.md | 12 +- .../features/apiSpaces/lockSpaces.feature | 24 +- .../features/bootstrap/SpacesContext.php | 208 ++++++++++-------- 3 files changed, 131 insertions(+), 113 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index b88b3880288..af6078526ab 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -37,9 +37,9 @@ The expected failures in this file are from features in the owncloud/ocis repo. #### [Webdav LOCK operations](https://github.com/owncloud/ocis/issues/1284) - [apiSpaces/lockSpaces.feature:31](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L31) - [apiSpaces/lockSpaces.feature:32](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L32) -- [apiSpaces/lockSpaces.feature:52](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L52) -- [apiSpaces/lockSpaces.feature:53](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L53) -- [apiSpaces/lockSpaces.feature:73](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L73) -- [apiSpaces/lockSpaces.feature:74](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L74) -- [apiSpaces/lockSpaces.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L91) -- [apiSpaces/lockSpaces.feature:92](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L92) +- [apiSpaces/lockSpaces.feature:50](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L50) +- [apiSpaces/lockSpaces.feature:51](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L51) +- [apiSpaces/lockSpaces.feature:71](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L71) +- [apiSpaces/lockSpaces.feature:72](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L72) +- [apiSpaces/lockSpaces.feature:89](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L89) +- [apiSpaces/lockSpaces.feature:90](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L90) diff --git a/tests/acceptance/features/apiSpaces/lockSpaces.feature b/tests/acceptance/features/apiSpaces/lockSpaces.feature index a91deeb1ddb..f0ae101f1f8 100644 --- a/tests/acceptance/features/apiSpaces/lockSpaces.feature +++ b/tests/acceptance/features/apiSpaces/lockSpaces.feature @@ -17,12 +17,12 @@ Feature: lock Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the owner Given user "Alice" has shared folder "PARENT" with user "Brian" And user "Brian" has accepted share "/PARENT" offered by user "Alice" - And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor" And user "Carol" has accepted share "/PARENT" offered by user "Brian" And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties | lockscope | | - When user "Carol" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API - And user "Brian" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API + When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API + And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API Then the HTTP status code of responses on all endpoints should be "423" And as "Alice" file "/PARENT/textfile.txt" should not exist @@ -34,16 +34,14 @@ Feature: lock Scenario Outline: lock should propagate correctly when uploaded overwriting to a reshare that was locked by the owner Given user "Alice" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt" - And user "Brian" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt" - And user "Carol" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt" And user "Alice" has shared folder "PARENT" with user "Brian" And user "Brian" has accepted share "/PARENT" offered by user "Alice" - And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor" And user "Carol" has accepted share "/PARENT" offered by user "Brian" And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties | lockscope | | - When user "Carol" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/parent.txt" using the WebDAV API - And user "Brian" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/parent.txt" using the WebDAV API + When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API + And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/parent.txt" using the WebDAV API Then the HTTP status code of responses on all endpoints should be "423" And the content of file "/PARENT/parent.txt" for user "Alice" should be "ownCloud test text file parent" @@ -56,7 +54,7 @@ Feature: lock Scenario Outline: lock should propagate correctly when the public uploads to a reshared share that was locked by the original owner Given user "Alice" has shared folder "PARENT" with user "Brian" And user "Brian" has accepted share "/PARENT" offered by user "Alice" - And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor" And user "Carol" has accepted share "/PARENT" offered by user "Brian" And user "Carol" has created a public link share inside of space "Shares Jail" with settings: | path | PARENT | @@ -67,7 +65,7 @@ Feature: lock | lockscope | | When the public uploads file "test.txt" with content "test" using the new public WebDAV API Then the HTTP status code should be "423" - And as "Alice" file "/PARENT/textfile.txt" should not exist + And as "Alice" file "/PARENT/test.txt" should not exist Examples: | lock-scope | | shared | @@ -77,12 +75,12 @@ Feature: lock Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the resharing user Given user "Alice" has shared folder "PARENT" with user "Brian" And user "Brian" has accepted share "/PARENT" offered by user "Alice" - And user "Brian" has shared folder "Shares/PARENT" with user "Carol" + And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor" And user "Carol" has accepted share "/PARENT" offered by user "Brian" And user "Brian" has locked folder "/PARENT" inside space "Shares Jail" setting the following properties | lockscope | | - When user "Carol" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API - And user "Brian" uploads a file "filesForUpload/textfile.txt" inside space "Shares Jail" to "PARENT/textfile.txt" using the WebDAV API + When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API + And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API Then the HTTP status code of responses on all endpoints should be "423" And as "Alice" file "/PARENT/textfile.txt" should not exist diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index b52b9977cf1..2ac2f655e71 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -702,27 +702,27 @@ public function sendCreateFolderRequest( return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, $method, $user, $password, $headers); } - /** - * send proppatch request to url - * @param string $fullUrl - * @param string $user - * @param string $password - * @param string $xRequestId - * @param array $headers - * @param mixed|null $body - * @return ResponseInterface - */ - public function sendPropPatchRequest( - string $fullUrl, - string $user, - string $password, - string $xRequestId = '', - array $headers = [], - $body - ): ResponseInterface - { - return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PROPPATCH', $user, $password, $headers, $body); - } + /** + * send proppatch request to url + * + * @param string $fullUrl + * @param string $user + * @param string $password + * @param string $xRequestId + * @param array $headers + * @param mixed|null $body + * @return ResponseInterface + */ + public function sendPropPatchRequest( + string $fullUrl, + string $user, + string $password, + string $xRequestId = '', + array $headers = [], + $body + ): ResponseInterface { + return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PROPPATCH', $user, $password, $headers, $body); + } /** * @When /^user "([^"]*)" lists all available spaces via the GraphApi$/ @@ -1571,42 +1571,6 @@ public function theUserUploadsAFileToSpace( ); } - /** - * @When /^user "([^"]*)" uploads a file "([^"]*)" inside space "([^"]*)" to "([^"]*)" using the WebDAV API$/ - * - * @param string $user - * @param string $source - * @param string $spaceName - * @param string $destination - * - * @return void - * @throws GuzzleException - * @throws Exception - */ - public function theUserUploadsSpecificFileToSpace( - string $user, - string $source, - string $spaceName, - string $destination - ): void { - $space = $this->getSpaceByName($user, $spaceName); - $file = \fopen($this->featureContext->acceptanceTestsDirLocation() . $source, 'r'); - $this->featureContext->setResponse( - HttpRequestHelper::sendRequest( - $space["root"]["webDavUrl"] . "/" . $destination, - "", - 'PUT', - $user, - $this->featureContext->getPasswordForUser($user), - [], - $file - ) - ); - $this->featureContext->pushToLastHttpStatusCodesArray( - (string) $this->featureContext->getResponse()->getStatusCode() - ); - } - /** * @When /^user "([^"]*)" uploads a file inside space "([^"]*)" owned by the user "([^"]*)" with content "([^"]*)" to "([^"]*)" using the WebDAV API$/ * @@ -2177,7 +2141,7 @@ public function sendShareSpaceRequest( } /** - * @When /^user "([^"]*)" shares the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/ + * Request to send share of resource inside of space * * @param string $user * @param string $entity @@ -2188,13 +2152,7 @@ public function sendShareSpaceRequest( * @return void * @throws GuzzleException */ - public function sendShareEntityInsideOfSpaceRequest( - string $user, - string $entity, - string $spaceName, - string $userRecipient, - string $role - ): void { + public function sendRequestForShareOfEntityInsideOfSpace(string $user, string $entity, string $spaceName, string $userRecipient, string $role):void { $space = $this->getSpaceByName($user, $spaceName); $body = [ "space_ref" => $space['id'] . "/" . $entity, @@ -2216,6 +2174,54 @@ public function sendShareEntityInsideOfSpaceRequest( $this->setLastShareData(); } + /** + * @When /^user "([^"]*)" shares the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/ + * + * @param string $user + * @param string $entity + * @param string $spaceName + * @param string $userRecipient + * @param string $role + * + * @return void + * @throws GuzzleException + */ + public function sharesTheFollowingEntityInsideOfSpace( + string $user, + string $entity, + string $spaceName, + string $userRecipient, + string $role + ): void { + $this->sendRequestForShareOfEntityInsideOfSpace($user, $entity, $spaceName, $userRecipient, $role); + } + + /** + * @Given /^user "([^"]*)" has shared the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/ + * + * @param string $user + * @param string $entity + * @param string $spaceName + * @param string $userRecipient + * @param string $role + * + * @return void + * @throws GuzzleException + */ + public function hasSharedTheFollowingEntityInsideOfSpace( + string $user, + string $entity, + string $spaceName, + string $userRecipient, + string $role + ): void { + $this->sendRequestForShareOfEntityInsideOfSpace($user, $entity, $spaceName, $userRecipient, $role); + $this->featureContext->theHTTPStatusCodeShouldBe( + 200, + "Expected response status code should be 200" + ); + } + /** * @When /^user "([^"]*)" creates a public link share inside of space "([^"]*)" with settings:$/ * @@ -3059,16 +3065,17 @@ public function userHasStoredEtagOfElementOnPathFromSpace($user, $path, $storePa } /** - * @Given /^user "([^"]*)" has locked folder "([^"]*)" inside space "([^"]*)" setting the following properties$/ + * Request to lock the resource inside of space * * @param string $user * @param string $resource * @param TableNode $properties * @param string $spaceName * - * @throws Exception | GuzzleException + * @return void + * @throws GuzzleException */ - public function userHasLockedResourceOfSpace(string $user, string $resource, TableNode $properties, string $spaceName) { + public function sendRequestToLockResouceInsideOfSpace(string $user, string $resource, TableNode $properties, string $spaceName):void { $body = "" . " "; @@ -3111,6 +3118,20 @@ public function userHasLockedResourceOfSpace(string $user, string $resource, Tab } } + /** + * @Given /^user "([^"]*)" has locked folder "([^"]*)" inside space "([^"]*)" setting the following properties$/ + * + * @param string $user + * @param string $resource + * @param TableNode $properties + * @param string $spaceName + * + * @throws Exception | GuzzleException + */ + public function userHasLockedResourceOfSpace(string $user, string $resource, TableNode $properties, string $spaceName) { + $this->sendRequestToLockResouceInsideOfSpace($user, $resource, $properties, $spaceName); + } + /** * @When /^user "([^"]*)" creates a public link share of the space "([^"]*)" with settings:$/ * @@ -3320,21 +3341,20 @@ public function asUserFileInsideSpaceShouldContainAPropertyWithValue( ); } - /** - * @When /^user "([^"]*)" favorites element "([^"]*)" in space "([^"]*)" using the WebDAV API$/ - * - * @param string $user - * @param string $path - * @param string $spaceName - * - * @return void - * @throws GuzzleException - */ - public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void - { - $space = $this->getSpaceByName($user, $spaceName); - $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/"); - $body = ' + /** + * @When /^user "([^"]*)" favorites element "([^"]*)" in space "([^"]*)" using the WebDAV API$/ + * + * @param string $user + * @param string $path + * @param string $spaceName + * + * @return void + * @throws GuzzleException + */ + public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void { + $space = $this->getSpaceByName($user, $spaceName); + $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/"); + $body = ' @@ -3343,15 +3363,15 @@ public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, strin '; - $this->featureContext->setResponse( - $this->sendProppatchRequest( - $fullUrl, - $user, - $this->featureContext->getPasswordForUser($user), - $this->featureContext->getStepLineRef(), - [], - $body - ) - ); - } + $this->featureContext->setResponse( + $this->sendProppatchRequest( + $fullUrl, + $user, + $this->featureContext->getPasswordForUser($user), + $this->featureContext->getStepLineRef(), + [], + $body + ) + ); + } }