diff --git a/tests/acceptance/features/apiShareCreateSpecialToRoot1/createShareExpirationDate.feature b/tests/acceptance/features/apiShareCreateSpecialToRoot1/createShareExpirationDate.feature index c5925e2d9393..bf84574c5654 100644 --- a/tests/acceptance/features/apiShareCreateSpecialToRoot1/createShareExpirationDate.feature +++ b/tests/acceptance/features/apiShareCreateSpecialToRoot1/createShareExpirationDate.feature @@ -831,10 +831,9 @@ Feature: a default expiration date can be specified for shares with users or gro | path | /textfile0.txt | | shareWith | brand-new-group | | expireDate | +15 days | - And the administrator has expired the last created share using the testing API + And the administrator has expired the last created public link share using the testing API When the public accesses the preview of file "textfile0.txt" from the last shared public link using the sharing API Then the HTTP status code should be "404" - And user "Alice" should not see the share id of the last share And as "Alice" file "/textfile0.txt" should exist diff --git a/tests/acceptance/features/apiShareManagementBasicToRoot/deleteShareFromRoot.feature b/tests/acceptance/features/apiShareManagementBasicToRoot/deleteShareFromRoot.feature index 894faa409610..4f141b0ec33e 100644 --- a/tests/acceptance/features/apiShareManagementBasicToRoot/deleteShareFromRoot.feature +++ b/tests/acceptance/features/apiShareManagementBasicToRoot/deleteShareFromRoot.feature @@ -131,7 +131,7 @@ Feature: sharing And user "Alice" has created folder "PARENT" And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/PARENT/parent.txt" And user "Alice" has shared entry "" with group "grp1" - When user "Brian" deletes the last share using the sharing API + When user "Brian" deletes the last share of user "Alice" using the sharing API Then the OCS status code should be "404" And the HTTP status code should be "" And as "Alice" entry "" should exist @@ -149,7 +149,7 @@ Feature: sharing And user "Alice" has created folder "PARENT" And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/PARENT/parent.txt" And user "Alice" has shared entry "" with user "Brian" - When user "Brian" deletes the last share using the sharing API + When user "Brian" deletes the last share of user "Alice" using the sharing API Then the OCS status code should be "404" And the HTTP status code should be "" And as "Alice" entry "" should exist @@ -165,7 +165,7 @@ Feature: sharing Given using OCS API version "" And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "fileToShare.txt" And user "Alice" has shared file "fileToShare.txt" with user "Brian" - When user "Brian" tries to delete the last share using the sharing API + When user "Brian" tries to delete the last share of user "Alice" using the sharing API Then the OCS status code should be "" And the HTTP status code should be "" Examples: diff --git a/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature b/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature index d757d89ac1f7..846d0427e65e 100644 --- a/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature +++ b/tests/acceptance/features/apiShareManagementBasicToShares/deleteShareFromShares.feature @@ -173,7 +173,7 @@ Feature: sharing And user "Alice" has shared entry "" with group "grp1" And user "Brian" has accepted share "" offered by user "Alice" And user "Carol" has accepted share "" offered by user "Alice" - When user "Brian" deletes the last share using the sharing API + When user "Brian" deletes the last share of user "Alice" using the sharing API Then the OCS status code should be "404" And the HTTP status code should be "" And as "Alice" entry "" should exist @@ -201,7 +201,7 @@ Feature: sharing And user "Alice" has moved file "/textfile0.txt" to "/shared/shared_file.txt" And user "Alice" has shared entry "" with user "Brian" And user "Brian" has accepted share "" offered by user "Alice" - When user "Brian" deletes the last share using the sharing API + When user "Brian" deletes the last share of user "Alice" using the sharing API Then the OCS status code should be "404" And the HTTP status code should be "" And as "Alice" entry "" should exist @@ -242,7 +242,7 @@ Feature: sharing Given using OCS API version "" And user "Alice" has shared file "textfile0.txt" with user "Brian" And user "Brian" has accepted share "/textfile0.txt" offered by user "Alice" - When user "Brian" tries to delete the last share using the sharing API + When user "Brian" tries to delete the last share of user "Alice" using the sharing API Then the OCS status code should be "" And the HTTP status code should be "" Examples: diff --git a/tests/acceptance/features/apiSharePublicLink1/changingPublicLinkShare.feature b/tests/acceptance/features/apiSharePublicLink1/changingPublicLinkShare.feature index 6d3733c59c84..d041b4f127f2 100644 --- a/tests/acceptance/features/apiSharePublicLink1/changingPublicLinkShare.feature +++ b/tests/acceptance/features/apiSharePublicLink1/changingPublicLinkShare.feature @@ -14,7 +14,7 @@ Feature: changing a public link share Given user "Alice" has created a public link share with settings | path | /PARENT | | permissions | | - When the public deletes file "parent.txt" from the last public share using the public WebDAV API + When the public deletes file "parent.txt" from the last public link share using the public WebDAV API Then the HTTP status code should be "" And as "Alice" file "PARENT/parent.txt" exist @@ -35,7 +35,7 @@ Feature: changing a public link share Given user "Alice" has created a public link share with settings | path | /PARENT | | permissions | read,update,create | - When the public renames file "parent.txt" to "newparent.txt" from the last public share using the public WebDAV API + When the public renames file "parent.txt" to "newparent.txt" from the last public link share using the public WebDAV API Then the HTTP status code should be "403" And as "Alice" file "/PARENT/parent.txt" should exist And as "Alice" file "/PARENT/newparent.txt" should not exist @@ -55,7 +55,7 @@ Feature: changing a public link share Given user "Alice" has created a public link share with settings | path | /PARENT | | permissions | read,update,create,delete | - When the public renames file "parent.txt" to "newparent.txt" from the last public share using the public WebDAV API + When the public renames file "parent.txt" to "newparent.txt" from the last public link share using the public WebDAV API Then the HTTP status code should be "201" And as "Alice" file "/PARENT/parent.txt" should not exist And as "Alice" file "/PARENT/newparent.txt" should exist @@ -114,7 +114,7 @@ Feature: changing a public link share | path | /PARENT | | permissions | change | | password | newpasswd | - When the public deletes file "parent.txt" from the last public share using the password "invalid" and public WebDAV API + When the public deletes file "parent.txt" from the last public link share using the password "invalid" and public WebDAV API Then the HTTP status code should be "401" And as "Alice" file "PARENT/parent.txt" should exist @@ -134,7 +134,7 @@ Feature: changing a public link share | path | /PARENT | | permissions | change | | password | newpasswd | - When the public deletes file "parent.txt" from the last public share using the password "newpasswd" and public WebDAV API + When the public deletes file "parent.txt" from the last public link share using the password "newpasswd" and public WebDAV API Then the HTTP status code should be "204" And as "Alice" file "PARENT/parent.txt" should not exist @@ -154,7 +154,7 @@ Feature: changing a public link share | path | /PARENT | | permissions | change | | password | newpasswd | - When the public renames file "parent.txt" to "newparent.txt" from the last public share using the password "invalid" and public WebDAV API + When the public renames file "parent.txt" to "newparent.txt" from the last public link share using the password "invalid" and public WebDAV API Then the HTTP status code should be "401" And as "Alice" file "/PARENT/newparent.txt" should not exist And as "Alice" file "/PARENT/parent.txt" should exist @@ -175,7 +175,7 @@ Feature: changing a public link share | path | /PARENT | | permissions | change | | password | newpasswd | - When the public renames file "parent.txt" to "newparent.txt" from the last public share using the password "newpasswd" and public WebDAV API + When the public renames file "parent.txt" to "newparent.txt" from the last public link share using the password "newpasswd" and public WebDAV API Then the HTTP status code should be "201" And as "Alice" file "/PARENT/newparent.txt" should exist And as "Alice" file "/PARENT/parent.txt" should not exist @@ -235,7 +235,7 @@ Feature: changing a public link share Given user "Alice" has created a public link share with settings | path | /PARENT | | permissions | uploadwriteonly | - When the public renames file "parent.txt" to "newparent.txt" from the last public share using the public WebDAV API + When the public renames file "parent.txt" to "newparent.txt" from the last public link share using the public WebDAV API Then the HTTP status code should be "403" And as "Alice" file "/PARENT/parent.txt" should exist And as "Alice" file "/PARENT/newparent.txt" should not exist @@ -255,7 +255,7 @@ Feature: changing a public link share Given user "Alice" has created a public link share with settings | path | /PARENT | | permissions | uploadwriteonly | - When the public deletes file "parent.txt" from the last public share using the public WebDAV API + When the public deletes file "parent.txt" from the last public link share using the public WebDAV API Then the HTTP status code should be "403" And as "Alice" file "PARENT/parent.txt" should exist diff --git a/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShare.feature b/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShare.feature index f811b4e7e71e..c4e5d0992fd7 100644 --- a/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShare.feature +++ b/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShare.feature @@ -25,7 +25,7 @@ Feature: create a public link share | uid_file_owner | %username% | | uid_owner | %username% | | name | | - When the public downloads the last public shared file using the public WebDAV API + When the public downloads the last public link shared file using the public WebDAV API Then the downloaded content should be "Random data" And the public upload to the last publicly shared file using the public WebDAV API should fail with HTTP status code "403" @@ -162,7 +162,7 @@ Feature: create a public link share | uid_file_owner | %username% | | uid_owner | %username% | | name | | - When the public downloads file "/randomfile.txt" from inside the last public shared folder using the public WebDAV API + When the public downloads file "/randomfile.txt" from inside the last public link shared folder using the public WebDAV API Then the downloaded content should be "Random data" And the public upload to the last publicly shared folder using the public WebDAV API should fail with HTTP status code "403" @@ -201,10 +201,10 @@ Feature: create a public link share | uid_file_owner | %username% | | uid_owner | %username% | | name | | - And the public should be able to download file "/randomfile.txt" from inside the last public shared folder using the public WebDAV API with password "%public%" + And the public should be able to download file "/randomfile.txt" from inside the last public link shared folder using the public WebDAV API with password "%public%" And the downloaded content should be "Random data" - But the public should not be able to download file "/randomfile.txt" from inside the last public shared folder using the public WebDAV API without a password - And the public should not be able to download file "/randomfile.txt" from inside the last public shared folder using the public WebDAV API with password "%regular%" + But the public should not be able to download file "/randomfile.txt" from inside the last public link shared folder using the public WebDAV API without a password + And the public should not be able to download file "/randomfile.txt" from inside the last public link shared folder using the public WebDAV API with password "%regular%" @notToImplementOnOCIS @issue-ocis-2079 Examples: @@ -331,7 +331,7 @@ Feature: create a public link share | path | /afolder | | permissions | read | And parameter "shareapi_allow_public_upload" of app "core" has been set to "no" - When user "Alice" tries to update the last share using the sharing API with + When user "Alice" tries to update the last public link share using the sharing API with | permissions | read,create | Then the OCS status code should be "" @@ -461,7 +461,7 @@ Feature: create a public link share | uid_file_owner | %username% | | uid_owner | %username% | | name | | - And the public should be able to download file "/randomfile.txt" from inside the last public shared folder using the public WebDAV API + And the public should be able to download file "/randomfile.txt" from inside the last public link shared folder using the public WebDAV API And the downloaded content should be "Random data" And the public upload to the last publicly shared folder using the public WebDAV API should fail with HTTP status code "403" @@ -508,7 +508,7 @@ Feature: create a public link share | path | /aquickbrownfoxjumpsoveraverylazydogaquickbrownfoxjumpsoveralazydog | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "/randomfile.txt" from inside the last public shared folder using the public WebDAV API + And the public should be able to download file "/randomfile.txt" from inside the last public link shared folder using the public WebDAV API And the downloaded content should be "Random data" @notToImplementOnOCIS @issue-ocis-2079 @@ -541,7 +541,7 @@ Feature: create a public link share | permissions | read | | uid_owner | %username% | | expiration | +7 days | - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "" And the fields of the last response to user "Alice" should include @@ -574,7 +574,7 @@ Feature: create a public link share | path | PARENT | | permissions | read | When user "Alice" deletes folder "PARENT" using the WebDAV API - And the public download of file "/parent.txt" from inside the last public shared folder using the public WebDAV API should fail with HTTP status code "404" + And the public download of file "/parent.txt" from inside the last public link shared folder using the public WebDAV API should fail with HTTP status code "404" @notToImplementOnOCIS @issue-ocis-2079 Examples: @@ -593,7 +593,7 @@ Feature: create a public link share And user "Alice" has created a public link share with settings | path | PARENT | | permissions | uploadwriteonly | - When the public downloads file "parent.txt" from inside the last public shared folder using the public WebDAV API + When the public downloads file "parent.txt" from inside the last public link shared folder using the public WebDAV API Then the value of the item "//s:message" in the response should be "" And the HTTP status code should be "404" @@ -652,7 +652,7 @@ Feature: create a public link share And user "Alice" has created a public link share with settings | path | /testFolder | | permissions | read,update,create,delete | - When the public uploads file "file.txt" to the last shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API + When the public uploads file "file.txt" to the last public link shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API Then the HTTP status code should be "201" And as "Alice" file "testFolder/file.txt" should exist And as "Alice" the mtime of the file "testFolder/file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT" @@ -665,7 +665,7 @@ Feature: create a public link share And user "Alice" creates a public link share using the sharing API with settings | path | /testFolder | | permissions | read,update,create,delete | - And the public uploads file "file.txt" to the last shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API + And the public uploads file "file.txt" to the last public link shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API Then the HTTP status code should be "204" And as "Alice" file "/testFolder/file.txt" should exist And as "Alice" the mtime of the file "testFolder/file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT" @@ -684,7 +684,7 @@ Feature: create a public link share | path | /textfile0.txt | | name | link2 | | expireDateAsString | +5 days | - And the administrator expires the last created share using the testing API + And the administrator expires the last created public link share using the testing API Then the HTTP status code should be "" When user "Alice" gets all the shares from the file "textfile0.txt" using the sharing API Then the HTTP status code should be "" diff --git a/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShareOc10Issue37605.feature b/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShareOc10Issue37605.feature index 42c5ddd513f3..22fd35fbc80f 100644 --- a/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShareOc10Issue37605.feature +++ b/tests/acceptance/features/apiSharePublicLink1/createPublicLinkShareOc10Issue37605.feature @@ -11,7 +11,7 @@ Feature: create a public link share @issue-37605 Scenario: Get the mtime of a file inside a folder shared by public link using new webDAV version - When the public uploads file "file.txt" to the last shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API + When the public uploads file "file.txt" to the last public link shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API Then the HTTP status code should be "201" And as "Alice" file "testFolder/file.txt" should exist And as "Alice" the mtime of the file "testFolder/file.txt" should not be "Thu, 08 Aug 2019 04:18:13 GMT" @@ -22,7 +22,7 @@ Feature: create a public link share @issue-37605 Scenario: overwriting a file changes its mtime (new public webDAV API) Given user "Alice" has uploaded file with content "uploaded content for file name ending with a dot" to "testFolder/file.txt" - When the public uploads file "file.txt" to the last shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API + When the public uploads file "file.txt" to the last public link shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API Then the HTTP status code should be "204" And as "Alice" file "/testFolder/file.txt" should exist And as "Alice" the mtime of the file "testFolder/file.txt" should not be "Thu, 08 Aug 2019 04:18:13 GMT" diff --git a/tests/acceptance/features/apiSharePublicLink2/multilinkSharing.feature b/tests/acceptance/features/apiSharePublicLink2/multilinkSharing.feature index f601c007dca3..236e4309a92e 100644 --- a/tests/acceptance/features/apiSharePublicLink2/multilinkSharing.feature +++ b/tests/acceptance/features/apiSharePublicLink2/multilinkSharing.feature @@ -29,7 +29,7 @@ Feature: multilinksharing | publicUpload | true | | permissions | change | | name | sharedlink3 | - When user "Alice" updates the last share using the sharing API with + When user "Alice" updates the last public link share using the sharing API with | permissions | read | Then the OCS status code should be "" And the HTTP status code should be "200" @@ -64,7 +64,7 @@ Feature: multilinksharing | expireDate | +3 days | | permissions | read | | name | sharedlink3 | - When user "Alice" updates the last share using the sharing API with + When user "Alice" updates the last public link share using the sharing API with | permissions | read | Then the OCS status code should be "" And the HTTP status code should be "200" @@ -95,7 +95,7 @@ Feature: multilinksharing | publicUpload | true | | permissions | change | | name | sharedlink2 | - When user "Alice" updates the last share using the sharing API with + When user "Alice" updates the last public link share using the sharing API with | password | %alt1% | Then the OCS status code should be "" And the HTTP status code should be "200" diff --git a/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToRoot.feature b/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToRoot.feature index 9c99c017a20a..9569e77c41bd 100644 --- a/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToRoot.feature +++ b/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToRoot.feature @@ -36,7 +36,7 @@ Feature: reshare as public link | publicUpload | false | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the public WebDAV API And the downloaded content should be "some content" But uploading a file should not work using the public WebDAV API @@ -94,7 +94,7 @@ Feature: reshare as public link | publicUpload | false | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the public WebDAV API And the downloaded content should be "some content" But uploading a file should not work using the public WebDAV API @@ -122,7 +122,7 @@ Feature: reshare as public link | publicUpload | true | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the public WebDAV API And the downloaded content should be "some content" And uploading a file should work using the public WebDAV API @@ -164,7 +164,7 @@ Feature: reshare as public link | path | /test | | permissions | read | | publicUpload | false | - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "404" And the HTTP status code should be "" @@ -192,7 +192,7 @@ Feature: reshare as public link | permissions | read | | publicUpload | false | And uploading a file should not work using the public WebDAV API - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "404" And the HTTP status code should be "" diff --git a/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesNewDav.feature b/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesNewDav.feature index 093e9f043130..9f4dd1ea2b02 100644 --- a/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesNewDav.feature +++ b/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesNewDav.feature @@ -39,7 +39,7 @@ Feature: reshare as public link | publicUpload | false | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the new public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the new public WebDAV API And the downloaded content should be "some content" But uploading a file should not work using the new public WebDAV API Examples: @@ -91,7 +91,7 @@ Feature: reshare as public link | publicUpload | false | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the new public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the new public WebDAV API And the downloaded content should be "some content" But uploading a file should not work using the new public WebDAV API Examples: @@ -112,7 +112,7 @@ Feature: reshare as public link | publicUpload | true | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the new public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the new public WebDAV API And the downloaded content should be "some content" And uploading a file should work using the new public WebDAV API Examples: @@ -149,7 +149,7 @@ Feature: reshare as public link | path | /Shares/test | | permissions | read | | publicUpload | false | - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "404" And the HTTP status code should be "" @@ -171,7 +171,7 @@ Feature: reshare as public link | permissions | read | | publicUpload | false | And uploading a file should not work using the new public WebDAV API - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "404" And the HTTP status code should be "" diff --git a/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesOldDav.feature b/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesOldDav.feature index 587ba271b059..694d44a1d27f 100644 --- a/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesOldDav.feature +++ b/tests/acceptance/features/apiSharePublicLink2/reShareAsPublicLinkToSharesOldDav.feature @@ -24,7 +24,7 @@ Feature: reshare as public link | publicUpload | false | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the old public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the old public WebDAV API And the downloaded content should be "some content" But uploading a file should not work using the old public WebDAV API Examples: @@ -44,7 +44,7 @@ Feature: reshare as public link | publicUpload | false | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the old public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the old public WebDAV API And the downloaded content should be "some content" But uploading a file should not work using the old public WebDAV API Examples: @@ -65,7 +65,7 @@ Feature: reshare as public link | publicUpload | true | Then the OCS status code should be "" And the HTTP status code should be "200" - And the public should be able to download file "file.txt" from inside the last public shared folder using the old public WebDAV API + And the public should be able to download file "file.txt" from inside the last public link shared folder using the old public WebDAV API And the downloaded content should be "some content" And uploading a file should work using the old public WebDAV API Examples: @@ -84,7 +84,7 @@ Feature: reshare as public link | path | /Shares/test | | permissions | read | | publicUpload | false | - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "404" And the HTTP status code should be "" @@ -106,7 +106,7 @@ Feature: reshare as public link | permissions | read | | publicUpload | false | And uploading a file should not work using the old public WebDAV API - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "404" And the HTTP status code should be "" diff --git a/tests/acceptance/features/apiSharePublicLink3/allowGroupToCreatePublicLinks.feature b/tests/acceptance/features/apiSharePublicLink3/allowGroupToCreatePublicLinks.feature index 0b1fa9c46149..fa35c1f80ca2 100644 --- a/tests/acceptance/features/apiSharePublicLink3/allowGroupToCreatePublicLinks.feature +++ b/tests/acceptance/features/apiSharePublicLink3/allowGroupToCreatePublicLinks.feature @@ -48,7 +48,7 @@ Feature: public share sharers groups setting | permissions | read | And parameter "public_share_sharers_groups_allowlist_enabled" of app "files_sharing" has been set to "yes" And parameter "public_share_sharers_groups_allowlist" of app "files_sharing" has been set to '["grp1"]' - When user "Alice" updates the last share using the sharing API with + When user "Alice" updates the last public link share using the sharing API with | expireDate | +3 days | Then the HTTP status code should be "200" And the OCS status code should be "100" diff --git a/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShare.feature b/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShare.feature index 1e156bd7e4d4..cb2218ab0173 100644 --- a/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShare.feature +++ b/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShare.feature @@ -11,7 +11,7 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - When user "Alice" updates the last share using the sharing API with + When user "Alice" updates the last public link share using the sharing API with | expireDate | +3 days | Then the OCS status code should be "" And the OCS status message should be "Ok" @@ -51,9 +51,9 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | expireDate | +3 days | - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -86,7 +86,7 @@ Feature: update a public link share And user "Alice" has created a public link share with settings | path | FOLDER | And user "Alice" has moved folder "/FOLDER" to "/RENAMED_FOLDER" - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -129,7 +129,7 @@ Feature: update a public link share And user "Alice" has created a public link share with settings | path | randomfile.txt | | password | %public% | - When user "Alice" updates the last share using the sharing API with + When user "Alice" updates the last public link share using the sharing API with | expireDate | +3 days | Then the OCS status code should be "" And the HTTP status code should be "200" @@ -153,9 +153,9 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | expireDate | +3 days | - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -186,9 +186,9 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | password | %public% | - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -218,9 +218,9 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | permissions | read,update,create,delete | - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -250,9 +250,9 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | permissions | read,update,create,delete | - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -282,9 +282,9 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | publicUpload | true | - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -320,7 +320,7 @@ Feature: update a public link share And user "Brian" has created a public link share with settings | path | /Shares/test | | publicUpload | false | - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | publicUpload | true | Then the OCS status code should be "404" And the HTTP status code should be "" @@ -350,7 +350,7 @@ Feature: update a public link share And user "Brian" has created a public link share with settings | path | /Shares/test | | publicUpload | false | - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | publicUpload | true | Then the OCS status code should be "" And the HTTP status code should be "200" @@ -380,7 +380,7 @@ Feature: update a public link share And user "Brian" has created a public link share with settings | path | /Shares/test | | permissions | read | - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "404" And the HTTP status code should be "" @@ -410,7 +410,7 @@ Feature: update a public link share And user "Brian" has created a public link share with settings | path | /Shares/test | | permissions | read | - When user "Brian" updates the last share using the sharing API with + When user "Brian" updates the last public link share using the sharing API with | permissions | read,update,create,delete | Then the OCS status code should be "" And the HTTP status code should be "200" @@ -437,9 +437,9 @@ Feature: update a public link share And user "Alice" has created a public link share with settings | path | /PARENT | | permissions | read,update,create,delete | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | permissions | read | - When the public deletes file "CHILD/child.txt" from the last public share using the public WebDAV API + When the public deletes file "CHILD/child.txt" from the last public link share using the public WebDAV API Then the HTTP status code should be "403" And as "Alice" file "PARENT/CHILD/child.txt" should exist @@ -465,10 +465,10 @@ Feature: update a public link share And user "Alice" has created a public link share with settings | path | /PARENT | | permissions | read | - And user "Alice" has updated the last share with + And user "Alice" has updated the last public link share with | permissions | read,update,create,delete | - When the public deletes file "CHILD/child.txt" from the last public share using the public WebDAV API - And the public deletes file "parent.txt" from the last public share using the public WebDAV API + When the public deletes file "CHILD/child.txt" from the last public link share using the public WebDAV API + And the public deletes file "parent.txt" from the last public link share using the public WebDAV API Then the HTTP status code of responses on all endpoints should be "204" And as "Alice" file "PARENT/CHILD/child.txt" should not exist And as "Alice" file "PARENT/parent.txt" should not exist @@ -493,7 +493,7 @@ Feature: update a public link share And user "Alice" has created a public link share with settings | path | FOLDER | And user "Alice" has moved folder "/FOLDER" to "/RENAMED_FOLDER" - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -539,7 +539,7 @@ Feature: update a public link share And user "Alice" has created a public link share with settings | path | lorem.txt | And user "Alice" has moved file "/lorem.txt" to "/new-lorem.txt" - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include @@ -583,7 +583,7 @@ Feature: update a public link share And user "Alice" has created a public link share with settings | path | lorem.txt | And user "Alice" has moved file "/lorem.txt" to "/new-lorem.txt" - When user "Alice" gets the info of the last share using the sharing API + When user "Alice" gets the info of the last public link share using the sharing API Then the OCS status code should be "" And the HTTP status code should be "200" And the fields of the last response to user "Alice" should include diff --git a/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShareOc10Issue37653.feature b/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShareOc10Issue37653.feature index d56d55130abf..bea3766b6223 100644 --- a/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShareOc10Issue37653.feature +++ b/tests/acceptance/features/apiSharePublicLink3/updatePublicLinkShareOc10Issue37653.feature @@ -11,7 +11,7 @@ Feature: update a public link share And user "Alice" has created folder "FOLDER" And user "Alice" has created a public link share with settings | path | FOLDER | - When user "Alice" updates the last share using the sharing API with + When user "Alice" updates the last public link share using the sharing API with | expireDate | +3 days | Then the OCS status code should be "" And the OCS status message should be "" diff --git a/tests/acceptance/features/apiWebdavEtagPropagation1/deleteFileFolder.feature b/tests/acceptance/features/apiWebdavEtagPropagation1/deleteFileFolder.feature index e60d8bd6f6a8..690a6fdd70bc 100644 --- a/tests/acceptance/features/apiWebdavEtagPropagation1/deleteFileFolder.feature +++ b/tests/acceptance/features/apiWebdavEtagPropagation1/deleteFileFolder.feature @@ -240,7 +240,7 @@ Feature: propagation of etags when deleting a file or folder | permissions | change | And user "Alice" has stored etag of element "/" And user "Alice" has stored etag of element "/upload" - When the public deletes file "file.txt" from the last public share using the new public WebDAV API + When the public deletes file "file.txt" from the last public link share using the new public WebDAV API Then the HTTP status code should be "204" And these etags should have changed: | user | path | @@ -265,7 +265,7 @@ Feature: propagation of etags when deleting a file or folder | permissions | change | And user "Alice" has stored etag of element "/" And user "Alice" has stored etag of element "/upload" - When the public deletes folder "sub" from the last public share using the new public WebDAV API + When the public deletes folder "sub" from the last public link share using the new public WebDAV API Then the HTTP status code should be "204" And these etags should have changed: | user | path | diff --git a/tests/acceptance/features/apiWebdavEtagPropagation1/moveFileFolder.feature b/tests/acceptance/features/apiWebdavEtagPropagation1/moveFileFolder.feature index d818f7bfb667..b97e30e7f42e 100644 --- a/tests/acceptance/features/apiWebdavEtagPropagation1/moveFileFolder.feature +++ b/tests/acceptance/features/apiWebdavEtagPropagation1/moveFileFolder.feature @@ -396,7 +396,7 @@ Feature: propagation of etags when moving files or folders | permissions | change | And user "Alice" has stored etag of element "/" And user "Alice" has stored etag of element "/upload" - When the public renames file "file.txt" to "renamed.txt" from the last public share using the new public WebDAV API + When the public renames file "file.txt" to "renamed.txt" from the last public link share using the new public WebDAV API Then the HTTP status code should be "201" And these etags should have changed: | user | path | @@ -422,7 +422,7 @@ Feature: propagation of etags when moving files or folders | permissions | change | And user "Alice" has stored etag of element "/" And user "Alice" has stored etag of element "/upload" - When the public renames folder "sub" to "renamed" from the last public share using the new public WebDAV API + When the public renames folder "sub" to "renamed" from the last public link share using the new public WebDAV API Then the HTTP status code should be "201" And these etags should have changed: | user | path | diff --git a/tests/acceptance/features/apiWebdavLocks/publicLink.feature b/tests/acceptance/features/apiWebdavLocks/publicLink.feature index 0b86b0d24a41..1814e571bf76 100644 --- a/tests/acceptance/features/apiWebdavLocks/publicLink.feature +++ b/tests/acceptance/features/apiWebdavLocks/publicLink.feature @@ -99,7 +99,7 @@ Feature: persistent-locking in case of a public link @smokeTest @skipOnOcV10.3 Scenario Outline: Public locking is not supported Given user "Alice" has created a public link share of folder "PARENT" with change permission - When the public locks "/CHILD" in the last public shared folder using the public WebDAV API setting the following properties + When the public locks "/CHILD" in the last public link shared folder using the public WebDAV API setting the following properties | lockscope | | Then the HTTP status code should be "405" And the value of the item "//s:message" in the response should be "Locking not allowed from public endpoint" diff --git a/tests/acceptance/features/bootstrap/AppConfigurationContext.php b/tests/acceptance/features/bootstrap/AppConfigurationContext.php index bad7df8dccd6..c2b8ee3d3c92 100644 --- a/tests/acceptance/features/bootstrap/AppConfigurationContext.php +++ b/tests/acceptance/features/bootstrap/AppConfigurationContext.php @@ -577,20 +577,35 @@ public function theTrustedServerListShouldBeEmpty():void { } /** - * Expires last created share using the testing API + * Expires last created public link share using the testing API * * @return void * @throws GuzzleException */ - public function expireLastCreatedUserShare():void { + public function expireLastCreatedPublicLinkShare():void { + $shareId = $this->featureContext->getLastPublicLinkShareId(); + $this->expireShare($shareId); + } + + /** + * Expires a share using the testing API + * + * @param string|null $shareId optional share id, if null then expire the last share that was created. + * + * @return void + * @throws GuzzleException + */ + public function expireShare(string $shareId = null):void { $adminUser = $this->featureContext->getAdminUsername(); - $share_id = $this->featureContext->getLastShareId(); + if ($shareId === null) { + $shareId = $this->featureContext->getLastShareId(); + } $response = OcsApiHelper::sendRequest( $this->featureContext->getBaseUrl(), $adminUser, $this->featureContext->getAdminPassword(), 'POST', - "/apps/testing/api/v1/expire-share/{$share_id}", + "/apps/testing/api/v1/expire-share/{$shareId}", $this->featureContext->getStepLineRef(), [], $this->featureContext->getOcsApiVersion() @@ -605,7 +620,7 @@ public function expireLastCreatedUserShare():void { * @throws GuzzleException */ public function theAdministratorHasExpiredTheLastCreatedShare():void { - $this->expireLastCreatedUserShare(); + $this->expireShare(); Assert::assertSame( 200, $this->featureContext->getResponse()->getStatusCode(), @@ -613,6 +628,21 @@ public function theAdministratorHasExpiredTheLastCreatedShare():void { ); } + /** + * @Given the administrator has expired the last created public link share using the testing API + * + * @return void + * @throws GuzzleException + */ + public function theAdministratorHasExpiredTheLastCreatedPublicLinkShare():void { + $this->expireLastCreatedPublicLinkShare(); + Assert::assertSame( + 200, + $this->featureContext->getResponse()->getStatusCode(), + "Request to expire last public link share failed." + ); + } + /** * @When the administrator expires the last created share using the testing API * @@ -620,7 +650,17 @@ public function theAdministratorHasExpiredTheLastCreatedShare():void { * @throws GuzzleException */ public function theAdministratorExpiresTheLastCreatedShare():void { - $this->expireLastCreatedUserShare(); + $this->expireShare(); + } + + /** + * @When the administrator expires the last created public link share using the testing API + * + * @return void + * @throws GuzzleException + */ + public function theAdministratorExpiresTheLastCreatedPublicLinkShare():void { + $this->expireLastCreatedPublicLinkShare(); } /** diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index f44567e5f35e..19c2063b17b3 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -3176,10 +3176,10 @@ public function substituteInLineCodes( "parameter" => [] ], [ - "code" => "%last_share_token%", + "code" => "%last_public_share_token%", "function" => [ $this, - "getLastSharetoken" + "getLastPublicShareToken" ], "parameter" => [] ] diff --git a/tests/acceptance/features/bootstrap/Provisioning.php b/tests/acceptance/features/bootstrap/Provisioning.php index 39cbb9e294f2..e6e2de5b187d 100644 --- a/tests/acceptance/features/bootstrap/Provisioning.php +++ b/tests/acceptance/features/bootstrap/Provisioning.php @@ -924,7 +924,6 @@ public function setLdapSetting(string $configId, string $configKey, string $conf * @throws Exception */ public function deleteLdapUsersAndGroups():void { - // pdd $isOcisOrReva = OcisHelper::isTestingOnOcisOrReva(); foreach ($this->ldapCreatedUsers as $user) { if ($isOcisOrReva) { diff --git a/tests/acceptance/features/bootstrap/PublicWebDavContext.php b/tests/acceptance/features/bootstrap/PublicWebDavContext.php index a701652d7d7b..9d0d54809491 100644 --- a/tests/acceptance/features/bootstrap/PublicWebDavContext.php +++ b/tests/acceptance/features/bootstrap/PublicWebDavContext.php @@ -45,7 +45,7 @@ class PublicWebDavContext implements Context { private $occContext; /** - * @When /^the public downloads the last public shared file with range "([^"]*)" using the (old|new) public WebDAV API$/ + * @When /^the public downloads the last public link shared file with range "([^"]*)" using the (old|new) public WebDAV API$/ * * @param string $range ignore if empty * @param string $publicWebDAVAPIVersion @@ -55,7 +55,7 @@ class PublicWebDavContext implements Context { */ public function downloadPublicFileWithRange(string $range, string $publicWebDAVAPIVersion, ?string $password = ""):void { if ($publicWebDAVAPIVersion === "new") { - $path = (string)$this->featureContext->getLastShareData()->data->file_target; + $path = (string)$this->featureContext->getLastPublicShareData()->data->file_target; } else { $path = ""; } @@ -68,7 +68,7 @@ public function downloadPublicFileWithRange(string $range, string $publicWebDAVA } /** - * @When /^the public downloads the last public shared file with range "([^"]*)" and password "([^"]*)" using the (old|new) public WebDAV API$/ + * @When /^the public downloads the last public link shared file with range "([^"]*)" and password "([^"]*)" using the (old|new) public WebDAV API$/ * * @param string $range ignore if empty * @param string $password @@ -78,7 +78,7 @@ public function downloadPublicFileWithRange(string $range, string $publicWebDAVA */ public function downloadPublicFileWithRangeAndPassword(string $range, string $password, string $publicWebDAVAPIVersion):void { if ($publicWebDAVAPIVersion === "new") { - $path = $this->featureContext->getLastShareData()->data->file_target; + $path = $this->featureContext->getLastPublicShareData()->data->file_target; } else { $path = ""; } @@ -91,7 +91,7 @@ public function downloadPublicFileWithRangeAndPassword(string $range, string $pa } /** - * @When /^the public downloads the last public shared file using the (old|new) public WebDAV API$/ + * @When /^the public downloads the last public link shared file using the (old|new) public WebDAV API$/ * * @param string $publicWebDAVAPIVersion * @@ -102,7 +102,7 @@ public function downloadPublicFile(string $publicWebDAVAPIVersion):void { } /** - * @When /^the public downloads the last public shared file with password "([^"]*)" using the (old|new) public WebDAV API$/ + * @When /^the public downloads the last public link shared file with password "([^"]*)" using the (old|new) public WebDAV API$/ * * @param string $password * @param string $publicWebDAVAPIVersion @@ -114,7 +114,7 @@ public function downloadPublicFileWithPassword(string $password, string $publicW } /** - * @When /^the public deletes (?:file|folder|entry) "([^"]*)" from the last public share using the (old|new) public WebDAV API$/ + * @When /^the public deletes (?:file|folder|entry) "([^"]*)" from the last public link share using the (old|new) public WebDAV API$/ * * @param string $fileName * @param string $publicWebDAVAPIVersion @@ -123,7 +123,7 @@ public function downloadPublicFileWithPassword(string $password, string $publicW * @return void */ public function deleteFileFromPublicShare(string $fileName, string $publicWebDAVAPIVersion, string $password = ""):void { - $token = (string) $this->featureContext->getLastShareData()->data->token; + $token = $this->featureContext->getLastPublicShareToken(); $davPath = WebDavHelper::getDavPath( $token, 0, @@ -151,7 +151,7 @@ public function deleteFileFromPublicShare(string $fileName, string $publicWebDAV } /** - * @When /^the public deletes file "([^"]*)" from the last public share using the password "([^"]*)" and (old|new) public WebDAV API$/ + * @When /^the public deletes file "([^"]*)" from the last public link share using the password "([^"]*)" and (old|new) public WebDAV API$/ * * @param string $file * @param string $password @@ -164,7 +164,7 @@ public function thePublicDeletesFileFromTheLastPublicShareUsingThePasswordPasswo } /** - * @When /^the public renames (?:file|folder|entry) "([^"]*)" to "([^"]*)" from the last public share using the (old|new) public WebDAV API$/ + * @When /^the public renames (?:file|folder|entry) "([^"]*)" to "([^"]*)" from the last public link share using the (old|new) public WebDAV API$/ * * @param string $fileName * @param string $toFileName @@ -174,7 +174,7 @@ public function thePublicDeletesFileFromTheLastPublicShareUsingThePasswordPasswo * @return void */ public function renameFileFromPublicShare(string $fileName, string $toFileName, string $publicWebDAVAPIVersion, ?string $password = ""):void { - $token = (string)$this->featureContext->getLastShareData()->data->token; + $token = $this->featureContext->getLastPublicShareToken(); $davPath = WebDavHelper::getDavPath( $token, 0, @@ -204,7 +204,7 @@ public function renameFileFromPublicShare(string $fileName, string $toFileName, } /** - * @When /^the public renames file "([^"]*)" to "([^"]*)" from the last public share using the password "([^"]*)" and (old|new) public WebDAV API$/ + * @When /^the public renames file "([^"]*)" to "([^"]*)" from the last public link share using the password "([^"]*)" and (old|new) public WebDAV API$/ * * @param string $fileName * @param string $toName @@ -218,7 +218,7 @@ public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswo } /** - * @When /^the public downloads file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API$/ + * @When /^the public downloads file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API$/ * * @param string $path * @param string $publicWebDAVAPIVersion @@ -235,7 +235,7 @@ public function downloadPublicFileInsideAFolder(string $path, string $publicWebD } /** - * @When /^the public downloads file "([^"]*)" from inside the last public shared folder with password "([^"]*)" using the (old|new) public WebDAV API$/ + * @When /^the public downloads file "([^"]*)" from inside the last public link shared folder with password "([^"]*)" using the (old|new) public WebDAV API$/ * * @param string $path * @param string|null $password @@ -257,7 +257,7 @@ public function publicDownloadsTheFileInsideThePublicSharedFolderWithPassword( } /** - * @When /^the public downloads file "([^"]*)" from inside the last public shared folder with range "([^"]*)" using the (old|new) public WebDAV API$/ + * @When /^the public downloads file "([^"]*)" from inside the last public link shared folder with range "([^"]*)" using the (old|new) public WebDAV API$/ * * @param string $path * @param string $range @@ -275,7 +275,7 @@ public function downloadPublicFileInsideAFolderWithRange(string $path, string $r } /** - * @When /^the public downloads file "([^"]*)" from inside the last public shared folder with password "([^"]*)" with range "([^"]*)" using the (old|new) public WebDAV API$/ + * @When /^the public downloads file "([^"]*)" from inside the last public link shared folder with password "([^"]*)" with range "([^"]*)" using the (old|new) public WebDAV API$/ * * @param string $path * @param string $password @@ -292,7 +292,7 @@ public function publicDownloadsTheFileInsideThePublicSharedFolderWithPasswordAnd ):void { $path = \ltrim($path, "/"); $password = $this->featureContext->getActualPassword($password); - $token = (string) $this->featureContext->getLastShareData()->data->token; + $token = $this->featureContext->getLastPublicShareToken(); $davPath = WebDavHelper::getDavPath( $token, 0, @@ -403,7 +403,7 @@ public function publiclyCopyingFile( * @return void */ public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $destination, string $publicWebDAVAPIVersion):void { - $token = (string) $this->featureContext->getLastShareData()->data->token; + $token = $this->featureContext->getLastPublicShareToken(); $davPath = WebDavHelper::getDavPath( $token, 0, @@ -782,7 +782,7 @@ public function theLastPublicSharedFileShouldNotBeAbleToBeDownloadedWithoutAPass } /** - * @Then /^the public should be able to download file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API$/ + * @Then /^the public should be able to download file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API$/ * * @param string $path * @param string $publicWebDAVAPIVersion @@ -802,8 +802,8 @@ public function shouldBeAbleToDownloadFileInsidePublicSharedFolder( } /** - * @Then /^the public should not be able to download file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API without a password$/ - * @Then /^the public download of file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API should fail with HTTP status code "([^"]*)"$/ + * @Then /^the public should not be able to download file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API without a password$/ + * @Then /^the public download of file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API should fail with HTTP status code "([^"]*)"$/ * * @param string $path * @param string $publicWebDAVAPIVersion @@ -826,7 +826,7 @@ public function shouldNotBeAbleToDownloadFileInsidePublicSharedFolder( } /** - * @Then /^the public should be able to download file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ + * @Then /^the public should be able to download file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ * * @param string $path * @param string $publicWebDAVAPIVersion @@ -848,7 +848,7 @@ public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPassword( } /** - * @Then /^the public should be able to download file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)" and the content should be "([^"]*)" plus end-of-line$/ + * @Then /^the public should be able to download file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)" and the content should be "([^"]*)" plus end-of-line$/ * * @param string $path * @param string $publicWebDAVAPIVersion @@ -885,8 +885,8 @@ public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPasswordAn } /** - * @Then /^the public should not be able to download file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ - * @Then /^the public download of file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)" should fail with HTTP status code "([^"]*)"$/ + * @Then /^the public should not be able to download file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ + * @Then /^the public download of file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)" should fail with HTTP status code "([^"]*)"$/ * * @param string $path * @param string $publicWebDAVAPIVersion @@ -911,7 +911,7 @@ public function shouldNotBeAbleToDownloadFileInsidePublicSharedFolderWithPasswor } /** - * @Then /^the public should be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)""$/ + * @Then /^the public should be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)""$/ * * @param string $range * @param string $path @@ -943,7 +943,7 @@ public function shouldBeAbleToDownloadRangeOfFileInsidePublicSharedFolderWithPas } /** - * @Then /^the public should not be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ + * @Then /^the public should not be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ * * @param string $range * @param string $path @@ -989,7 +989,7 @@ public function shouldNotBeAbleToDownloadRangeOfFileInsidePublicSharedFolderWith } /** - * @Then /^the public should be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API and the content should be "([^"]*)"$/ + * @Then /^the public should be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API and the content should be "([^"]*)"$/ * * @param string $range * @param string $path @@ -1015,7 +1015,7 @@ public function shouldBeAbleToDownloadRangeOfFileInsidePublicSharedFolder( } /** - * @Then /^the public should not be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public shared folder using the (old|new) public WebDAV API without a password$/ + * @Then /^the public should not be able to download the range "([^"]*)" of file "([^"]*)" from inside the last public link shared folder using the (old|new) public WebDAV API without a password$/ * * @param string $range * @param string $path @@ -1053,7 +1053,7 @@ public function publiclyUploadingShouldToSharedFileShouldFail( $filename = ""; if ($publicWebDAVAPIVersion === "new") { - $filename = (string)$this->featureContext->getLastShareData()->data[0]->file_target; + $filename = (string)$this->featureContext->getLastPublicShareData()->data[0]->file_target; $techPreviewHadToBeEnabled = $this->occContext->enableDAVTechPreview(); } else { $techPreviewHadToBeEnabled = false; @@ -1120,7 +1120,7 @@ public function publiclyUploadingShouldNotWork( } /** - * @Then /^the public should be able to upload file "([^"]*)" into the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ + * @Then /^the public should be able to upload file "([^"]*)" into the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)"$/ * * @param string $filename * @param string $publicWebDAVAPIVersion @@ -1146,7 +1146,7 @@ public function publiclyUploadingIntoFolderWithPasswordShouldWork( } /** - * @Then /^the public upload of file "([^"]*)" into the last public shared folder using the (old|new) public WebDAV API with password "([^"]*)" should fail with HTTP status code "([^"]*)"$/ + * @Then /^the public upload of file "([^"]*)" into the last public link shared folder using the (old|new) public WebDAV API with password "([^"]*)" should fail with HTTP status code "([^"]*)"$/ * * @param string $filename * @param string $publicWebDAVAPIVersion @@ -1222,7 +1222,7 @@ public function publiclyUploadingShouldWork(string $publicWebDAVAPIVersion):void } /** - * @When the public uploads file :fileName to the last shared folder with mtime :mtime using the :davVersion public WebDAV API + * @When the public uploads file :fileName to the last public link shared folder with mtime :mtime using the :davVersion public WebDAV API * * @param String $fileName * @param String $mtime @@ -1259,7 +1259,7 @@ public function publicCreatesFolderUsingPassword( string $destination, string $password ):void { - $token = $this->featureContext->getLastShareToken(); + $token = $this->featureContext->getLastPublicShareToken(); $davPath = WebDavHelper::getDavPath( $token, 0, @@ -1301,7 +1301,7 @@ public function publicCreatesFolder(string $destination):void { } /** - * @Then /^the public should be able to create folder "([^"]*)" in the last public shared folder using the new public WebDAV API with password "([^"]*)"$/ + * @Then /^the public should be able to create folder "([^"]*)" in the last public link shared folder using the new public WebDAV API with password "([^"]*)"$/ * * @param string $foldername * @param string $password @@ -1317,7 +1317,7 @@ public function publicShouldBeAbleToCreateFolderWithPassword( } /** - * @Then /^the public creation of folder "([^"]*)" in the last public shared folder using the new public WebDAV API with password "([^"]*)" should fail with HTTP status code "([^"]*)"$/ + * @Then /^the public creation of folder "([^"]*)" in the last public link shared folder using the new public WebDAV API with password "([^"]*)" should fail with HTTP status code "([^"]*)"$/ * * @param string $foldername * @param string $password @@ -1351,8 +1351,7 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldBe string $fileName, string $mtime ):void { - $tokenArray = $this->featureContext->getLastShareData()->data->token; - $token = (string)$tokenArray[0]; + $token = $this->featureContext->getLastPublicShareToken(); $baseUrl = $this->featureContext->getBaseUrl(); if (\TestHelpers\OcisHelper::isTestingOnOcisOrReva()) { $mtime = \explode(" ", $mtime); @@ -1393,8 +1392,7 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldNo string $fileName, string $mtime ):void { - $tokenArray = $this->featureContext->getLastShareData()->data->token; - $token = (string)$tokenArray[0]; + $token = $this->featureContext->getLastPublicShareToken(); $baseUrl = $this->featureContext->getBaseUrl(); Assert::assertNotEquals( $mtime, @@ -1428,7 +1426,7 @@ public function publicUploadContent( string $publicWebDAVAPIVersion = "old" ):void { $password = $this->featureContext->getActualPassword($password); - $token = $this->featureContext->getLastShareToken(); + $token = $this->featureContext->getLastPublicShareToken(); $davPath = WebDavHelper::getDavPath( $token, 0, diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index 8e2661cffee3..ed99d82d45f8 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -44,9 +44,47 @@ trait Sharing { private $sharingApiVersion = 1; /** + * Contains the API response to the last share that was created by each user + * using the Sharing API. Shares created on the webUI do not have an entry. + * + * @var SimpleXMLElement[] + */ + private $lastShareDataByUser = []; + + /** + * Contains the share id of the last share that was created by each user, + * either using the Sharing API or on the web UI. + * + * @var string[] + */ + private $lastShareIdByUser = []; + + /** + * @var string + */ + private $userWhoCreatedLastShare = null; + + /** + * @var string + */ + private $userWhoCreatedLastPublicShare = null; + + /** + * Contains the API response to the last public link share that was created + * by the test-runner using the Sharing API. + * Shares created on the webUI do not have an entry. + * * @var SimpleXMLElement */ - private $lastShareData = null; + private $lastPublicShareData = null; + + /** + * Contains the share id of the last public link share that was created by + * the test-runner, either using the Sharing API or on the web UI. + * + * @var string + */ + private $lastPublicShareId = null; /** * @var int @@ -94,11 +132,38 @@ public function getCreatedPublicLinks():array { return $this->createdPublicLinks; } + /** + * @return SimpleXMLElement|null + */ + public function getLastPublicShareData():?SimpleXMLElement { + return $this->lastPublicShareData; + } + /** * @return SimpleXMLElement + * @throws Exception */ public function getLastShareData():SimpleXMLElement { - return $this->lastShareData; + return $this->getLastShareDataForUser($this->userWhoCreatedLastShare); + } + + /** + * @param string|null $user + * + * @return SimpleXMLElement + * @throws Exception + */ + public function getLastShareDataForUser(?string $user):SimpleXMLElement { + if ($user === null) { + throw new Exception( + __METHOD__ . " user not specified. Probably no user or group shares have been created yet in the test scenario." + ); + } + if (isset($this->lastShareDataByUser[$user])) { + return $this->lastShareDataByUser[$user]; + } else { + throw new Exception(__METHOD__ . " last share data for user '$user' was not found"); + } } /** @@ -111,8 +176,24 @@ public function getSavedShareId():?int { /** * @return void */ - public function resetLastShareData():void { - $this->lastShareData = null; + public function resetLastPublicShareData():void { + $this->lastPublicShareData = null; + $this->lastPublicShareId = null; + $this->userWhoCreatedLastPublicShare = null; + } + + /** + * @param string $user + * + * @return void + */ + public function resetLastShareInfoForUser(string $user):void { + if (isset($this->lastShareDataByUser[$user])) { + unset($this->lastShareDataByUser[$user]); + } + if (isset($this->lastShareIdByUser[$user])) { + unset($this->lastShareIdByUser[$user]); + } } /** @@ -126,7 +207,7 @@ public function getLocalLastShareTime():int { * @return int */ public function getServerLastShareTime():int { - return (int) $this->lastShareData->data->stime; + return (int) $this->getLastShareData()->data->stime; } /** @@ -752,7 +833,7 @@ public function aPublicLinkShareOfHasCreatedWithExpiry( * @return string */ public function getMimeTypeOfLastSharedFile():string { - return \json_decode(\json_encode($this->lastShareData->data->mimetype), true)[0]; + return \json_decode(\json_encode($this->getLastShareData()->data->mimetype), true)[0]; } /** @@ -873,17 +954,27 @@ public function theUserHasUpdatedTheLastShareWith(?TableNode $body):void { * @param string $user * @param TableNode|null $body * @param string|null $shareOwner + * @param bool $updateLastPublicLink * * @return void * @throws Exception */ - public function updateLastShareWithSettings(string $user, ?TableNode $body, ?string $shareOwner = null):void { + public function updateLastShareWithSettings( + string $user, + ?TableNode $body, + ?string $shareOwner = null, + ?bool $updateLastPublicLink = false + ):void { $user = $this->getActualUsername($user); - if ($shareOwner === null) { - $share_id = $this->lastShareData->data[0]->id; + if ($updateLastPublicLink) { + $share_id = $this->getLastPublicLinkShareId(); } else { - $share_id = $this->getLastShareIdOf($shareOwner); + if ($shareOwner === null) { + $share_id = $this->getLastShareId(); + } else { + $share_id = $this->getLastShareIdForUser($shareOwner); + } } $this->verifyTableNodeRows( @@ -934,6 +1025,20 @@ public function userUpdatesTheLastShareWith(string $user, ?TableNode $body):void $this->pushToLastStatusCodesArrays(); } + /** + * @When /^user "([^"]*)" updates the last public link share using the sharing API with$/ + * + * @param string $user + * @param TableNode|null $body + * + * @return void + * @throws Exception + */ + public function userUpdatesTheLastPublicLinkShareWith(string $user, ?TableNode $body):void { + $this->updateLastShareWithSettings($user, $body, null, true); + $this->pushToLastStatusCodesArrays(); + } + /** * @Given /^user "([^"]*)" has updated the last share with$/ * @@ -948,6 +1053,20 @@ public function userHasUpdatedTheLastShareWith(string $user, ?TableNode $body):v $this->theHTTPStatusCodeShouldBeSuccess(); } + /** + * @Given /^user "([^"]*)" has updated the last public link share with$/ + * + * @param string $user + * @param TableNode|null $body + * + * @return void + * @throws Exception + */ + public function userHasUpdatedTheLastPublicLinkShareWith(string $user, ?TableNode $body):void { + $this->updateLastShareWithSettings($user, $body, null, true); + $this->theHTTPStatusCodeShouldBeSuccess(); + } + /** * @Given /^user "([^"]*)" has updated the last share of "([^"]*)" with$/ * @@ -1030,15 +1149,37 @@ public function createShare( $this->sharingApiVersion, $sharingApp ); - // In case of HTTP status code 204, there is no content in response payload body. - if ($this->response->getStatusCode() === 204) { - $this->lastShareData = null; + $httpStatusCode = $this->response->getStatusCode(); + // In case of HTTP status code 204 "no content", or a failure code like 4xx + // in the HTTP or OCS status there is no useful content in response payload body. + // Clear the test-runner's memory of "last share data" to avoid later steps + // accidentally using some previous share data. + if (($httpStatusCode === 204) + || !$this->theHTTPStatusCodeWasSuccess() + || (($httpStatusCode === 200) && ($this->ocsContext->getOCSResponseStatusCode($this->response) > 299)) + ) { + if ($shareType === 'public_link') { + $this->lastPublicShareData = null; + $this->lastPublicShareId = null; + $this->userWhoCreatedLastPublicShare = null; + } else { + $this->resetLastShareInfoForUser($user); + } } else { - $this->lastShareData = $this->getResponseXml(null, __METHOD__); - if ($shareType === 'public_link' && isset($this->lastShareData->data)) { - $linkName = (string) $this->lastShareData->data[0]->name; - $linkUrl = (string) $this->lastShareData->data[0]->url; - $this->addToListOfCreatedPublicLinks($linkName, $linkUrl); + if ($shareType === 'public_link') { + $this->lastPublicShareData = $this->getResponseXml(null, __METHOD__); + $this->setLastPublicLinkShareId((string) $this->lastPublicShareData->data[0]->id); + $this->userWhoCreatedLastPublicShare = $user; + if (isset($this->lastPublicShareData->data)) { + $linkName = (string) $this->lastPublicShareData->data[0]->name; + $linkUrl = (string) $this->lastPublicShareData->data[0]->url; + $this->addToListOfCreatedPublicLinks($linkName, $linkUrl); + } + } else { + $shareData = $this->getResponseXml(null, __METHOD__); + $this->lastShareDataByUser[$user] = $shareData; + $shareId = (string) $shareData->data[0]->id; + $this->setLastShareIdOf($user, $shareId); } } $this->localLastShareTime = \microtime(true); @@ -1746,6 +1887,19 @@ public function userTriesToUpdateTheLastShareUsingTheSharingApiWith(string $user $this->updateLastShareWithSettings($user, $body); } + /** + * @When /^user "([^"]*)" tries to update the last public link share using the sharing API with$/ + * + * @param string $user + * @param TableNode|null $body + * + * @return void + * @throws Exception + */ + public function userTriesToUpdateTheLastPublicLinkShareUsingTheSharingApiWith(string $user, ?TableNode $body):void { + $this->updateLastShareWithSettings($user, $body, null, true); + } + /** * @Then /^user "([^"]*)" should not be able to share (file|folder|entry) "([^"]*)" with (user|group) "([^"]*)"(?: with permissions (\d+))? using the sharing API$/ * @Then /^user "([^"]*)" should not be able to share (file|folder|entry) "([^"]*)" with (user|group) "([^"]*)" with permissions "([^"]*)" using the sharing API$/ @@ -1850,13 +2004,17 @@ public function theUserHasDeletedLastShareUsingTheSharingAPI():void { /** * @param string $user + * @param string|null $sharer * * @return void */ - public function deleteLastShareUsingSharingApi(string $user):void { + public function deleteLastShareUsingSharingApi(string $user, string $sharer = null):void { $user = $this->getActualUsername($user); - $share_id = $this->lastShareData->data[0]->id; - $url = $this->getSharesEndpointPath("/$share_id"); + if ($sharer === null) { + $sharer = $user; + } + $shareId = $this->getLastShareIdForUser($sharer); + $url = $this->getSharesEndpointPath("/$shareId"); $this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody( $user, "DELETE", @@ -1885,6 +2043,20 @@ public function userDeletesLastShareUsingTheSharingApi(string $user):void { $this->pushToLastStatusCodesArrays(); } + /** + * @When /^user "([^"]*)" deletes the last share of user "([^"]*)" using the sharing API$/ + * @When /^user "([^"]*)" tries to delete the last share of user "([^"]*)" using the sharing API$/ + * + * @param string $user + * @param string $sharer + * + * @return void + */ + public function userDeletesLastShareOfUserUsingTheSharingApi(string $user, string $sharer):void { + $this->deleteLastShareUsingSharingApi($user, $sharer); + $this->pushToLastStatusCodesArrays(); + } + /** * @Given /^user "([^"]*)" has deleted the last share$/ * @@ -1918,13 +2090,42 @@ public function theUserGetsInfoOfLastShareUsingTheSharingApi():void { * @throws Exception */ public function userGetsInfoOfLastShareUsingTheSharingApi(string $user, ?string $language = null):void { - if (isset($this->lastShareData->data[0]->id)) { - $share_id = $this->lastShareData->data[0]->id; + $shareId = $this->getLastShareId(); + $language = TranslationHelper::getLanguage($language); + $this->getShareData($user, $shareId, $language); + $this->pushToLastStatusCodesArrays(); + } + + /** + * @When /^the user gets the info of the last public link share using the sharing API$/ + * + * @return void + * @throws Exception + */ + public function theUserGetsInfoOfLastPublicLinkShareUsingTheSharingApi():void { + $this->userGetsInfoOfLastPublicLinkShareUsingTheSharingApi($this->userWhoCreatedLastPublicShare); + } + + /** + * @When /^user "([^"]*)" gets the info of the last public link share in language "([^"]*)" using the sharing API$/ + * @When /^user "([^"]*)" gets the info of the last public link share using the sharing API$/ + * + * @param string $user username that requests the information (might not be the user that has initiated the share) + * @param string|null $language + * + * @return void + * @throws Exception + */ + public function userGetsInfoOfLastPublicLinkShareUsingTheSharingApi(string $user, ?string $language = null):void { + if ($this->lastPublicShareId !== null) { + $shareId = $this->lastPublicShareId; } else { - $share_id = $this->getLastShareIdOf($user); + throw new Exception( + __METHOD__ . " last public link share data was not found" + ); } $language = TranslationHelper::getLanguage($language); - $this->getShareData($user, (string)$share_id, $language); + $this->getShareData($user, $shareId, $language); $this->pushToLastStatusCodesArrays(); } @@ -1969,26 +2170,36 @@ public function theInfoAboutTheLastShareByUserWithUserShouldInclude( } /** - * Get id of the last share of the user - * - * If lastShareData was not of $user, it fetches all shares for that user, - * and extracts the id for last share from the response + * Sets the id of the last shared file * * @param string $user + * @param string $shareId * - * @return string|null - * @throws Exception + * @return void */ - public function getLastShareIdOf(string $user):?string { - $user = $this->getActualUsername($user); + public function setLastShareIdOf(string $user, string $shareId):void { + $this->lastShareIdByUser[$user] = $shareId; + $this->userWhoCreatedLastShare = $user; + } - $this->getListOfShares($user); - $id = $this->extractLastSharedIdFromLastResponse(); - Assert::assertNotNull( - $id, - __METHOD__ . " Could not find id in the last response." - ); - return $id; + /** + * Sets the id of the last public link shared file + * + * @param string $shareId + * + * @return void + */ + public function setLastPublicLinkShareId(string $shareId):void { + $this->lastPublicShareId = $shareId; + } + + /** + * Retrieves the id of the last public link shared file + * + * @return string|null + */ + public function getLastPublicLinkShareId():?string { + return $this->lastPublicShareId; } /** @@ -1997,13 +2208,24 @@ public function getLastShareIdOf(string $user):?string { * @return string|null */ public function getLastShareId():?string { - if ($this->lastShareData && $this->lastShareData->data) { - // id is a SimpleXMLElement object that contains the share id - // which is a string. - // (It might be a numeric string or might not, either is fine.) - return (string) $this->lastShareData->data[0]->id; + return $this->getLastShareIdForUser($this->userWhoCreatedLastShare); + } + + /** + * @param string $user + * + * @return string|null + */ + public function getLastShareIdForUser(string $user):?string { + if ($user === null) { + throw new Exception( + __METHOD__ . " user not specified. Probably no user or group shares have been created yet in the test scenario." + ); + } + if (isset($this->lastShareIdByUser[$user])) { + return $this->lastShareIdByUser[$user]; } else { - return null; + throw new Exception(__METHOD__ . " last share id for user '$user' was not found"); } } @@ -2029,21 +2251,6 @@ public function getListOfShares(string $user):ResponseInterface { return $this->response; } - /** - * Extracts `id` from responseXml - * - * @return string|null - */ - public function extractLastSharedIdFromLastResponse():?string { - // extract max id - $xpath = '/ocs/data/element/id[not (. < ../../element/id)][1]'; - $id = $this->getResponseXml(null, __METHOD__)->xpath($xpath); - if ((bool) $id) { - return (string) $id[0]; - } - return null; - } - /** * Get share data of specific share_id * @@ -2286,7 +2493,7 @@ public function theResponseWhenUserGetsInfoOfLastShareShouldInclude( ):void { $user = $this->getActualUsername($user); $this->verifyTableNodeRows($body, [], $this->shareResponseFields); - $this->getShareData($user, (string)$this->lastShareData->data[0]->id); + $this->getShareData($user, (string)$this->getLastShareData()->data[0]->id); $this->theHTTPStatusCodeShouldBe( 200, "Error getting info of last share for user $user" @@ -2315,16 +2522,11 @@ public function informationOfLastShareShouldInclude( TableNode $body ):void { $user = $this->getActualUsername($user); - $this->getListOfShares($user); - $share_id = $this->extractLastSharedIdFromLastResponse(); - Assert::assertNotNull( - $share_id, - __METHOD__ . " Could not find id in the last response." - ); - $this->getShareData($user, $share_id); + $shareId = $this->getLastShareIdForUser($user); + $this->getShareData($user, $shareId); $this->theHTTPStatusCodeShouldBe( 200, - "Error getting info of last share for user $user" + "Error getting info of last share for user $user with share id $shareId" ); $this->verifyTableNodeRows($body, [], $this->shareResponseFields); $this->checkFields($user, $body); @@ -2396,10 +2598,10 @@ public function theFieldsOfTheResponseForUserForResourceShouldInclude( * @throws Exception */ public function checkingLastShareIDIsIncluded():void { - $share_id = (string)$this->lastShareData->data[0]->id; - if (!$this->isFieldInResponse('id', $share_id)) { + $shareId = $this->getLastShareId(); + if (!$this->isFieldInResponse('id', $shareId)) { Assert::fail( - "Share id $share_id not found in response" + "Share id $shareId not found in response" ); } } @@ -2411,10 +2613,10 @@ public function checkingLastShareIDIsIncluded():void { * @throws Exception */ public function checkLastShareIDIsNotIncluded():void { - $share_id = (string) $this->lastShareData->data[0]->id; - if ($this->isFieldInResponse('id', $share_id, false)) { + $shareId = $this->getLastShareId(); + if ($this->isFieldInResponse('id', $shareId, false)) { Assert::fail( - "Share id $share_id has been found in response" + "Share id $shareId has been found in response" ); } } @@ -2786,7 +2988,14 @@ public function userHasRemovedAllSharesFromTheFileNamed(string $user, string $fi } /** - * Returns shares of a file or folders as an array of elements + * Returns shares of a file or folder as a SimpleXMLElement + * + * Note: the "single" SimpleXMLElement may contain one or more actual + * shares (to users, groups or public links etc). If you access an item directly, + * for example, getShares()->id, then the value of "id" for the first element + * will be returned. To access all the elements, you can loop through the + * returned SimpleXMLElement with "foreach" - it will act like a PHP array + * of elements. * * @param string $user * @param string $path @@ -3387,12 +3596,12 @@ private function getAllSharesSharedWithUser(string $user, ?string $state = "all" /** * @return string authorization token */ - public function getLastShareToken():string { - if (\count($this->lastShareData->data->element) > 0) { - return (string)$this->lastShareData->data[0]->token; + public function getLastPublicShareToken():string { + if (\count($this->lastPublicShareData->data->element) > 0) { + return (string)$this->lastPublicShareData->data[0]->token; } - return (string)$this->lastShareData->data->token; + return (string)$this->lastPublicShareData->data->token; } /** @@ -3422,7 +3631,7 @@ public function getPublicPreviewOfFile(string $fileName, string $token):void { * @return void */ public function thePublicAccessesThePreviewOfTheSharedFileUsingTheSharingApi(string $path):void { - $shareData = $this->getLastShareData(); + $shareData = $this->getLastPublicShareData(); $token = (string) $shareData->data->token; $this->getPublicPreviewOfFile($path, $token); $this->pushToLastStatusCodesArrays(); @@ -3444,7 +3653,7 @@ public function thePublicAccessesThePreviewOfTheFollowingSharedFileUsingTheShari $this->emptyLastHTTPStatusCodesArray(); $this->emptyLastOCSStatusCodesArray(); foreach ($paths as $path) { - $shareData = $this->getLastShareData(); + $shareData = $this->getLastPublicShareData(); $token = (string) $shareData->data->token; $this->getPublicPreviewOfFile($path["path"], $token); $this->pushToLastStatusCodesArrays(); @@ -3466,7 +3675,7 @@ public function saveLastSharedPublicLinkShare( $user = $this->getActualUsername($user); $userPassword = $this->getPasswordForUser($user); - $shareData = $this->getLastShareData(); + $shareData = $this->getLastPublicShareData(); $owner = (string) $shareData->data->uid_owner; $name = $this->encodePath((string) $shareData->data->file_target); $name = \trim($name, "/"); diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index f32523e9747a..ab1cf79e091c 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -1566,7 +1566,7 @@ public function downloadFileAsUserUsingPassword( * @throws Exception */ public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi():void { - $tokenArray = $this->getLastShareData()->data->token; + $tokenArray = $this->getLastPublicShareData()->data->token; $token = (string)$tokenArray[0]; $url = $this->getBaseUrl() . "/remote.php/dav/public-files/{$token}"; $this->response = HttpRequestHelper::sendRequest( @@ -5123,7 +5123,7 @@ public function theLastDavResponseShouldNotContainTheseNodes(string $user, Table * @throws Exception */ public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table):void { - $user = (string) $this->getLastShareData()->data->token; + $user = $this->getLastPublicShareToken(); $this->verifyTableNodeColumns($table, ["name"]); $type = $this->usingOldDavPath ? "public-files" : "public-files-new"; foreach ($table->getHash() as $row) { @@ -5142,7 +5142,7 @@ public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table * @throws Exception */ public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $table):void { - $user = (string) $this->getLastShareData()->data->token; + $user = $this->getLastPublicShareToken(); $this->verifyTableNodeColumns($table, ["name"]); $type = $this->usingOldDavPath ? "public-files" : "public-files-new"; foreach ($table->getHash() as $row) { @@ -5161,7 +5161,7 @@ public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $ta * @throws Exception */ public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(string $depth):void { - $user = (string) $this->getLastShareData()->data->token; + $user = $this->getLastPublicShareToken(); $response = $this->listFolder( $user, '/', diff --git a/tests/acceptance/features/bootstrap/WebDavLockingContext.php b/tests/acceptance/features/bootstrap/WebDavLockingContext.php index b37050418102..4a3e8284b779 100644 --- a/tests/acceptance/features/bootstrap/WebDavLockingContext.php +++ b/tests/acceptance/features/bootstrap/WebDavLockingContext.php @@ -150,7 +150,7 @@ public function userHasLockedFile($user, $file, TableNode $properties) { } /** - * @Given the public has locked the last public shared file/folder setting the following properties + * @Given the public has locked the last public link shared file/folder setting the following properties * * @param TableNode $properties * @@ -158,7 +158,7 @@ public function userHasLockedFile($user, $file, TableNode $properties) { */ public function publicHasLockedLastSharedFile(TableNode $properties) { $this->lockFile( - (string) $this->featureContext->getLastShareData()->data->token, + $this->featureContext->getLastPublicShareToken(), "/", $properties, true @@ -166,7 +166,7 @@ public function publicHasLockedLastSharedFile(TableNode $properties) { } /** - * @When the public locks the last public shared file/folder using the WebDAV API setting the following properties + * @When the public locks the last public link shared file/folder using the WebDAV API setting the following properties * * @param TableNode $properties * @@ -174,7 +174,7 @@ public function publicHasLockedLastSharedFile(TableNode $properties) { */ public function publicLocksLastSharedFile(TableNode $properties) { $this->lockFile( - (string) $this->featureContext->getLastShareData()->data->token, + $this->featureContext->getLastPublicShareToken(), "/", $properties, true, @@ -183,7 +183,7 @@ public function publicLocksLastSharedFile(TableNode $properties) { } /** - * @Given the public has locked :file in the last public shared folder setting the following properties + * @Given the public has locked :file in the last public link shared folder setting the following properties * * @param string $file * @param TableNode $properties @@ -195,7 +195,7 @@ public function publicHasLockedFileLastSharedFolder( TableNode $properties ) { $this->lockFile( - (string) $this->featureContext->getLastShareData()->data->token, + $this->featureContext->getLastPublicShareToken(), $file, $properties, true @@ -203,7 +203,7 @@ public function publicHasLockedFileLastSharedFolder( } /** - * @When /^the public locks "([^"]*)" in the last public shared folder using the (old|new) public WebDAV API setting the following properties$/ + * @When /^the public locks "([^"]*)" in the last public link shared folder using the (old|new) public WebDAV API setting the following properties$/ * * @param string $file * @param string $publicWebDAVAPIVersion @@ -217,7 +217,7 @@ public function publicLocksFileLastSharedFolder( TableNode $properties ) { $this->lockFile( - (string) $this->featureContext->getLastShareData()->data->token, + $this->featureContext->getLastPublicShareToken(), $file, $properties, true, @@ -278,7 +278,7 @@ public function unlockItemWithLastPublicLockOfOtherItemUsingWebDavAPI( $itemToUnlock, $itemToUseLockOf ) { - $lockOwner = (string) $this->featureContext->getLastShareData()->data->token; + $lockOwner = $this->featureContext->getLastPublicShareToken(); $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( $user, $itemToUnlock, @@ -429,7 +429,7 @@ public function unlockItemAsPublicWithLastLockOfUserAndItemUsingWebDavAPI( $lockOwner, $itemToUseLockOf ) { - $user = (string) $this->featureContext->getLastShareData()->data->token; + $user = $this->featureContext->getLastPublicShareToken(); $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( $user, $itemToUnlock, @@ -447,7 +447,7 @@ public function unlockItemAsPublicWithLastLockOfUserAndItemUsingWebDavAPI( * @return void */ public function unlockItemAsPublicUsingWebDavAPI($itemToUnlock) { - $user = (string) $this->featureContext->getLastShareData()->data->token; + $user = $this->featureContext->getLastPublicShareToken(); $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( $user, $itemToUnlock, @@ -602,7 +602,7 @@ public function publicUploadFileSendingLockTokenOfPublic( $itemToUseLockOf, $publicWebDAVAPIVersion ) { - $lockOwner = (string) $this->featureContext->getLastShareData()->data->token; + $lockOwner = $this->featureContext->getLastPublicShareToken(); $this->publicUploadFileSendingLockTokenOfUser( $filename, $content, diff --git a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php index c17810f7afde..2845833c3396 100644 --- a/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php +++ b/tests/acceptance/features/bootstrap/WebDavPropertiesContext.php @@ -298,7 +298,7 @@ public function userGetsPropertiesOfFile( * @throws Exception */ public function publicGetsThePropertiesOfFolder(string $path, TableNode $propertiesTable):void { - $user = (string) $this->featureContext->getLastShareData()->data->token; + $user = $this->featureContext->getLastPublicShareToken(); $properties = null; if ($propertiesTable instanceof TableNode) { foreach ($propertiesTable->getRows() as $row) { diff --git a/tests/acceptance/features/bootstrap/WebUIFilesContext.php b/tests/acceptance/features/bootstrap/WebUIFilesContext.php index c88d62fb05fc..095491c7b395 100644 --- a/tests/acceptance/features/bootstrap/WebUIFilesContext.php +++ b/tests/acceptance/features/bootstrap/WebUIFilesContext.php @@ -144,6 +144,13 @@ class WebUIFilesContext extends RawMinkContext implements Context { */ private $currentFile = ""; + /** + * variable to remember the path of a received share that has been moved + * + * @var string + */ + private $pathOfMovedReceivedShare = ""; + /** * * @var FeatureContext @@ -227,6 +234,15 @@ private function getCurrentFolderFilePath():string { return \rtrim($this->currentFolder, '/') . '/' . $this->currentFile; } + /** + * get the new path of a moved received share (if any, it might be an empty string) + * + * @return string + */ + public function getPathOfMovedReceivedShare():string { + return $this->pathOfMovedReceivedShare; + } + /** * reset any context remembered about where we are or what we have done on * the files-like pages @@ -890,6 +906,22 @@ public function theUserMovesFileFolderIntoFolderUsingTheWebUI($name, $destinatio $pageObject->moveFileTo($name, $destination, $this->getSession()); } + /** + * @When the user moves received file/folder :name into folder :destination using the webUI + * + * @param string|array $name + * @param string|array $destination + * + * @return void + */ + public function theUserMovesReceivedFileFolderIntoFolderUsingTheWebUI($name, $destination):void { + $pageObject = $this->getCurrentPageObject(); + $pageObject->moveFileTo($name, $destination, $this->getSession()); + // A received share has been moved. Remember that this exists as a new share path, + // so that other steps can be aware of it. + $this->pathOfMovedReceivedShare = "$destination/$name"; + } + /** * @When the user moves the following file/folder using the webUI * @@ -2683,7 +2715,7 @@ public function userGroupShouldBeListedAsShareReceiver(string $type, string $nam * @return void */ public function publicLinkWithLastShareTokenShouldBeListedAsShareReceiverViaOnTheWebUI(string $item):void { - $token = (string)$this->featureContext->getLastShareData()->data->token; + $token = $this->featureContext->getLastPublicShareToken(); $sharingDialog = $this->filesPage->getSharingDialog(); $shareTreeItem = $sharingDialog->getShareTreeItem("public link", $token, $item); Assert::assertTrue( diff --git a/tests/acceptance/features/bootstrap/WebUISharingContext.php b/tests/acceptance/features/bootstrap/WebUISharingContext.php index 4912f46b5bc3..9fec66784752 100644 --- a/tests/acceptance/features/bootstrap/WebUISharingContext.php +++ b/tests/acceptance/features/bootstrap/WebUISharingContext.php @@ -146,6 +146,7 @@ public function __construct( * @param string|null $username * @param int $maxRetries * @param boolean $quiet + * @param boolean $expectedToWork * * @return void * @throws Exception @@ -156,7 +157,8 @@ public function theUserSharesFileFolderWithUserUsingTheWebUI( string $user, ?string $username = null, int $maxRetries = STANDARD_RETRY_COUNT, - bool $quiet = false + bool $quiet = false, + bool $expectedToWork = true ):void { $user = $this->featureContext->getActualUsername($user); if ($remote === "remote" || $remote === "federated") { @@ -168,14 +170,43 @@ public function theUserSharesFileFolderWithUserUsingTheWebUI( $remote, $user, $maxRetries, - $quiet + $quiet, + $expectedToWork ); } /** - * @When /^the user shares (?:file|folder) "([^"]*)" with (?:(remote|federated)\s)?user "([^"]*)" ?(?:with displayname "([^"]*)")? using the webUI without closing the share dialog$/ + * @When /^the user tries to share (?:file|folder) "([^"]*)" with (?:(remote|federated)\s)?user "([^"]*)" ?(?:with displayname "([^"]*)")? using the webUI$/ * * @param string $folder + * @param string $remote + * @param string $user + * @param string|null $username + * + * @return void + * @throws Exception + */ + public function theUserTriesToShareFileFolderWithUserUsingTheWebUI( + string $folder, + string $remote, + string $user, + ?string $username = null + ):void { + $this->theUserSharesFileFolderWithUserUsingTheWebUI( + $folder, + $remote, + $user, + $username, + STANDARD_RETRY_COUNT, + false, + false + ); + } + + /** + * @When /^the user shares (?:file|folder) "([^"]*)" with (?:(remote|federated)\s)?user "([^"]*)" ?(?:with displayname "([^"]*)")? using the webUI without closing the share dialog$/ + * + * @param string $resource * @param string $remote (remote|federated|) * @param string $name * @param string|null $displayname @@ -187,17 +218,17 @@ public function theUserSharesFileFolderWithUserUsingTheWebUI( * */ public function theUserSharesWithUserWithoutClosingDialog( - string $folder, - string $remote, - string $name, + string $resource, + string $remote, + string $name, ?string $displayname = null, - int $maxRetries = STANDARD_RETRY_COUNT, - bool $quiet = false + int $maxRetries = STANDARD_RETRY_COUNT, + bool $quiet = false ):void { if ($remote === "remote" || $remote === "federated") { $name = $this->featureContext->substituteInLineCodes($displayname, $name); } - $this->theUserSharesUsingWebUIWithoutClosingDialog($folder, "user", $remote, $name, $maxRetries, $quiet); + $this->theUserSharesUsingWebUIWithoutClosingDialog($resource, "user", $remote, $name, $maxRetries, $quiet); } /** @@ -349,23 +380,29 @@ public function clearExpirationDate(string $userOrGroup, string $receiver):void } /** - * @param string $folder + * The resource can be a whole path to the file/folder. The test step will open each folder + * to reach the final list of resources, and then create the public link for the final + * resource. + * + * @param string $resource * @param string|null $userOrGroup (user|group) * @param string|null $remote (remote|federated|) * @param string|null $name * @param int $maxRetries * @param bool $quiet + * @param bool $expectedToWork * * @return void * @throws Exception */ public function theUserSharesUsingWebUIWithoutClosingDialog( - string $folder, + string $resource, ?string $userOrGroup, ?string $remote, ?string $name, - int $maxRetries = STANDARD_RETRY_COUNT, - bool $quiet = false + int $maxRetries = STANDARD_RETRY_COUNT, + bool $quiet = false, + bool $expectedToWork = true ):void { $this->filesPage->waitTillPageIsloaded($this->getSession()); try { @@ -373,8 +410,25 @@ public function theUserSharesUsingWebUIWithoutClosingDialog( } catch (Exception $e) { //we don't care } + // If the resource to share is a path with nested folders, then first + // open each of the folders until the last resource should be displayed. + $resourceParts = \explode("/", $resource); + $numberOfResourceParts = \count($resourceParts); + foreach ($resourceParts as $key => $resourcePart) { + // open each folder in the path, so that the last item should be listed + if ($key === ($numberOfResourceParts - 1)) { + $finalResource = $resourcePart; + } else { + $this->webUIFilesContext->theUserOpensFolderNamedUsingTheWebUI( + "", + "folder", + "'$resourcePart'", + "" + ); + } + } $this->sharingDialog = $this->filesPage->openSharingDialog( - $folder, + $finalResource, $this->getSession() ); if ($userOrGroup === "user") { @@ -403,6 +457,47 @@ public function theUserSharesUsingWebUIWithoutClosingDialog( $maxRetries ); } + if ($expectedToWork) { + // Use the sharing API to find the share that has been created. + // And remember the share id so that later steps can know the latest share. + $currentUser = $this->featureContext->getCurrentUser(); + $shareData = $this->featureContext->getShares($currentUser, $resource); + $shareId = null; + // The share might have been moved somewhere else in an earlier test step + // If so, then getPathOfMovedReceivedShare will know the expected path. + $expectedPathOfShare = $this->webUIFilesContext->getPathOfMovedReceivedShare(); + if ($expectedPathOfShare === "") { + // The share should be in its usual path, indicated by "resource" that was passed in. + $expectedPathOfShare = $resource; + } + $slashExpectedPathOfShare = "/" . \trim($expectedPathOfShare, "/"); + foreach ($shareData as $shareItem) { + $sharePath = (string) $shareItem->path; + $slashSharePath = "/" . \trim($sharePath, "/"); + // The user might have navigated down multiple folders /a/b/c and shared "d". + // Normally the share path will be /a/b/c/d + // But the user might have received "a" as a share, but also "b" as a separate share. + // (maybe the two shares were to two different groups and the user is a member of both) + // Then the user will also have a path to "d" that is b/c/d only. + // And the share response actually provides that path. + // So match any share path like /b/c/d or /c/d if it appears at the end of the expected path, + // even though it is not the whole of the expected path. + // Note: if (str_ends_with($expectedPathOfShare, $slashSharePath)) - will work from PHP8 + if (substr($slashExpectedPathOfShare, -\strlen($slashSharePath)) === $slashSharePath) { + $shareId = (string) $shareItem->id; + break; + } + } + if ($shareId === null) { + // Fail early here. We know that there was some trouble with the share. + // It will be confusing if we continue to later steps that try to use + // a non-existent share id. + throw new Exception( + __METHOD__ . " share with path '$resource' for user '$currentUser' could not be found." + ); + } + $this->featureContext->setLastShareIdOf($currentUser, $shareId); + } } /** @@ -439,6 +534,7 @@ public function theUserSharesFileFolderWithGroupUsingTheWebUI( * @param string|null $name * @param int $maxRetries * @param bool $quiet + * @param bool $expectedToWork * * @return void * @throws Exception @@ -449,7 +545,8 @@ public function theUserSharesFileFolderWithUserOrGroupUsingTheWebUI( ?string $remote, ?string $name, int $maxRetries = STANDARD_RETRY_COUNT, - bool $quiet = false + bool $quiet = false, + bool $expectedToWork = true ):void { $this->theUserSharesUsingWebUIWithoutClosingDialog( $folder, @@ -457,7 +554,8 @@ public function theUserSharesFileFolderWithUserOrGroupUsingTheWebUI( $remote, $name, $maxRetries, - $quiet + $quiet, + $expectedToWork ); $this->theUserClosesTheShareDialog(); } @@ -735,7 +833,7 @@ public function createsThePublicLinkUsingTheWebUI():void { $linkUrl = $this->publicShareTab->getLinkUrl($linkName); $this->featureContext->addToListOfCreatedPublicLinks($linkName, $linkUrl); - $this->featureContext->resetLastShareData(); + $this->featureContext->resetLastPublicShareData(); } /** @@ -772,6 +870,10 @@ public function theUserCreatesAReadOnlyPublicLinkForFolderUsingTheQuickActionBut * @When the user creates a new public link for file/folder :name using the webUI with * @Given the user has created a new public link for file/folder :name using the webUI with * + * The name can be a whole path to the file/folder. The test step will open each folder + * to reach the final list of resources, and then create the public link for the final + * resource. + * * @param string $name * @param TableNode|null $settings table with the settings and no header * possible settings: name, permission, @@ -787,8 +889,47 @@ public function theUserCreatesANewPublicLinkForFileFolderUsingTheWebUIWith( string $name, ?TableNode $settings = null ):void { - $linkName = $this->createPublicShareLink($name, $settings); + $nameParts = \explode("/", $name); + $numberOfNameParts = \count($nameParts); + foreach ($nameParts as $key => $namePart) { + // open each folder in the path, so that the last item should be listed + if ($key === ($numberOfNameParts - 1)) { + $finalName = $namePart; + } else { + $this->webUIFilesContext->theUserOpensFolderNamedUsingTheWebUI( + "", + "folder", + "'$namePart'", + "" + ); + } + } + $linkName = $this->createPublicShareLink($finalName, $settings); $linkUrl = $this->publicShareTab->getLinkUrl($linkName); + $urlParts = \explode("/", $linkUrl); + $shareToken = \end($urlParts); + // Find the share id of the share that has this share token. + // We want to remember it so that later "Then" steps can check + // attributes of the "last public link share" by using the share id to + // access the sharing API. + $currentUser = $this->featureContext->getCurrentUser(); + $shareData = $this->featureContext->getShares($currentUser, $name); + $shareId = null; + foreach ($shareData as $shareItem) { + if ((string) $shareItem->token === $shareToken) { + $shareId = (string) $shareItem->id; + break; + } + } + if ($shareId === null) { + // Fail early here. We know that there was some trouble with the share. + // It will be confusing if we continue to later steps that try to use + // a non-existent share id. + throw new Exception( + __METHOD__ . " share with token '$shareToken' for user '$currentUser' could not be found." + ); + } + $this->featureContext->setLastPublicLinkShareId($shareId); $this->featureContext->addToListOfCreatedPublicLinks($linkName, $linkUrl); } diff --git a/tests/acceptance/features/webUIAdminSettings/adminStorageSettings.feature b/tests/acceptance/features/webUIAdminSettings/adminStorageSettings.feature index 5abe088d24cd..01cdff34631e 100644 --- a/tests/acceptance/features/webUIAdminSettings/adminStorageSettings.feature +++ b/tests/acceptance/features/webUIAdminSettings/adminStorageSettings.feature @@ -178,5 +178,5 @@ Feature: admin storage settings And the administrator has enabled read-only for the last created local storage mount using the webUI And the administrator has enabled sharing for the last created local storage mount using the webUI And the user has re-logged in as "Alice" using the webUI - When the user shares folder "local_storage1" with user "Brian" using the webUI + When the user tries to share folder "local_storage1" with user "Brian" using the webUI And as "Brian" folder "local_storage1" should exist diff --git a/tests/acceptance/features/webUIAdminSettings/adminStorageSettingsOC10Issue36803.feature b/tests/acceptance/features/webUIAdminSettings/adminStorageSettingsOC10Issue36803.feature index f3152bcaf8f4..f6ff60ebfc2c 100644 --- a/tests/acceptance/features/webUIAdminSettings/adminStorageSettingsOC10Issue36803.feature +++ b/tests/acceptance/features/webUIAdminSettings/adminStorageSettingsOC10Issue36803.feature @@ -18,7 +18,7 @@ Feature: admin storage settings And the administrator has enabled read-only for the last created local storage mount using the webUI And the administrator has enabled sharing for the last created local storage mount using the webUI And the user has re-logged in as "Alice" using the webUI - When the user shares folder "local_storage1" with user "Brian" using the webUI + When the user tries to share folder "local_storage1" with user "Brian" using the webUI Then notifications should be displayed on the webUI with the text | Cannot set the requested share permissions for local_storage1 | # And as "Brian" folder "local_storage1" should exist diff --git a/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupUsingExpirationDate.feature b/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupUsingExpirationDate.feature index c63c1b6544c9..be777d6aae37 100644 --- a/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupUsingExpirationDate.feature +++ b/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupUsingExpirationDate.feature @@ -264,8 +264,7 @@ Feature: Sharing files and folders with internal groups with expiration date set | permissions | read,share | | expireDate | +15 days | And user "Alice" has logged in using the webUI - When the user opens folder "simple-folder" using the webUI - And the user shares file "simple-empty-folder" with group "grp1" using the webUI without closing the share dialog + When the user shares file "simple-folder/simple-empty-folder" with group "grp1" using the webUI without closing the share dialog Then the expiration date input field should be "+30 days" for the group "grp1" in the share dialog When the user changes expiration date for share of group "grp1" to "+20 days" in the share dialog And the information of the last share of user "Alice" should include diff --git a/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupsEdgeCases.feature b/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupsEdgeCases.feature index f177fb745040..f84118d115a5 100644 --- a/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupsEdgeCases.feature +++ b/tests/acceptance/features/webUISharingInternalGroups2/shareWithGroupsEdgeCases.feature @@ -366,8 +366,7 @@ Feature: Sharing files and folders with internal groups And user "Carol" has shared folder "/simple-folder" with group "grp1" And user "Alice" has logged in using the webUI When the user shares folder "simple-folder" with group "grp2" using the webUI - And the user opens folder "simple-folder" using the webUI - And the user shares folder "simple-empty-folder" with group "grp2" using the webUI + And the user shares folder "simple-folder/simple-empty-folder" with group "grp2" using the webUI Then as "Alice" folder "/simple-folder" should exist And user "Alice" should be able to upload file "filesForUpload/textfile.txt" to "simple-folder/textfile.txt" And as "Alice" folder "/simple-empty-folder" should not exist @@ -389,8 +388,7 @@ Feature: Sharing files and folders with internal groups And the user sets the sharing permissions of group "grp2" for "simple-folder" using the webUI to | edit | no | | create | no | - And the user opens folder "simple-folder" using the webUI - And the user shares folder "simple-empty-folder" with group "grp2" using the webUI + And the user shares folder "simple-folder/simple-empty-folder" with group "grp2" using the webUI And the user sets the sharing permissions of group "grp2" for "simple-empty-folder" using the webUI to | edit | no | | create | no | @@ -438,8 +436,7 @@ Feature: Sharing files and folders with internal groups And user "Alice" has been added to group "grp1" And user "Carol" has uploaded file with content "some data" to "/simple-folder/simple-inner-folder/simple-inner-inner-folder/textfile-1.txt" And user "Carol" has logged in using the webUI - And the user opens folder "/simple-folder/simple-inner-folder/simple-inner-inner-folder" using the webUI - When the user shares file "textfile-1.txt" with group "grp1" using the webUI + When the user shares file "simple-folder/simple-inner-folder/simple-inner-inner-folder/textfile-1.txt" with group "grp1" using the webUI Then the following permissions are seen for "textfile-1.txt" in the sharing dialog for group "grp1" | edit | yes | | change | yes | @@ -470,8 +467,7 @@ Feature: Sharing files and folders with internal groups And user "Alice" has shared file "/simple-folder/simple-inner-folder" with group "grp1" with permissions "read" And user "Alice" has shared file "/simple-folder/simple-inner-folder/simple-inner-inner-folder" with group "grp2" with permissions "read,share,delete" And user "Brian" has logged in using the webUI - And the user opens folder "/simple-folder/simple-inner-folder/simple-inner-inner-folder" using the webUI - When the user shares file "textfile-2.txt" with group "grp3" using the webUI + When the user shares file "simple-folder/simple-inner-folder/simple-inner-inner-folder/textfile-2.txt" with group "grp3" using the webUI Then the following permissions are seen for "textfile-2.txt" in the sharing dialog for group "grp3" | edit | yes | | change | yes | @@ -501,8 +497,7 @@ Feature: Sharing files and folders with internal groups And user "Alice" has shared file "/simple-folder" with group "grp2" with permissions "all" And user "Alice" has shared file "/simple-folder/simple-inner-folder" with group "grp1" with permissions "read" And user "Alice" has logged in using the webUI - And the user opens folder "/simple-folder" using the webUI - When the user shares folder "simple-inner-folder" with group "grp3" using the webUI + When the user shares folder "simple-folder/simple-inner-folder" with group "grp3" using the webUI Then the following permissions are seen for "simple-inner-folder" in the sharing dialog for group "grp3" | edit | yes | | change | yes | @@ -530,19 +525,23 @@ Feature: Sharing files and folders with internal groups And user "Carol" has shared folder "/simple-folder" with user "Alice" with permissions "all" And user "Alice" has shared folder "/simple-folder" with group "grp2" with permissions "all" And user "Alice" has shared folder "/simple-folder/simple-inner-folder" with group "grp1" with permissions "read" - And user "Brian" has created folder "/renamed-simple-folder" + And user "Brian" has created folder "/other-folder" And user "Brian" has logged in using the webUI When the user opens the sharing tab from the file action menu of folder "simple-inner-folder" using the webUI Then the user should see an error message on the share dialog saying "Sharing is not allowed" # now move received simple-inner-folder into some folder - And the user moves folder "simple-inner-folder" into folder "renamed-simple-folder" using the webUI - And the user opens folder "/renamed-simple-folder" using the webUI + # this effectively moves the read-only share of this folder with grp1 + # and so sharing is not allowed for /other-folder/simple-inner-folder + And the user moves received folder "simple-inner-folder" into folder "other-folder" using the webUI + And the user opens folder "/other-folder" using the webUI When the user opens the sharing tab from the file action menu of folder "simple-inner-folder" using the webUI Then the user should see an error message on the share dialog saying "Sharing is not allowed" - # after move, sharing folder simple-inner-folder again but with different group should be possible + # simple-inner-folder is also still shown in simple-folder. In that view, it is just a sub-folder + # of the share of simple-folder with grp2 with all permissions. + # So that "view" of simple-inner-folder can be reshared. + # This is an unusual edge case combination. The test scenario demonstrates the current behavior. And the user browses to the home page - And the user opens folder "/simple-folder" using the webUI - When the user shares folder "simple-inner-folder" with group "grp3" using the webUI + When the user shares folder "simple-folder/simple-inner-folder" with group "grp3" using the webUI Then the following permissions are seen for "simple-inner-folder" in the sharing dialog for group "grp3" | edit | yes | | change | yes | diff --git a/tests/acceptance/features/webUISharingInternalUsers1/createShareWithUsers.feature b/tests/acceptance/features/webUISharingInternalUsers1/createShareWithUsers.feature index eacd28c62665..758154fbe0c5 100644 --- a/tests/acceptance/features/webUISharingInternalUsers1/createShareWithUsers.feature +++ b/tests/acceptance/features/webUISharingInternalUsers1/createShareWithUsers.feature @@ -190,7 +190,10 @@ Feature: Sharing files and folders with internal users When the user uploads file "textfile.txt" using the webUI Then as "Alice" file "simple-folder/textfile.txt" should not exist And file "textfile.txt" should not be listed on the webUI - When the user shares file "lorem.txt" with user "Carol" using the webUI + # Go back to the home page so that the "user shares file" step can navigate its own way + # into simple-folder and will "know where it is" + When the user browses to the home page + And the user shares file "simple-folder/lorem.txt" with user "Carol" using the webUI Then as "Carol" file "lorem.txt" should exist @skipOnOcV10.3 diff --git a/tests/acceptance/features/webUISharingInternalUsers2/adminDisablesSharePermissions.feature b/tests/acceptance/features/webUISharingInternalUsers2/adminDisablesSharePermissions.feature index 5f8597d9117a..3f6d895565da 100644 --- a/tests/acceptance/features/webUISharingInternalUsers2/adminDisablesSharePermissions.feature +++ b/tests/acceptance/features/webUISharingInternalUsers2/adminDisablesSharePermissions.feature @@ -27,7 +27,10 @@ Feature: Sharing files and folders with internal users where admin disables diff And the option to rename file "lorem.txt" should be available on the webUI And the option to delete file "lorem.txt" should not be available on the webUI And the option to upload file should be available on the webUI - When the user shares file "lorem.txt" with user "Carol" using the webUI + # Go back to the home page so that the "user shares file" step can navigate its own way + # into simple-folder and will "know where it is" + When the user browses to the home page + And the user shares file "simple-folder/lorem.txt" with user "Carol" using the webUI Then as "Carol" file "lorem.txt" should exist @skipOnOcV10.3 @@ -52,7 +55,10 @@ Feature: Sharing files and folders with internal users where admin disables diff And the user opens folder "simple-folder" using the webUI And the option to rename file "lorem.txt" should not be available on the webUI And the option to upload file should be available on the webUI - When the user shares file "lorem.txt" with user "Carol" using the webUI + # Go back to the home page so that the "user shares file" step can navigate its own way + # into simple-folder and will "know where it is" + When the user browses to the home page + And the user shares file "simple-folder/lorem.txt" with user "Carol" using the webUI Then as "Carol" file "lorem.txt" should exist And the option to delete file "lorem.txt" should be available on the webUI @@ -123,5 +129,8 @@ Feature: Sharing files and folders with internal users where admin disables diff Then the option to rename file "lorem.txt" should be available on the webUI And the option to upload file should be available on the webUI And the option to delete file "lorem.txt" should not be available on the webUI - When the user shares file "lorem.txt" with user "Carol" using the webUI + # Go back to the home page so that the "user shares file" step can navigate its own way + # into simple-folder and will "know where it is" + When the user browses to the home page + When the user shares file "simple-folder/lorem.txt" with user "Carol" using the webUI Then as "Carol" file "lorem.txt" should exist diff --git a/tests/acceptance/features/webUISharingInternalUsers2/shareWithUserUsingExpirationDate.feature b/tests/acceptance/features/webUISharingInternalUsers2/shareWithUserUsingExpirationDate.feature index f6c89711e4d7..d13f0dc7cac0 100644 --- a/tests/acceptance/features/webUISharingInternalUsers2/shareWithUserUsingExpirationDate.feature +++ b/tests/acceptance/features/webUISharingInternalUsers2/shareWithUserUsingExpirationDate.feature @@ -253,8 +253,7 @@ Feature: Sharing files and folders with internal users with expiration date set/ | permissions | read,share | | expireDate | +15 days | And user "Alice" has logged in using the webUI - When the user opens folder "simple-folder" using the webUI - And the user shares file "simple-empty-folder" with user "Brian" using the webUI without closing the share dialog + When the user shares file "simple-folder/simple-empty-folder" with user "Brian" using the webUI without closing the share dialog Then the expiration date input field should be "+30 days" for the user "Brian" in the share dialog When the user changes expiration date for share of user "Brian" to "+20 days" in the share dialog And the information of the last share of user "Alice" should include diff --git a/tests/acceptance/features/webUISharingPublic1/createPublicLinkShares.feature b/tests/acceptance/features/webUISharingPublic1/createPublicLinkShares.feature index 19b16c0df03f..944460569ecd 100644 --- a/tests/acceptance/features/webUISharingPublic1/createPublicLinkShares.feature +++ b/tests/acceptance/features/webUISharingPublic1/createPublicLinkShares.feature @@ -236,7 +236,7 @@ Feature: Share by public link And user "Alice" has logged in using the webUI When the user creates a new public link for file "lorem.txt" using the webUI with | expiration | | - And user "Alice" gets the info of the last share using the sharing API + And user "Alice" gets the info of the last public link share using the sharing API Then the fields of the last response to user "Alice" should include | expiration | | @@ -256,7 +256,7 @@ Feature: Share by public link And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/lorem.txt" And user "Alice" has logged in using the webUI When the user creates a new public link for file "lorem.txt" using the webUI - And user "Alice" gets the info of the last share using the sharing API + And user "Alice" gets the info of the last public link share using the sharing API Then the fields of the last response to user "Alice" should include | expiration | +7 days | diff --git a/tests/acceptance/features/webUISharingPublic2/reShareByPublicLink.feature b/tests/acceptance/features/webUISharingPublic2/reShareByPublicLink.feature index e54b1aeadd09..475239ef56a4 100644 --- a/tests/acceptance/features/webUISharingPublic2/reShareByPublicLink.feature +++ b/tests/acceptance/features/webUISharingPublic2/reShareByPublicLink.feature @@ -32,8 +32,7 @@ Feature: Reshare by public link And user "Alice" has uploaded file with content "some content" to "/simple-folder/sub-folder/randomfile.txt" And user "Alice" has shared folder "/simple-folder" with user "Brian" with permissions "share,read" And user "Brian" has logged in using the webUI - When the user opens folder "simple-folder" using the webUI - And the user creates a new public link for folder "sub-folder" using the webUI + When the user creates a new public link for folder "simple-folder/sub-folder" using the webUI And the public accesses the last created public link using the webUI Then file "randomfile.txt" should be listed on the webUI @@ -42,8 +41,7 @@ Feature: Reshare by public link And user "Alice" has uploaded file with content "some content" to "/simple-folder/randomfile.txt" And user "Alice" has shared folder "/simple-folder" with user "Brian" with permissions "share,read" And user "Brian" has logged in using the webUI - When the user opens folder "simple-folder" using the webUI - And the user creates a new public link for file "randomfile.txt" using the webUI + When the user creates a new public link for file "simple-folder/randomfile.txt" using the webUI And the public accesses the last created public link using the webUI Then the text preview of the public link should contain "some content" @@ -68,8 +66,7 @@ Feature: Reshare by public link And user "Alice" has shared folder "/simple-folder" with user "Brian" with permissions "share,read" And parameter "shareapi_allow_public_notification" of app "core" has been set to "yes" And user "Brian" has logged in using the webUI - When the user opens folder "simple-folder" using the webUI - And the user creates a new public link for file "randomfile.txt" using the webUI with + When the user creates a new public link for file "simple-folder/randomfile.txt" using the webUI with | email | foo@bar.co | Then the email address "foo@bar.co" should have received an email from user "Brian" with the body containing """ diff --git a/tests/acceptance/features/webUISharingPublic2/shareByPublicLink.feature b/tests/acceptance/features/webUISharingPublic2/shareByPublicLink.feature index e3533b96cb93..9e8d13842058 100644 --- a/tests/acceptance/features/webUISharingPublic2/shareByPublicLink.feature +++ b/tests/acceptance/features/webUISharingPublic2/shareByPublicLink.feature @@ -138,7 +138,7 @@ Feature: Share by public link | shareType | public_link | And user "Alice" has logged in using the webUI When the user changes the expiration of the public link named "Public link" of file "lorem.txt" to "21-07-2038" - And the user gets the info of the last share using the sharing API + And the user gets the info of the last public link share using the sharing API Then the fields of the last response to user "Alice" should include | expiration | 21-07-2038 | @@ -151,20 +151,19 @@ Feature: Share by public link | shareType | public_link | And user "Alice" has logged in using the webUI When the user changes the expiration of the public link named "Public link" of file "lorem.txt" to "14-09-2017" - And the user gets the info of the last share using the sharing API + And the user gets the info of the last public link share using the sharing API Then the user should see an error message on the public link share dialog saying "Expiration date is in the past" And the fields of the last response to user "Alice" should include | expiration | 14-10-2038 | - Scenario: share two file with same name but different paths by public link + Scenario: share two files with the same name but different paths by public link Given user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/lorem.txt" And user "Alice" has created folder "/simple-folder" And user "Alice" has uploaded file "filesForUpload/lorem.txt" to "/simple-folder/lorem.txt" And user "Alice" has logged in using the webUI When the user creates a new public link for file "lorem.txt" using the webUI And the user closes the details dialog - And the user opens folder "simple-folder" using the webUI - And the user creates a new public link for file "lorem.txt" using the webUI + And the user creates a new public link for file "simple-folder/lorem.txt" using the webUI And the user browses to the shared-by-link page Then file "lorem.txt" with path "" should be listed in the shared with others page on the webUI And file "lorem.txt" with path "/simple-folder" should be listed in the shared with others page on the webUI @@ -232,7 +231,7 @@ Feature: Share by public link And user "Alice" has logged in using the webUI And the user changes the expiration of the public link named "Public link" of file "lorem.txt" to " " Then the user should see an error message on the public link popup saying "Expiration date is required" - And the user gets the info of the last share using the sharing API + And the user gets the info of the last public link share using the sharing API And the fields of the last response to user "Alice" should include | expiration | + 5 days | @@ -246,7 +245,7 @@ Feature: Share by public link | shareType | public_link | And user "Alice" has logged in using the webUI And the user changes the expiration of the public link named "Public link" of file "lorem.txt" to " " - And the user gets the info of the last share using the sharing API + And the user gets the info of the last public link share using the sharing API And the fields of the last response to user "Alice" should include | expiration | |