diff --git a/tests/acceptance/features/apiFederation/federated.feature b/tests/acceptance/features/apiFederation/federated.feature index 97983d71a3dc..df64f80452a7 100644 --- a/tests/acceptance/features/apiFederation/federated.feature +++ b/tests/acceptance/features/apiFederation/federated.feature @@ -200,6 +200,76 @@ Feature: federated And the content of file "/PARENT (2)/textfile0.txt" for user "user1" should be "AAAAABBBBBCCCCC" And the content of file "/PARENT/textfile0.txt" for user "user0" on server "REMOTE" should be "AAAAABBBBBCCCCC" + Scenario: Remote sharee deletes an accepted federated share + Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL" + And user "user1" from server "LOCAL" has accepted the last pending share + When user "user1" deletes the last federated cloud share using the sharing API + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "user1" should not see the following elements + | /textfile0%20(2).txt | + When user "user1" gets the list of federated cloud shares using the sharing API + Then the response should contain 0 entries + When user "user1" gets the list of pending federated cloud shares using the sharing API + Then the response should contain 0 entries + + Scenario: Remote sharee tries to delete an accepted federated share sending wrong password + Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL" + And user "user1" from server "LOCAL" has accepted the last pending share + When user "user1" deletes the last federated cloud share with password "invalid" using the sharing API + Then the OCS status code should be "997" + And the HTTP status code should be "401" + And user "user1" should see the following elements + | /textfile0%20(2).txt | + When user "user1" gets the list of federated cloud shares using the sharing API + And the fields of the last response should include + | id | A_NUMBER | + | remote | REMOTE | + | remote_id | A_NUMBER | + | share_token | A_TOKEN | + | name | /textfile0.txt | + | owner | user0 | + | user | user1 | + | mountpoint | /textfile0 (2).txt | + | accepted | 1 | + | type | file | + | permissions | 27 | + When user "user1" gets the list of pending federated cloud shares using the sharing API + Then the response should contain 0 entries + + Scenario: Remote sharee deletes a pending federated share + Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL" + When user "user1" deletes the last pending federated cloud share using the sharing API + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "user1" should not see the following elements + | /textfile0%20(2).txt | + When user "user1" gets the list of federated cloud shares using the sharing API + Then the response should contain 0 entries + When user "user1" gets the list of pending federated cloud shares using the sharing API + Then the response should contain 0 entries + + Scenario: Remote sharee tries to delete a pending federated share sending wrong password + Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL" + When user "user1" deletes the last pending federated cloud share with password "invalid" using the sharing API + Then the OCS status code should be "997" + And the HTTP status code should be "401" + And user "user1" should not see the following elements + | /textfile0%20(2).txt | + When user "user1" gets the list of pending federated cloud shares using the sharing API + And the fields of the last response should include + | id | A_NUMBER | + | remote | REMOTE | + | remote_id | A_NUMBER | + | share_token | A_TOKEN | + | name | /textfile0.txt | + | owner | user0 | + | user | user1 | + | mountpoint | {{TemporaryMountPointName#/textfile0.txt}} | + | accepted | 0 | + When user "user1" gets the list of federated cloud shares using the sharing API + Then the response should contain 0 entries + Scenario: Trusted server handshake does not require authenticated requests - we force 403 by sending an empty body Given using server "LOCAL" And using OCS API version "2" diff --git a/tests/acceptance/features/bootstrap/FederationContext.php b/tests/acceptance/features/bootstrap/FederationContext.php index ea6f0defe3f1..79a14728981c 100644 --- a/tests/acceptance/features/bootstrap/FederationContext.php +++ b/tests/acceptance/features/bootstrap/FederationContext.php @@ -141,12 +141,7 @@ public function userFromServerHasAcceptedLastPendingShare($user, $server) { * @return void */ public function userRetrievesInformationOfLastFederatedShare($user) { - $this->featureContext->userSendsHTTPMethodToOcsApiEndpointWithBody( - $user, - 'GET', - "/apps/files_sharing/api/v1/remote_shares", - null - ); + $this->userGetsTheListOfFederatedCloudShares($user); $this->featureContext->theHTTPStatusCodeShouldBe('200'); $this->featureContext->theOCSStatusCodeShouldBe('100'); $share_id = SharingHelper::getLastShareIdFromResponse( @@ -199,6 +194,54 @@ public function userGetsTheListOfPendingFederatedCloudShares($user) { ); } + /** + * @When /^user "([^"]*)" gets the list of federated cloud shares using the sharing API$/ + * + * @param string $user + * + * @return void + */ + public function userGetsTheListOfFederatedCloudShares($user) { + $this->featureContext->userSendsHTTPMethodToOcsApiEndpointWithBody( + $user, 'GET', "/apps/files_sharing/api/v1/remote_shares" + ); + } + + /** + * + * @When /^user "([^"]*)" deletes the last (pending|)\s?federated cloud share using the sharing API$/ + * @When /^user "([^"]*)" deletes the last (pending|)\s?federated cloud share with password "([^"]*)" using the sharing API$/ + * + * @param string $user + * @param string $shareType "pending" or empty string + * @param string $password + * + * @return void + */ + public function userDeletesLastFederatedCloudShare( + $user, $shareType, $password = null + ) { + if ($shareType === "pending") { + $this->userGetsTheListOfPendingFederatedCloudShares($user); + } else { + $this->userGetsTheListOfFederatedCloudShares($user); + } + $this->featureContext->theHTTPStatusCodeShouldBe('200'); + $this->featureContext->theOCSStatusCodeShouldBe('100'); + $share_id = SharingHelper::getLastShareIdFromResponse( + $this->featureContext->getResponseXml() + ); + if ($shareType === "pending") { + $url = "/apps/files_sharing/api/v1/remote_shares/pending/$share_id"; + } else { + $url = "/apps/files_sharing/api/v1/remote_shares/$share_id"; + } + + $this->featureContext->userSendsHTTPMethodToOcsApiEndpointWithBody( + $user, 'DELETE', $url, null, $password + ); + } + /** * @When /^user "([^"]*)" requests shared secret using the federation API$/ *