From 023069e8e900e7423b9b04bc76d4dc0b4325cfac Mon Sep 17 00:00:00 2001 From: Parajuli Kiran Date: Fri, 22 Apr 2022 14:19:55 +0545 Subject: [PATCH] Improve then steps for suite 'apiFederationToShares2' Signed-off-by: Parajuli Kiran --- .../apiFederationToShares2/federated.feature | 210 ++++++++++++------ .../bootstrap/AppConfigurationContext.php | 19 ++ .../features/bootstrap/FeatureContext.php | 1 + .../features/bootstrap/FederationContext.php | 8 + .../features/bootstrap/OCSContext.php | 1 + .../acceptance/features/bootstrap/Sharing.php | 2 + .../acceptance/features/bootstrap/WebDav.php | 36 ++- 7 files changed, 196 insertions(+), 81 deletions(-) diff --git a/tests/acceptance/features/apiFederationToShares2/federated.feature b/tests/acceptance/features/apiFederationToShares2/federated.feature index 031aa3709b62..e315fc9e3800 100644 --- a/tests/acceptance/features/apiFederationToShares2/federated.feature +++ b/tests/acceptance/features/apiFederationToShares2/federated.feature @@ -11,7 +11,7 @@ Feature: federated And auto-accept shares has been disabled And user "Brian" has been created with default attributes and without skeleton files - @issue-35839 @skipOnOcV10 + @issue-35839 Scenario: "Auto accept from trusted servers" enabled with remote server Given using server "REMOTE" And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile1.txt" @@ -20,11 +20,13 @@ Feature: federated And parameter "auto_accept_trusted" of app "federatedfilesharing" has been set to "yes" When the administrator adds url "%remote_server%" as trusted server using the testing API And user "Alice" from server "REMOTE" shares "/textfile1.txt" with user "Brian" from server "LOCAL" using the sharing API - And using server "LOCAL" + Then the OCS status code should be "100" + And the HTTP status code of responses on each endpoint should be "201, 200" respectively + When using server "LOCAL" Then as "Brian" file "Shares/textfile1.txt" should exist And url "%remote_server%" should be a trusted server - @issue-35839 @skipOnOcV10 + @issue-35839 Scenario: "Auto accept from trusted servers" disabled with remote server Given using server "REMOTE" And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile1.txt" @@ -33,7 +35,9 @@ Feature: federated And parameter "auto_accept_trusted" of app "federatedfilesharing" has been set to "no" When the administrator adds url "%remote_server%" as trusted server using the testing API And user "Alice" from server "REMOTE" shares "/textfile1.txt" with user "Brian" from server "LOCAL" using the sharing API - And using server "LOCAL" + Then the OCS status code should be "100" + And the HTTP status code of responses on each endpoint should be "201, 200" respectively + When using server "LOCAL" Then as "Brian" file "Shares/textfile1.txt" should not exist And url "%remote_server%" should be a trusted server @@ -44,8 +48,10 @@ Feature: federated And using server "REMOTE" And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile1.txt" 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 using the sharing API + Then the HTTP status code of responses on all endpoints should be 200 + And the OCS status code of responses on all endpoints should be "100" + When using server "LOCAL" Then as "Brian" file "Shares/textfile1.txt" should exist And url "%remote_server%" should be a trusted server @@ -56,8 +62,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 using the sharing API + Then the HTTP status code of responses on all endpoints should be 200 + And the OCS status code of responses on all endpoints should be "100" + When using server "LOCAL" Then as "Brian" file "Shares/textfile1.txt" should exist And url "%remote_server%" should not be a trusted server @@ -70,13 +78,17 @@ 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 using server "LOCAL" + And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API + Then the HTTP status code of responses on all endpoints should be 200 + And the OCS status code of responses on all endpoints should be "100" + When 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 + Then the HTTP status code should be "200" + And the OCS status code should be "100" Then as "Brian" file "Shares/textfile1.txt" should exist - @issue-35839 @skipOnOcV10 + @issue-35839 Scenario: disable "Add server automatically" once a federated share was created successfully Given using server "REMOTE" And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile0.txt" @@ -86,10 +98,14 @@ 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 using server "LOCAL" + And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API + Then the HTTP status code of responses on all endpoints should be 200 + And the OCS status code of responses on all endpoints should be "100" + When 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 + Then the HTTP status code should be "200" + And the OCS status code should be "100" And as "Brian" file "Shares/textfile1.txt" should not exist Scenario Outline: federated share receiver sees the original content of a received file @@ -130,7 +146,8 @@ Feature: federated And using server "REMOTE" When user "Alice" uploads file with content "thisContentIsFinal" to "/Shares/RandomFolder/new-file" using the WebDAV API And user "Alice" creates folder "/Shares/RandomFolder/sub-folder" using the WebDAV API - And using server "LOCAL" + Then the HTTP status code of responses on all endpoints should be 200 + 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 @@ -151,7 +168,8 @@ Feature: federated And using server "LOCAL" When user "Brian" uploads file with content "thisContentIsFinal" to "/Shares/RandomFolder/new-file" using the WebDAV API And user "Brian" creates folder "/Shares/RandomFolder/sub-folder" using the WebDAV API - And using server "REMOTE" + Then the HTTP status code of responses on all endpoints should be 200 + 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 @@ -173,7 +191,8 @@ Feature: federated And using server "LOCAL" When user "Brian" deletes folder "/Shares/RandomFolder/sub-folder" using the WebDAV API And user "Brian" deletes file "/Shares/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 @@ -193,7 +212,8 @@ Feature: federated And using server "REMOTE" When user "Alice" deletes folder "/Shares/RandomFolder/sub-folder" using the WebDAV API And user "Alice" deletes file "/Shares/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 @@ -214,7 +234,8 @@ Feature: federated And using server "LOCAL" When user "Brian" moves folder "/Shares/RandomFolder/sub-folder" to "/Shares/RandomFolder/renamed-sub-folder" using the WebDAV API And user "Brian" moves file "/Shares/RandomFolder/file-to-share" to "/Shares/RandomFolder/renamedFile" 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/file-to-share" should not exist But as "Alice" file "/PARENT/RandomFolder/renamedFile" should exist And the content of file "/PARENT/RandomFolder/renamedFile" for user "Alice" should be "thisContentShouldBeVisible" @@ -236,7 +257,8 @@ Feature: federated And using server "REMOTE" When user "Alice" moves folder "/Shares/RandomFolder/sub-folder" to "/Shares/RandomFolder/renamed-sub-folder" using the WebDAV API And user "Alice" moves file "/Shares/RandomFolder/file-to-share" to "/Shares/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" @@ -256,7 +278,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 "/Shares/file-to-share" for user "Brian" should be "thisContentIsFinal" Examples: | ocs-api-version | @@ -273,7 +296,8 @@ 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 - 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 "/Shares/RandomFolder/new-file" should exist And as "Brian" file "/Shares/RandomFolder/file-to-share" should exist And as "Brian" folder "/Shares/RandomFolder/sub-folder" should exist @@ -294,7 +318,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 "/Shares/RandomFolder/file-to-share" should not exist And as "Brian" folder "/Shares/RandomFolder/sub-folder" should not exist But as "Brian" folder "/Shares/RandomFolder" should exist @@ -314,7 +339,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 "/Shares/RandomFolder/file-to-share" should not exist But as "Brian" file "/Shares/RandomFolder/renamedFile" should exist And the content of file "/Shares/RandomFolder/renamedFile" for user "Brian" should be "thisContentShouldBeVisible" @@ -333,13 +359,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 HTTP status code should be "200" + And the OCS status code should be "" + When using server "REMOTE" Then as "Alice" file "/Shares/RandomFolder/file-to-share" should not exist And as "Alice" folder "/Shares/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" @@ -352,12 +380,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 "/Shares/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: @@ -375,12 +405,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 "/Shares/RandomFolder/file-to-share" should exist When user "Alice" uploads file with content "thisIsTheContentOfNewFile" to "/Shares/RandomFolder/newFile" using the WebDAV API And user "Alice" uploads file with content "theContentIsChanged" to "/Shares/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: @@ -395,19 +427,23 @@ Feature: federated And user "Brian" has uploaded file with content "thisContentIsVisible" to "/file-to-share" 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 HTTP status code of responses on all endpoints should be "200" + And the OCS status code of responses on all endpoints should be "" + When using server "REMOTE" Then as "Alice" file "/Shares/file-to-share" should exist And the content of file "/Shares/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 + Then the HTTP status code of responses on each endpoint should be "201, 200" respectively + And the OCS status code of responses on each endpoint should be "notset, " respectively And using server "LOCAL" And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API Then as "Brian" file "/Shares/newFile" should exist And the content of file "/Shares/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" @@ -415,18 +451,24 @@ Feature: federated 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 using server "REMOTE" + Then the HTTP status code should be "" + And the OCS status code should be "403" + When using server "REMOTE" Then user "Alice" should not have any pending federated cloud share And as "Alice" file "/Shares/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 the HTTP status code of responses on each endpoint should be "201, 200" respectively + And the OCS status code of responses on each endpoint should be "notset, " respectively + When using server "LOCAL" And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API - Then as "Brian" file "/Shares/newFile" should exist + Then the HTTP status code should be "200" + And the OCS status code should be "" + And as "Brian" file "/Shares/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" @@ -434,18 +476,24 @@ Feature: federated 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 using server "REMOTE" + Then the HTTP status code should be "200" + And the OCS status code should be "" + When using server "REMOTE" And user "Alice" from server "REMOTE" accepts the last pending share using the sharing API - Then as "Alice" file "/Shares/file-to-share" should exist + Then the HTTP status code should be "200" + And the OCS status code should be "" + And as "Alice" file "/Shares/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 the HTTP status code of responses on each endpoint should be "" respectively + And the OCS status code of responses on each endpoint should be "notset, 403" respectively + When using server "LOCAL" Then user "Brian" should not have any pending federated cloud share And as "Brian" file "/Shares/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 | 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" @@ -453,18 +501,22 @@ Feature: federated 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 using server "REMOTE" + Then the HTTP status code should be "" + And the OCS status code should be "403" + When using server "REMOTE" Then user "Alice" should not have any pending federated cloud share And as "Alice" file "/Shares/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 the HTTP status code of responses on each endpoint should be "201," respectively + And the OCS status code of responses on each endpoint should be "notset, 403" respectively + When using server "LOCAL" Then user "Brian" should not have any pending federated cloud share And as "Brian" file "/Shares/newFile" should not exist Examples: - | ocs-api-version | - | 1 | - | 2 | + | ocs-api-version | http-status-code | + | 1 | 200 | + | 2 | 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" @@ -476,18 +528,24 @@ Feature: federated 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 using server "REMOTE" + Then the HTTP status code should be "" + And the OCS status code should be "403" + When using server "REMOTE" Then user "Alice" should not have any pending federated cloud share And as "Alice" file "/Shares/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 the HTTP status code of responses on each endpoint should be "201,200" respectively + And the OCS status code of responses on each endpoint should be "notset," respectively + When using server "LOCAL" And user "Brian" from server "LOCAL" accepts the last pending share using the sharing API - Then as "Brian" file "/Shares/newFile" should exist + Then the HTTP status code should be "200" + And the OCS status code should be "" + And as "Brian" file "/Shares/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 and outgoing federation shares are enabled for local server but outgoing federation shares are restricted for remote server Given using server "REMOTE" @@ -499,18 +557,24 @@ Feature: federated 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 using server "REMOTE" + Then the HTTP status code should be "200" + And the OCS status code should be "" + When using server "REMOTE" And user "Alice" from server "REMOTE" accepts the last pending share using the sharing API - Then as "Alice" file "/Shares/file-to-share" should exist + Then the HTTP status code should be "200" + And the OCS status code should be "" + And as "Alice" file "/Shares/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 the HTTP status code of responses on each endpoint should be "" respectively + And the OCS status code of responses on each endpoint should be "notset,403" respectively + When using server "LOCAL" Then user "Brian" should not have any pending federated cloud share And as "Brian" file "/Shares/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 @@ -597,8 +661,8 @@ Feature: federated And parameter "shareapi_enforce_expire_date_remote_share" of app "core" has been set to "yes" And parameter "shareapi_expire_after_n_days_remote_share" of app "core" has been set to "7" And user "Brian" has uploaded file "filesForUpload/textfile.txt" to "/textfile0.txt" - When user "Brian" from server "LOCAL" shares "/textfile0.txt" with user "Alice" from server "REMOTE" using the sharing API - And user "Brian" updates the last share using the sharing API with + And user "Brian" from server "LOCAL" has shared "/textfile0.txt" with user "Alice" from server "REMOTE" + When user "Brian" updates the last share using the sharing API with | expireDate | +3 days | Then the OCS status code should be "" And the HTTP status code should be "200" @@ -610,14 +674,14 @@ Feature: federated | 2 | 200 | @skipOnOcV10.3 @skipOnOcV10.4 @skipOnOcV10.5.0 - Scenario Outline: Federated sharing with default expiration date enabled and enforced, user shares with expiration date more than the default + Scenario Outline: Federated sharing with default expiration date enabled and enforced, user updates the share with expiration date more than the default Given using OCS API version "" And parameter "shareapi_default_expire_date_remote_share" of app "core" has been set to "yes" And parameter "shareapi_enforce_expire_date_remote_share" of app "core" has been set to "yes" And parameter "shareapi_expire_after_n_days_remote_share" of app "core" has been set to "7" And user "Brian" has uploaded file "filesForUpload/textfile.txt" to "/textfile0.txt" - When user "Brian" from server "LOCAL" shares "/textfile0.txt" with user "Alice" from server "REMOTE" using the sharing API - And user "Brian" updates the last share using the sharing API with + And user "Brian" from server "LOCAL" has shared "/textfile0.txt" with user "Alice" from server "REMOTE" + When user "Brian" updates the last share using the sharing API with | expireDate | +10 days | Then the OCS status code should be "404" And the HTTP status code should be "" @@ -637,8 +701,8 @@ Feature: federated And user "Brian" has uploaded file "filesForUpload/textfile.txt" to "/textfile0.txt" And user "Brian" has shared file "/textfile0.txt" with user "Carol" with permissions "read,update,share" And user "Carol" has accepted share "/textfile0.txt" offered by user "Brian" - When user "Carol" from server "LOCAL" shares "/Shares/textfile0.txt" with user "Alice" from server "REMOTE" using the sharing API - And user "Carol" updates the last share using the sharing API with + And user "Carol" from server "LOCAL" has shared "/Shares/textfile0.txt" with user "Alice" from server "REMOTE" + When user "Carol" updates the last share using the sharing API with | expireDate | +3 days | Then the HTTP status code should be "200" And the OCS status code should be "" @@ -660,8 +724,8 @@ Feature: federated And user "Brian" has uploaded file "filesForUpload/textfile.txt" to "/textfile0.txt" And user "Brian" has shared file "/textfile0.txt" with user "Carol" with permissions "read,update,share" And user "Carol" has accepted share "/textfile0.txt" offered by user "Brian" - When user "Carol" from server "LOCAL" shares "/Shares/textfile0.txt" with user "Alice" from server "REMOTE" using the sharing API - And user "Carol" updates the last share using the sharing API with + And user "Carol" from server "LOCAL" has shared "/Shares/textfile0.txt" with user "Alice" from server "REMOTE" + When user "Carol" updates the last share using the sharing API with | expireDate | +10 days | Then the OCS status code should be "404" And the HTTP status code should be "" diff --git a/tests/acceptance/features/bootstrap/AppConfigurationContext.php b/tests/acceptance/features/bootstrap/AppConfigurationContext.php index 1535efb8d8a2..7e8496bff730 100644 --- a/tests/acceptance/features/bootstrap/AppConfigurationContext.php +++ b/tests/acceptance/features/bootstrap/AppConfigurationContext.php @@ -23,6 +23,7 @@ */ use Behat\Behat\Hook\Scope\BeforeScenarioScope; +use GuzzleHttp\Exception\GuzzleException; use PHPUnit\Framework\Assert; use TestHelpers\AppConfigHelper; use TestHelpers\OcsApiHelper; @@ -47,6 +48,7 @@ class AppConfigurationContext implements Context { * @param string $value * * @return void + * @throws Exception */ public function adminSetsServerParameterToUsingAPI( string $parameter, @@ -68,6 +70,7 @@ public function adminSetsServerParameterToUsingAPI( * @param string $value * * @return void + * @throws Exception */ public function serverParameterHasBeenSetTo(string $parameter, string $app, string $value):void { // The capturing group of the regex always includes the quotes at each @@ -111,6 +114,7 @@ public function theCapabilitiesSettingOfAppParameterShouldBe( * @param string $capabilitiesPath the path to the element * * @return string + * @throws Exception */ public function getAppParameter(string $capabilitiesApp, string $capabilitiesPath):string { return $this->getParameterValueFromXml( @@ -126,6 +130,8 @@ public function getAppParameter(string $capabilitiesApp, string $capabilitiesPat * @param string $username * * @return void + * @throws GuzzleException + * @throws JsonException */ public function userGetsCapabilities(string $username):void { $user = $this->featureContext->getActualUsername($username); @@ -184,6 +190,7 @@ public function theUserGetsCapabilitiesCheckResponse():void { /** * @return string + * @throws Exception */ public function getAdminUsernameForCapabilitiesCheck():string { if (\TestHelpers\OcisHelper::isTestingOnReva()) { @@ -225,6 +232,7 @@ public function theAdministratorGetsCapabilitiesCheckResponse():void { * @param string $exceptionText text to put at the front of exception messages * * @return SimpleXMLElement latest retrieved capabilities in XML format + * @throws Exception */ public function getCapabilitiesXml(string $exceptionText = ''): SimpleXMLElement { if ($exceptionText === '') { @@ -237,6 +245,7 @@ public function getCapabilitiesXml(string $exceptionText = ''): SimpleXMLElement * @param string $exceptionText text to put at the front of exception messages * * @return SimpleXMLElement latest retrieved version data in XML format + * @throws Exception */ public function getVersionXml(string $exceptionText = ''): SimpleXMLElement { if ($exceptionText === '') { @@ -326,6 +335,7 @@ public function parameterValueExistsInXml( * @param string $value * * @return void + * @throws Exception */ public function modifyAppConfig(string $app, string $parameter, string $value):void { AppConfigHelper::modifyAppConfig( @@ -344,6 +354,7 @@ public function modifyAppConfig(string $app, string $parameter, string $value):v * @param array $appParameterValues * * @return void + * @throws Exception */ public function modifyAppConfigs(array $appParameterValues):void { AppConfigHelper::modifyAppConfigs( @@ -362,6 +373,7 @@ public function modifyAppConfigs(array $appParameterValues):void { * @param string $url * * @return void + * @throws GuzzleException */ public function theAdministratorAddsUrlAsTrustedServerUsingTheTestingApi(string $url):void { $adminUser = $this->featureContext->getAdminUsername(); @@ -375,6 +387,7 @@ public function theAdministratorAddsUrlAsTrustedServerUsingTheTestingApi(string ['url' => $this->featureContext->substituteInLineCodes($url)] ); $this->featureContext->setResponse($response); + $this->featureContext->pushToLastStatusCodesArrays(); } /** @@ -456,6 +469,7 @@ public function theTrustedServerListShouldIncludeTheseUrls(TableNode $table):voi * * @return void * @throws Exception + * @throws GuzzleException */ public function theAdministratorHasAddedUrlAsTrustedServer(string $url):void { $this->theAdministratorAddsUrlAsTrustedServerUsingTheTestingApi($url); @@ -475,6 +489,7 @@ public function theAdministratorHasAddedUrlAsTrustedServer(string $url):void { * @param string $url * * @return void + * @throws GuzzleException */ public function theAdministratorDeletesUrlFromTrustedServersUsingTheTestingApi(string $url):void { $adminUser = $this->featureContext->getAdminUsername(); @@ -514,6 +529,7 @@ public function urlShouldNotBeATrustedServer(string $url):void { * @When the administrator deletes all trusted servers using the testing API * * @return void + * @throws GuzzleException */ public function theAdministratorDeletesAllTrustedServersUsingTheTestingApi():void { $adminUser = $this->featureContext->getAdminUsername(); @@ -564,6 +580,7 @@ public function theTrustedServerListShouldBeEmpty():void { * Expires last created share using the testing API * * @return void + * @throws GuzzleException */ public function expireLastCreatedUserShare():void { $adminUser = $this->featureContext->getAdminUsername(); @@ -585,6 +602,7 @@ public function expireLastCreatedUserShare():void { * @Given the administrator has expired the last created share using the testing API * * @return void + * @throws GuzzleException */ public function theAdministratorHasExpiredTheLastCreatedShare():void { $this->expireLastCreatedUserShare(); @@ -599,6 +617,7 @@ public function theAdministratorHasExpiredTheLastCreatedShare():void { * @When the administrator expires the last created share using the testing API * * @return void + * @throws GuzzleException */ public function theAdministratorExpiresTheLastCreatedShare():void { $this->expireLastCreatedUserShare(); diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index 60bc3b8b36db..aa0bf5261dd8 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -1580,6 +1580,7 @@ public function theHTTPStatusCodeShouldBe($expectedStatusCode, ?string $message $message ); } + $this->emptyLastHTTPStatusCodesArray(); } /** diff --git a/tests/acceptance/features/bootstrap/FederationContext.php b/tests/acceptance/features/bootstrap/FederationContext.php index e939294a6a22..3df79286ff4b 100644 --- a/tests/acceptance/features/bootstrap/FederationContext.php +++ b/tests/acceptance/features/bootstrap/FederationContext.php @@ -57,6 +57,7 @@ class FederationContext implements Context { * @param string|null $expireDate * * @return void + * @throws JsonException */ public function userFromServerSharesWithUserFromServerUsingTheSharingAPI( string $sharerUser, @@ -89,6 +90,7 @@ public function userFromServerSharesWithUserFromServerUsingTheSharingAPI( * @param string|null $expireDate * * @return void + * @throws JsonException */ public function userFromServerSharesWithUserFromServerUsingTheSharingAPIWithPermissions( string $sharerUser, @@ -120,6 +122,7 @@ public function userFromServerSharesWithUserFromServerUsingTheSharingAPIWithPerm null, $expireDate ); + $this->featureContext->pushToLastStatusCodesArrays(); $this->featureContext->usingServer($previous); } @@ -155,6 +158,7 @@ public function userFromServerHasSharedWithUserFromServer( $this->featureContext->getResponse() ) . '"' ); + $this->featureContext->emptyLastHTTPStatusCodesArray(); } /** @@ -254,6 +258,7 @@ public function userFromServerAcceptsLastPendingShareUsingTheSharingAPI(string $ "/apps/files_sharing/api/v1/remote_shares/pending/{$share_id}", null ); + $this->featureContext->pushToLastStatusCodesArrays(); $this->featureContext->usingServer($previous); } @@ -272,6 +277,7 @@ public function userFromServerHasAcceptedLastPendingShare(string $user, string $ $server ); $this->ocsContext->assertOCSResponseIndicatesSuccess(); + $this->featureContext->emptyLastHTTPStatusCodesArray(); } /** @@ -302,6 +308,7 @@ public function userRetrievesInformationOfLastFederatedShare(string $user):void * @param string $user * * @return void + * @throws Exception */ public function userShouldHaveNoLastPendingFederatedCloudShare(string $user):void { $this->userGetsTheListOfPendingFederatedCloudShares($user); @@ -312,6 +319,7 @@ public function userShouldHaveNoLastPendingFederatedCloudShare(string $user):voi __METHOD__ . " No pending federated cloud shares were expected, but got unexpectedly." ); + $this->featureContext->emptyLastHTTPStatusCodesArray(); } /** diff --git a/tests/acceptance/features/bootstrap/OCSContext.php b/tests/acceptance/features/bootstrap/OCSContext.php index eb71fda4aad5..016203271d10 100644 --- a/tests/acceptance/features/bootstrap/OCSContext.php +++ b/tests/acceptance/features/bootstrap/OCSContext.php @@ -759,6 +759,7 @@ public function theOCSStatusCodeShouldBe(string $statusCode, $message = ""):void $statusCodes, $message ); + $this->featureContext->emptyLastOCSStatusCodesArray(); } else { if ($message === "") { $message = "OCS status code is not the expected value " . $statusCodes . " got " . $responseStatusCode; diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index dd4f998c7477..c967c2660d73 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -994,6 +994,8 @@ public function addToListOfCreatedPublicLinks(string $name, string $url):void { * @param string $sharingApp * * @return void + * @throws JsonException + * @throws Exception */ public function createShare( string $user, diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 24f9f4ebe8c2..62d1557e218e 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -725,6 +725,8 @@ public function userMovesEntriesUsingTheAPI( * @param string $fileDestination * * @return void + * @throws JsonException + * @throws GuzzleException */ public function userMovesFileUsingTheAPI( string $user, @@ -751,7 +753,6 @@ public function userMovesFileUsingTheAPI( } } try { - $this->emptyLastHTTPStatusCodesArray(); $this->response = $this->makeDavRequest( $user, "MOVE", @@ -2452,6 +2453,7 @@ public function theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBe(int $statusCo \intval($duplicateRemovedStatusCodes[0]), 'Responses did not return expected http status code' ); + $this->emptyLastHTTPStatusCodesArray(); } else { throw new Exception( 'Expected same but found different http status codes of last requested responses.' . @@ -2496,13 +2498,20 @@ public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBe(string $statu * @throws Exception */ public function theOCStatusCodeOfResponsesOnEachEndpointShouldBe(string $statusCodes):void { + $NOT_SET = "notset"; $statusCodes = \explode(',', $statusCodes); $count = \count($statusCodes); if ($count === \count($this->lastOCSStatusCodesArray)) { for ($i = 0; $i < $count; $i++) { + $actualCode = $this->lastOCSStatusCodesArray[$i]; + $expectedCode = \trim($statusCodes[$i]); + if ($expectedCode !== $NOT_SET) { + $actualCode = \intval($actualCode); + $expectedCode = \intval($expectedCode); + } Assert::assertSame( - (int)\trim($statusCodes[$i]), - (int)$this->lastOCSStatusCodesArray[$i], + $expectedCode, + $actualCode, 'Responses did not return expected OCS status code' ); } @@ -2536,7 +2545,7 @@ public function theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBeOr(string $sta /** * @Then the OCS status code of responses on all endpoints should be :statusCode * - * @param $statusCode + * @param string $statusCode * * @return void * @throws Exception @@ -2549,6 +2558,7 @@ public function theOCSStatusCodeOfResponsesOnAllEndpointsShouldBe(string $status \intval($duplicateRemovedStatusCodes[0]), 'Responses did not return expected ocs status code' ); + $this->emptyLastOCSStatusCodesArray(); } else { throw new Exception( 'Expected same but found different ocs status codes of last requested responses.' . @@ -2860,6 +2870,7 @@ public function userUploadsAFileToEndingWithOfSizeBytes(string $user, string $de * * @return void * @throws Exception + * @throws GuzzleException */ public function userUploadsFilesWithContentTo( string $user, @@ -2891,6 +2902,8 @@ public function userUploadsFilesWithContentTo( * @param string $destination * * @return string[] + * @throws JsonException + * @throws GuzzleException */ public function uploadFileWithContent( string $user, @@ -2955,14 +2968,17 @@ public function adminHasUploadedAFileWithContentTo( * @param string|null $content * @param string $destination * - * @return string[] + * @return void + * @throws GuzzleException + * @throws JsonException */ public function userUploadsAFileWithContentTo( string $user, ?string $content, string $destination - ):array { - return $this->uploadFileWithContent($user, $content, $destination); + ):void { + $this->uploadFileWithContent($user, $content, $destination); + $this->pushToLastStatusCodesArrays(); } /** @@ -2973,7 +2989,7 @@ public function userUploadsAFileWithContentTo( * @param TableNode $table * * @return void - * @throws Exception + * @throws Exception|GuzzleException */ public function userUploadsFollowingFilesWithContentTo( string $user, @@ -3561,6 +3577,7 @@ public function userOnHasDeletedFile(string $user, string $server, string $delet * @param string $destination * * @return void + * @throws JsonException | GuzzleException */ public function userCreatesFolder(string $user, string $destination):void { $user = $this->getActualUsername($user); @@ -3574,6 +3591,7 @@ public function userCreatesFolder(string $user, string $destination):void { $this->setResponseXml( HttpRequestHelper::parseResponseAsXml($this->response) ); + $this->pushToLastStatusCodesArrays(); } /** @@ -3583,6 +3601,7 @@ public function userCreatesFolder(string $user, string $destination):void { * @param string $destination * * @return void + * @throws JsonException */ public function userHasCreatedFolder(string $user, string $destination):void { $user = $this->getActualUsername($user); @@ -3591,6 +3610,7 @@ public function userHasCreatedFolder(string $user, string $destination):void { ["201", "204"], "HTTP status code was not 201 or 204 while trying to create folder '$destination' for user '$user'" ); + $this->emptyLastHTTPStatusCodesArray(); } /**