From 94e03acf7db064f32622fe357e4ed7a1315ed5f9 Mon Sep 17 00:00:00 2001 From: jasson99 Date: Wed, 11 Mar 2020 15:03:39 +0545 Subject: [PATCH 1/3] [Tests-Only] Acceptance tests when incoming and outgoing federated share settings are enabled or disabled --- .../features/apiFederation/federated.feature | 124 ++++++++++++++++++ .../features/bootstrap/FederationContext.php | 19 +++ 2 files changed, 143 insertions(+) diff --git a/tests/acceptance/features/apiFederation/federated.feature b/tests/acceptance/features/apiFederation/federated.feature index cd01217a8462..123ab31e3b1e 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: Incoming and Outgoing federation shares are enabled + 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 user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" + And user "user1" from server "LOCAL" has shared "file-to-share" with user "user0" from server "REMOTE" + And user "user0" from server "REMOTE" has accepted the last pending share + And using OCS API version "" + When 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 enabled but outgoing federation shares are disabled + 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 have no last 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 disabled but outgoing federation shares are enabled + 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 have no last 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 disabled + 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 have no last 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 have no last 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 is disabled 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 have no last 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 is disabled 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 have no last 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..54fc36995a41 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 have no last 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$/ * From 8752cb6cb696c6ebabd4255680b00926d0826c25 Mon Sep 17 00:00:00 2001 From: jasson99 Date: Thu, 12 Mar 2020 09:54:45 +0545 Subject: [PATCH 2/3] requested changes made --- .../features/apiFederation/federated.feature | 32 +++++++++---------- .../features/bootstrap/FederationContext.php | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/acceptance/features/apiFederation/federated.feature b/tests/acceptance/features/apiFederation/federated.feature index 123ab31e3b1e..417770462950 100644 --- a/tests/acceptance/features/apiFederation/federated.feature +++ b/tests/acceptance/features/apiFederation/federated.feature @@ -869,14 +869,14 @@ Feature: federated | 1 | | 2 | - Scenario Outline: Incoming and Outgoing federation shares are enabled + 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 user "user1" has uploaded file with content "thisContentIsVisible" to "/file-to-share" - And user "user1" from server "LOCAL" has shared "file-to-share" with user "user0" from server "REMOTE" - And user "user0" from server "REMOTE" has accepted the last pending share And using OCS API version "" - When using server "REMOTE" + When user "user1" uploads file with content "thisContentIsVisible" to "/file-to-share" using the WebDAV API + And 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 @@ -890,14 +890,14 @@ Feature: federated | 1 | | 2 | - Scenario Outline: Incoming federation shares are enabled but outgoing federation shares are disabled + 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 have no last pending federated cloud share + 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 @@ -909,7 +909,7 @@ Feature: federated | 1 | | 2 | - Scenario Outline: Incoming federation shares are disabled but outgoing federation shares are enabled + 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" @@ -921,33 +921,33 @@ Feature: federated 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 have no last pending federated cloud share + 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 disabled + 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 have no last pending federated cloud share + 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 have no last pending federated cloud share + 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 is disabled for remote server + 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" @@ -958,7 +958,7 @@ Feature: federated 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 have no last pending federated cloud share + 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 @@ -970,7 +970,7 @@ Feature: federated | 1 | | 2 | - Scenario Outline: Incoming and outgoing federation shares are enabled for local server but outgoing federation shares is disabled for remote server + 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" @@ -986,7 +986,7 @@ Feature: federated 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 have no last pending federated cloud share + Then user "user1" should not have any pending federated cloud share And as "user1" file "/newFile" should not exist Examples: | ocs-api-version | diff --git a/tests/acceptance/features/bootstrap/FederationContext.php b/tests/acceptance/features/bootstrap/FederationContext.php index 54fc36995a41..375d94790cdd 100644 --- a/tests/acceptance/features/bootstrap/FederationContext.php +++ b/tests/acceptance/features/bootstrap/FederationContext.php @@ -204,7 +204,7 @@ public function userRetrievesInformationOfLastFederatedShare($user) { } /** - * @Then user :user should have no last pending federated cloud share + * @Then user :user should not have any pending federated cloud share * * @param string $user * From 568c66f87e9eec8251a62a3700f5d70cd3706fbc Mon Sep 17 00:00:00 2001 From: jasson99 Date: Thu, 12 Mar 2020 14:06:55 +0545 Subject: [PATCH 3/3] when steps changed to given as suggested --- tests/acceptance/features/apiFederation/federated.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/features/apiFederation/federated.feature b/tests/acceptance/features/apiFederation/federated.feature index 417770462950..8a27e853562b 100644 --- a/tests/acceptance/features/apiFederation/federated.feature +++ b/tests/acceptance/features/apiFederation/federated.feature @@ -873,8 +873,8 @@ Feature: federated 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 "" - When user "user1" uploads file with content "thisContentIsVisible" to "/file-to-share" using the WebDAV API - And user "user1" from server "LOCAL" shares "file-to-share" with user "user0" from server "REMOTE" using the sharing API + 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