From 7b26133d1daecf05afffffe11507f3a58c214858 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Fri, 22 Apr 2022 12:26:15 +0545 Subject: [PATCH] Improve then step for suite apiFederationToRoot2 --- .../apiFederationToRoot2/federated.feature | 153 +++++++++++------- .../features/bootstrap/FederationContext.php | 19 +++ .../acceptance/features/bootstrap/WebDav.php | 4 +- 3 files changed, 118 insertions(+), 58 deletions(-) diff --git a/tests/acceptance/features/apiFederationToRoot2/federated.feature b/tests/acceptance/features/apiFederationToRoot2/federated.feature index fe8035c8a75c..f64570bc05fd 100644 --- a/tests/acceptance/features/apiFederationToRoot2/federated.feature +++ b/tests/acceptance/features/apiFederationToRoot2/federated.feature @@ -40,8 +40,10 @@ Feature: federated And the trusted server list is cleared And parameter "autoAddServers" of app "federation" has been set to "1" When user "Alice" from server "REMOTE" shares "/textfile1.txt" with user "Brian" from server "LOCAL" using the sharing API - And user "Brian" from server "LOCAL" has accepted the last pending share - And using server "LOCAL" + And user "Brian" from server "LOCAL" accepts the last pending share + Then the OCS status code of responses on all endpoints should be "100" + And the HTTP status code of responses on all endpoints should be "200" + When using server "LOCAL" Then as "Brian" file "textfile1.txt" should exist And url "%remote_server%" should be a trusted server @@ -52,8 +54,10 @@ Feature: federated And the trusted server list is cleared And parameter "autoAddServers" of app "federation" has been set to "0" When user "Alice" from server "REMOTE" shares "/textfile1.txt" with user "Brian" from server "LOCAL" using the sharing API - And user "Brian" from server "LOCAL" has accepted the last pending share - And using server "LOCAL" + And user "Brian" from server "LOCAL" accepts the last pending share + Then the OCS status code of responses on all endpoints should be "100" + And the HTTP status code of responses on all endpoints should be "200" + When using server "LOCAL" Then as "Brian" file "textfile1.txt" should exist And url "%remote_server%" should not be a trusted server @@ -66,7 +70,7 @@ Feature: federated And parameter "autoAddServers" of app "federation" has been set to "1" And parameter "auto_accept_trusted" of app "federatedfilesharing" has been set to "yes" When user "Alice" from server "REMOTE" shares "/textfile0.txt" with user "Brian" from server "LOCAL" using the sharing API - And user "Brian" from server "LOCAL" has accepted the last pending share + And user "Brian" from server "LOCAL" accepts the last pending share And using server "LOCAL" Then url "%remote_server%" should be a trusted server When user "Alice" from server "REMOTE" shares "/textfile1.txt" with user "Brian" from server "LOCAL" using the sharing API @@ -82,7 +86,7 @@ Feature: federated And parameter "autoAddServers" of app "federation" has been set to "0" And parameter "auto_accept_trusted" of app "federatedfilesharing" has been set to "yes" When user "Alice" from server "REMOTE" shares "/textfile0.txt" with user "Brian" from server "LOCAL" using the sharing API - And user "Brian" from server "LOCAL" has accepted the last pending share + And user "Brian" from server "LOCAL" accepts the last pending share And using server "LOCAL" Then url "%remote_server%" should not be a trusted server When user "Alice" from server "REMOTE" shares "/textfile1.txt" with user "Brian" from server "LOCAL" using the sharing API @@ -126,7 +130,8 @@ Feature: federated And using server "REMOTE" When user "Alice" uploads file with content "thisContentIsFinal" to "/RandomFolder/new-file" using the WebDAV API And user "Alice" creates folder "/RandomFolder/sub-folder" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code of responses on all endpoints should be "201" + When using server "LOCAL" Then as "Brian" file "/PARENT/RandomFolder/new-file" should exist And as "Brian" file "/PARENT/RandomFolder/file-to-share" should exist And as "Brian" folder "/PARENT/RandomFolder/sub-folder" should exist @@ -147,7 +152,8 @@ Feature: federated And using server "LOCAL" When user "Brian" uploads file with content "thisContentIsFinal" to "/RandomFolder/new-file" using the WebDAV API And user "Brian" creates folder "/RandomFolder/sub-folder" using the WebDAV API - And using server "REMOTE" + Then the HTTP status code of responses on all endpoints should be "201" + When using server "REMOTE" Then as "Alice" file "/PARENT/RandomFolder/new-file" should exist And as "Alice" file "/PARENT/RandomFolder/file-to-share" should exist And as "Alice" folder "/PARENT/RandomFolder/sub-folder" should exist @@ -169,7 +175,8 @@ Feature: federated And using server "LOCAL" When user "Brian" deletes folder "/RandomFolder/sub-folder" using the WebDAV API And user "Brian" deletes file "/RandomFolder/file-to-share" using the WebDAV API - And using server "REMOTE" + Then the HTTP status code of responses on all endpoints should be "204" + When using server "REMOTE" Then as "Alice" file "/PARENT/RandomFolder/file-to-share" should not exist And as "Alice" folder "/PARENT/RandomFolder/sub-folder" should not exist But as "Alice" folder "/PARENT/RandomFolder" should exist @@ -189,7 +196,8 @@ Feature: federated And using server "REMOTE" When user "Alice" deletes folder "/RandomFolder/sub-folder" using the WebDAV API And user "Alice" deletes file "/RandomFolder/file-to-share" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code of responses on all endpoints should be "204" + When using server "LOCAL" Then as "Brian" file "/PARENT/RandomFolder/file-to-share" should not exist And as "Brian" folder "/PARENT/RandomFolder/sub-folder" should not exist But as "Brian" folder "/PARENT/RandomFolder" should exist @@ -210,6 +218,7 @@ Feature: federated And using server "LOCAL" When user "Brian" moves folder "/RandomFolder/sub-folder" to "/RandomFolder/renamed-sub-folder" using the WebDAV API And user "Brian" moves file "/RandomFolder/file-to-share" to "/RandomFolder/renamedFile" using the WebDAV API + Then the HTTP status code of responses on all endpoints should be "201" And using server "REMOTE" Then as "Alice" file "/PARENT/RandomFolder/file-to-share" should not exist But as "Alice" file "/PARENT/RandomFolder/renamedFile" should exist @@ -232,7 +241,8 @@ Feature: federated And using server "REMOTE" When user "Alice" moves folder "/RandomFolder/sub-folder" to "/RandomFolder/renamed-sub-folder" using the WebDAV API And user "Alice" moves file "/RandomFolder/file-to-share" to "/RandomFolder/renamedFile" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code of responses on all endpoints should be "201" + When using server "LOCAL" Then as "Brian" file "/PARENT/RandomFolder/file-to-share" should not exist But as "Brian" file "/PARENT/RandomFolder/renamedFile" should exist And the content of file "/PARENT/RandomFolder/renamedFile" for user "Brian" should be "thisContentShouldBeVisible" @@ -252,7 +262,8 @@ Feature: federated And user "Brian" from server "LOCAL" has accepted the last pending share And using OCS API version "" When user "Alice" uploads file with content "thisContentIsFinal" to "/PARENT/RandomFolder/file-to-share" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code should be "204" + When using server "LOCAL" Then the content of file "/file-to-share" for user "Brian" should be "thisContentIsFinal" Examples: | ocs-api-version | @@ -269,6 +280,7 @@ Feature: federated And using OCS API version "" When user "Alice" uploads file with content "thisContentIsFinal" to "/PARENT/RandomFolder/new-file" using the WebDAV API And user "Alice" creates folder "/PARENT/RandomFolder/sub-folder" using the WebDAV API + Then the HTTP status code of responses on all endpoints should be "201" And using server "LOCAL" Then as "Brian" file "/RandomFolder/new-file" should exist And as "Brian" file "/RandomFolder/file-to-share" should exist @@ -290,7 +302,8 @@ Feature: federated And using OCS API version "" When user "Alice" deletes folder "/PARENT/RandomFolder/sub-folder" using the WebDAV API And user "Alice" deletes file "/PARENT/RandomFolder/file-to-share" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code of responses on all endpoints should be "204" + When using server "LOCAL" Then as "Brian" file "/RandomFolder/file-to-share" should not exist And as "Brian" folder "/RandomFolder/sub-folder" should not exist But as "Brian" folder "/RandomFolder" should exist @@ -310,7 +323,8 @@ Feature: federated And using OCS API version "" When user "Alice" moves folder "/PARENT/RandomFolder/sub-folder" to "/PARENT/RandomFolder/renamed-sub-folder" using the WebDAV API And user "Alice" moves file "/PARENT/RandomFolder/file-to-share" to "/PARENT/RandomFolder/renamedFile" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code of responses on all endpoints should be "201" + When using server "LOCAL" Then as "Brian" file "/RandomFolder/file-to-share" should not exist But as "Brian" file "/RandomFolder/renamedFile" should exist And the content of file "/RandomFolder/renamedFile" for user "Brian" should be "thisContentShouldBeVisible" @@ -329,13 +343,15 @@ Feature: federated And user "Alice" from server "REMOTE" has accepted the last pending share And using OCS API version "" When user "Brian" deletes the last share using the sharing API - And using server "REMOTE" + Then the OCS status code should be "" + And the HTTP status code should be "200" + When using server "REMOTE" Then as "Alice" file "/RandomFolder/file-to-share" should not exist And as "Alice" folder "/RandomFolder" should not exist Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | ocs-status-code | + | 1 | 100 | + | 2 | 200 | Scenario Outline: federated share receiver can move the location of the received share and changes are correctly seen at both ends Given user "Brian" has created folder "/PARENT" @@ -348,12 +364,14 @@ Feature: federated When user "Alice" creates folder "/CHILD" using the WebDAV API And user "Alice" creates folder "/CHILD/newRandomFolder" using the WebDAV API And user "Alice" moves folder "/RandomFolder" to "/CHILD/newRandomFolder/RandomFolder" using the WebDAV API - Then as "Alice" file "/CHILD/newRandomFolder/RandomFolder/file-to-share" should exist + Then the HTTP status code of responses on all endpoints should be "201" + And as "Alice" file "/CHILD/newRandomFolder/RandomFolder/file-to-share" should exist When using server "LOCAL" Then as "Brian" file "/PARENT/RandomFolder/file-to-share" should exist When user "Brian" uploads file with content "thisIsTheContentOfNewFile" to "/PARENT/RandomFolder/newFile" using the WebDAV API And user "Brian" uploads file with content "theContentIsChanged" to "/PARENT/RandomFolder/file-to-share" using the WebDAV API - And using server "REMOTE" + Then the HTTP status code of responses on each endpoint should be "201, 204" respectively + When using server "REMOTE" Then as "Alice" file "/CHILD/newRandomFolder/RandomFolder/newFile" should exist And the content of file "/CHILD/newRandomFolder/RandomFolder/file-to-share" for user "Alice" should be "theContentIsChanged" Examples: @@ -371,12 +389,14 @@ Feature: federated When user "Brian" creates folder "/CHILD" using the WebDAV API And user "Brian" creates folder "/CHILD/newRandomFolder" using the WebDAV API And user "Brian" moves folder "PARENT/RandomFolder" to "/CHILD/newRandomFolder/RandomFolder" using the WebDAV API - Then as "Brian" file "/CHILD/newRandomFolder/RandomFolder/file-to-share" should exist + Then the HTTP status code of responses on all endpoints should be "201" + And as "Brian" file "/CHILD/newRandomFolder/RandomFolder/file-to-share" should exist When using server "REMOTE" Then as "Alice" file "/RandomFolder/file-to-share" should exist When user "Alice" uploads file with content "thisIsTheContentOfNewFile" to "/RandomFolder/newFile" using the WebDAV API And user "Alice" uploads file with content "theContentIsChanged" to "/RandomFolder/file-to-share" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code of responses on each endpoint should be "201, 204" respectively + When using server "LOCAL" Then as "Brian" file "/CHILD/newRandomFolder/RandomFolder/newFile" should exist And the content of file "/CHILD/newRandomFolder/RandomFolder/file-to-share" for user "Brian" should be "theContentIsChanged" Examples: @@ -392,18 +412,22 @@ Feature: federated When user "Brian" from server "LOCAL" shares "file-to-share" with user "Alice" from server "REMOTE" using the sharing API And user "Alice" from server "REMOTE" accepts the last pending share using the sharing API And using server "REMOTE" + Then the OCS status code of responses on all endpoints should be "" + And the HTTP status code of responses on all endpoints should be "200" Then as "Alice" file "/file-to-share" should exist And the content of file "/file-to-share" for user "Alice" should be "thisContentIsVisible" When user "Alice" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API And user "Alice" from server "REMOTE" shares "/newFile" with user "Brian" from server "LOCAL" using the sharing API And using server "LOCAL" And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API - Then as "Brian" file "/newFile" should exist + Then the OCS status code of responses on all endpoints should be "" + And the HTTP status code of responses on each endpoint should be "201, 200, 200" respectively + And as "Brian" file "/newFile" should exist And the content of file "/newFile" for user "Brian" should be "thisFileIsShared" Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | ocs-status-code | + | 1 | 100 | + | 2 | 200 | 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" @@ -412,55 +436,64 @@ Feature: federated And using OCS API version "" When user "Brian" from server "LOCAL" shares "file-to-share" with user "Alice" from server "REMOTE" using the sharing API And using server "REMOTE" - Then user "Alice" should not have any pending federated cloud share + Then the OCS status code should be "403" + And the HTTP status code should be "" + And user "Alice" should not have any pending federated cloud share And as "Alice" file "/file-to-share" should not exist When user "Alice" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API And user "Alice" from server "REMOTE" shares "/newFile" with user "Brian" from server "LOCAL" using the sharing API And using server "LOCAL" And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API - Then as "Brian" file "/newFile" should exist + Then the OCS status code of responses on all endpoints should be "" + And the HTTP status code of responses on each endpoint should be "201, 200, 200" respectively + And as "Brian" file "/newFile" should exist Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | ocs-status-code | http-status-code | + | 1 | 100 | 200 | + | 2 | 200 | 403 | 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 "Brian" has uploaded file with content "thisContentIsVisible" to "/file-to-share" And using OCS API version "" - When user "Brian" from server "LOCAL" shares "/file-to-share" with user "Alice" from server "REMOTE" using the sharing API + And user "Brian" from server "LOCAL" has shared "/file-to-share" with user "Alice" from server "REMOTE" And using server "REMOTE" - And user "Alice" from server "REMOTE" accepts the last pending share using the sharing API - Then as "Alice" file "/file-to-share" should exist + And user "Alice" from server "REMOTE" has accepted the last pending share When user "Alice" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API And user "Alice" from server "REMOTE" shares "/newFile" with user "Brian" from server "LOCAL" using the sharing API And using server "LOCAL" - Then user "Brian" should not have any pending federated cloud share + Then the OCS status code of responses on all endpoints should be "403" + And the HTTP status code of responses on each endpoint should be "" respectively + And user "Brian" should not have any pending federated cloud share And as "Brian" file "/newFile" should not exist Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | http-status-code | + | 1 | 201, 200 | + | 2 | 201, 403 | 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 "Brian" has uploaded file with content "thisContentIsVisible" to "/file-to-share" And using OCS API version "" - When user "Brian" from server "LOCAL" shares "/file-to-share" with user "Alice" from server "REMOTE" using the sharing API + When user "Brian" uploads file with content "thisContentIsVisible" to "/file-to-share" using the WebDAV API + And user "Brian" from server "LOCAL" shares "/file-to-share" with user "Alice" from server "REMOTE" using the sharing API And using server "REMOTE" - Then user "Alice" should not have any pending federated cloud share + Then the OCS status code should be "403" + And the HTTP status code of responses on each endpoint should be "" respectively + And user "Alice" should not have any pending federated cloud share And as "Alice" file "/file-to-share" should not exist When user "Alice" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API And user "Alice" from server "REMOTE" shares "/newFile" with user "Brian" from server "LOCAL" using the sharing API And using server "LOCAL" - Then user "Brian" should not have any pending federated cloud share + Then the OCS status code should be "403" + And the HTTP status code of responses on each endpoint should be "" respectively + And user "Brian" should not have any pending federated cloud share And as "Brian" file "/newFile" should not exist Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | http-status-code | + | 1 | 201, 200 | + | 2 | 201, 403 | 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" @@ -469,21 +502,25 @@ Feature: federated 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 "Brian" has uploaded file with content "thisContentIsVisible" to "/file-to-share" And using OCS API version "" - When user "Brian" from server "LOCAL" shares "/file-to-share" with user "Alice" from server "REMOTE" using the sharing API + When user "Brian" uploads file with content "thisContentIsVisible" to "/file-to-share" using the WebDAV API + And user "Brian" from server "LOCAL" shares "/file-to-share" with user "Alice" from server "REMOTE" using the sharing API And using server "REMOTE" - Then user "Alice" should not have any pending federated cloud share + Then the OCS status code should be "403" + And the HTTP status code of responses on each endpoint should be "" respectively + And user "Alice" should not have any pending federated cloud share And as "Alice" file "/file-to-share" should not exist When user "Alice" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API And user "Alice" from server "REMOTE" shares "/newFile" with user "Brian" from server "LOCAL" using the sharing API + Then the OCS status code should be "" + And the HTTP status code of responses on each endpoint should be "201, 200" respectively And using server "LOCAL" And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API Then as "Brian" file "/newFile" should exist Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | ocs-status-code | http-status-code | + | 1 | 100 | 201, 200 | + | 2 | 200 | 201, 403 | 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" @@ -497,16 +534,20 @@ Feature: federated When user "Brian" from server "LOCAL" shares "/file-to-share" with user "Alice" from server "REMOTE" using the sharing API And using server "REMOTE" And user "Alice" from server "REMOTE" accepts the last pending share using the sharing API - Then as "Alice" file "/file-to-share" should exist + Then the OCS status code of responses on all endpoints should be "" + And the HTTP status code of responses on all endpoints should be "200" + And as "Alice" file "/file-to-share" should exist When user "Alice" uploads file with content "thisFileIsShared" to "/newFile" using the WebDAV API And user "Alice" from server "REMOTE" shares "/newFile" with user "Brian" from server "LOCAL" using the sharing API And using server "LOCAL" - Then user "Brian" should not have any pending federated cloud share + Then the OCS status code should be "403" + And the HTTP status code of responses on each endpoint should be "" respectively + And user "Brian" should not have any pending federated cloud share And as "Brian" file "/newFile" should not exist Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | ocs-status-code | http-status-code | + | 1 | 100 | 201, 200 | + | 2 | 200 | 201, 403 | @skipOnOcV10.3 @skipOnOcV10.4 @skipOnOcV10.5.0 Scenario Outline: Federated share a file with another server with expiration date diff --git a/tests/acceptance/features/bootstrap/FederationContext.php b/tests/acceptance/features/bootstrap/FederationContext.php index 3df79286ff4b..498c97c63717 100644 --- a/tests/acceptance/features/bootstrap/FederationContext.php +++ b/tests/acceptance/features/bootstrap/FederationContext.php @@ -159,6 +159,7 @@ public function userFromServerHasSharedWithUserFromServer( ) . '"' ); $this->featureContext->emptyLastHTTPStatusCodesArray(); + $this->featureContext->emptyLastOCSStatusCodesArray(); } /** @@ -278,6 +279,24 @@ public function userFromServerHasAcceptedLastPendingShare(string $user, string $ ); $this->ocsContext->assertOCSResponseIndicatesSuccess(); $this->featureContext->emptyLastHTTPStatusCodesArray(); + $this->featureContext->emptyLastOCSStatusCodesArray(); + } + + /** + * @When /^user "([^"]*)" from server "(LOCAL|REMOTE)" accepts the last pending share$/ + * + * @param string $user + * @param string $server + * + * @return void + * @throws Exception + */ + public function userFromServerHasAcceptsLastPendingShare(string $user, string $server):void { + $this->userFromServerAcceptsLastPendingShareUsingTheSharingAPI( + $user, + $server + ); + $this->featureContext->pushToLastStatusCodesArrays(); } /** diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index bf860fec0068..7826e4c2b0d9 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -2057,7 +2057,7 @@ public function userUploadsAFileTo(string $user, string $source, string $destina $this->setResponseXml( HttpRequestHelper::parseResponseAsXml($this->response) ); - $this->pushToLastStatusCodesArrays(); + $this->pushToLastHttpStatusCodesArray((string)$this->getResponse()->getStatusCode()); } /** @@ -2076,7 +2076,6 @@ public function userHasUploadedAFileTo(string $user, string $source, string $des "HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user'" ); $this->emptyLastHTTPStatusCodesArray(); - $this->emptyLastOCSStatusCodesArray(); } /** @@ -2446,6 +2445,7 @@ public function theHTTPStatusCodeOfAllUploadResponsesShouldBe(int $statusCode):v * @throws Exception */ public function theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBe(int $statusCode):void { + echo \count($this->lastHttpStatusCodesArray); $duplicateRemovedStatusCodes = \array_unique($this->lastHttpStatusCodesArray); if (\count($duplicateRemovedStatusCodes) === 1) { Assert::assertSame(