diff --git a/tests/acceptance/features/apiFederation/federated.feature b/tests/acceptance/features/apiFederation/federated.feature index cd01217a8462..8a27e853562b 100644 --- a/tests/acceptance/features/apiFederation/federated.feature +++ b/tests/acceptance/features/apiFederation/federated.feature @@ -864,6 +864,130 @@ Feature: federated And using server "LOCAL" Then as "user1" file "/CHILD/newRandomFolder/RandomFolder/newFile" should exist And the content of file "/CHILD/newRandomFolder/RandomFolder/file-to-share" for user "user1" should be "theContentIsChanged" + Examples: + | ocs-api-version | + | 1 | + | 2 | + + Scenario Outline: Both Incoming and Outgoing federation shares are allowed + Given parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And using OCS API version "" + And user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" + When user "user1" from server "LOCAL" shares "file-to-share" with user "user0" from server "REMOTE" using the sharing API + And user "user0" from server "REMOTE" accepts the last pending share using the sharing API + And using server "REMOTE" + Then as "user0" file "/file-to-share" should exist + And the content of file "/file-to-share" for user "user0" should be "thisContentIsVisible" + When user "user0" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API + And user "user0" from server "REMOTE" shares "/newFile" with user "user1" from server "LOCAL" using the sharing API + And using server "LOCAL" + When user "user1" from server "LOCAL" accepts the last pending share using the sharing API + Then as "user1" file "/newFile" should exist + And the content of file "/newFile" for user "user1" should be "thisFileIsShared" + Examples: + | ocs-api-version | + | 1 | + | 2 | + + Scenario Outline: Incoming federation shares are allowed but outgoing federation shares are restricted + Given parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "no" + And user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" + And using OCS API version "" + When user "user1" from server "LOCAL" shares "file-to-share" with user "user0" from server "REMOTE" using the sharing API + And using server "REMOTE" + Then user "user0" should not have any pending federated cloud share + And as "user0" file "/file-to-share" should not exist + When user "user0" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API + And user "user0" from server "REMOTE" shares "/newFile" with user "user1" from server "LOCAL" using the sharing API + And using server "LOCAL" + When user "user1" from server "LOCAL" accepts the last pending share using the sharing API + Then as "user1" file "/newFile" should exist + Examples: + | ocs-api-version | + | 1 | + | 2 | + + Scenario Outline: Incoming federation shares are restricted but outgoing federation shares are allowed + Given parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "no" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" + And using OCS API version "" + When user "user1" from server "LOCAL" shares "/file-to-share" with user "user0" from server "REMOTE" using the sharing API + And using server "REMOTE" + And user "user0" from server "REMOTE" accepts the last pending share using the sharing API + Then as "user0" file "/file-to-share" should exist + When user "user0" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API + And user "user0" from server "REMOTE" shares "/newFile" with user "user1" from server "LOCAL" using the sharing API + And using server "LOCAL" + Then user "user1" should not have any pending federated cloud share + And as "user1" file "/newFile" should not exist + Examples: + | ocs-api-version | + | 1 | + | 2 | + + Scenario Outline: Both Incoming and outgoing federation shares are restricted + Given parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "no" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "no" + And user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" + And using OCS API version "" + When user "user1" from server "LOCAL" shares "/file-to-share" with user "user0" from server "REMOTE" using the sharing API + And using server "REMOTE" + Then user "user0" should not have any pending federated cloud share + And as "user0" file "/file-to-share" should not exist + When user "user0" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API + And user "user0" from server "REMOTE" shares "/newFile" with user "user1" from server "LOCAL" using the sharing API + And using server "LOCAL" + Then user "user1" should not have any pending federated cloud share + And as "user1" file "/newFile" should not exist + Examples: + | ocs-api-version | + | 1 | + | 2 | + + Scenario Outline: Incoming and outgoing federation shares are enabled for local server but incoming federation shares are restricted for remote server + Given using server "REMOTE" + And parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "no" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And using server "LOCAL" + And parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" + And using OCS API version "" + When user "user1" from server "LOCAL" shares "/file-to-share" with user "user0" from server "REMOTE" using the sharing API + And using server "REMOTE" + Then user "user0" should not have any pending federated cloud share + And as "user0" file "/file-to-share" should not exist + When user "user0" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API + And user "user0" from server "REMOTE" shares "/newFile" with user "user1" from server "LOCAL" using the sharing API + And using server "LOCAL" + And user "user1" from server "LOCAL" accepts the last pending share using the sharing API + Then as "user1" file "/newFile" should exist + Examples: + | ocs-api-version | + | 1 | + | 2 | + + Scenario Outline: Incoming and outgoing federation shares are enabled for local server but outgoing federation shares are restricted for remote server + Given using server "REMOTE" + And parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "no" + And using server "LOCAL" + And parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "yes" + And user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" + And using OCS API version "" + When user "user1" from server "LOCAL" shares "/file-to-share" with user "user0" from server "REMOTE" using the sharing API + And using server "REMOTE" + And user "user0" from server "REMOTE" accepts the last pending share using the sharing API + Then as "user0" file "/file-to-share" should exist + When user "user0" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API + And user "user0" from server "REMOTE" shares "/newFile" with user "user1" from server "LOCAL" using the sharing API + And using server "LOCAL" + Then user "user1" should not have any pending federated cloud share + And as "user1" file "/newFile" should not exist Examples: | ocs-api-version | | 1 | diff --git a/tests/acceptance/features/bootstrap/FederationContext.php b/tests/acceptance/features/bootstrap/FederationContext.php index a7dce67002a3..375d94790cdd 100644 --- a/tests/acceptance/features/bootstrap/FederationContext.php +++ b/tests/acceptance/features/bootstrap/FederationContext.php @@ -25,6 +25,7 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use TestHelpers\SharingHelper; +use PHPUnit\Framework\Assert; require_once 'bootstrap.php'; @@ -202,6 +203,24 @@ public function userRetrievesInformationOfLastFederatedShare($user) { ); } + /** + * @Then user :user should not have any pending federated cloud share + * + * @param string $user + * + * @return void + */ + public function userShouldHaveNoLastPendingFederatedCloudShare($user) { + $this->userGetsTheListOfPendingFederatedCloudShares($user); + $responseXml = $this->featureContext->getResponseXml(); + $xmlPart = $responseXml->xpath("//data/element[last()]/id"); + Assert::assertTrue( + !\is_array($xmlPart) || (\count($xmlPart) === 0), + __METHOD__ + . " No pending federated cloud shares were expected, but got unexpectedly." + ); + } + /** * @When /^user "([^"]*)" retrieves the information of the last pending federated cloud share using the sharing API$/ *