From 66e09938cb40a73efccbd198a33ccd035fb757f8 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi <41103328+SwikritiT@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:00:47 +0545 Subject: [PATCH] tests: add tests for update public link to delete password invite permission (#7894) Signed-off-by: Swikriti Tripathi --- tests/TestHelpers/SharingHelper.php | 4 +- .../shareSpacesViaLink.feature | 97 +++++++++++++++++-- .../acceptance/features/bootstrap/Sharing.php | 2 +- .../changingPublicLinkShare.feature | 20 ++++ 4 files changed, 114 insertions(+), 9 deletions(-) diff --git a/tests/TestHelpers/SharingHelper.php b/tests/TestHelpers/SharingHelper.php index 86dafcfcda..0d35f858cd 100644 --- a/tests/TestHelpers/SharingHelper.php +++ b/tests/TestHelpers/SharingHelper.php @@ -40,6 +40,7 @@ class SharingHelper { 'create' => 4, 'delete' => 8, 'share' => 16, + 'invite' => 0 ]; public const SHARE_TYPES = [ @@ -181,6 +182,7 @@ class SharingHelper { * 'create' => 4 * 'delete' => 8 * 'share' => 16 + * 'invite' => 0 * * @param string[]|string|int|int[] $permissions * @@ -209,7 +211,7 @@ class SharingHelper { ); } } - if ($permissionSum < 1 || $permissionSum > 31) { + if ($permissionSum < 0 || $permissionSum > 31) { throw new InvalidArgumentException( "invalid permission total ($permissionSum)" ); diff --git a/tests/acceptance/features/apiSpacesShares/shareSpacesViaLink.feature b/tests/acceptance/features/apiSpacesShares/shareSpacesViaLink.feature index f762a767bc..ac986773b9 100644 --- a/tests/acceptance/features/apiSpacesShares/shareSpacesViaLink.feature +++ b/tests/acceptance/features/apiSpacesShares/shareSpacesViaLink.feature @@ -130,15 +130,23 @@ Feature: Share spaces via link And for user "Alice" the space "Alice Hansen" should not contain the last created public link - Scenario: space admin removes password of a public link share of a space - Given user "Alice" has created a public link share of the space "share space" with settings: - | permissions | 1 | - | password | %public% | + Scenario Outline: space admin removes password of a public link share of a space (read/invite permission) + Given using OCS API version "" + And user "Alice" has created a public link share of the space "share space" with settings: + | permissions | | + | password | %public% | When user "Alice" updates the last public link share using the sharing API with - | permissions | 1 | - | password | | + | permissions | | + | password | | Then the HTTP status code should be "200" - And the OCS status code should be "100" + And the OCS status code should be "" + And the OCS status message should be "OK" + Examples: + | ocs_api_version | ocs_status_code | permissions | + | 1 | 100 | 1 | + | 1 | 100 | 0 | + | 2 | 200 | 1 | + | 2 | 200 | 0 | Scenario Outline: space admin tries to remove password of a public link share of a space (various permission) @@ -158,6 +166,23 @@ Feature: Share spaces via link | 4 | + Scenario Outline: space admin removes password of a public link share of a space (invite permission) + Given using OCS API version "" + And user "Alice" has created a public link share of the space "share space" with settings: + | permissions | 1 | + | password | %public% | + When user "Alice" updates the last public link share using the sharing API with + | permissions | 0 | + | password | | + Then the HTTP status code should be "200" + And the OCS status code should be "" + And the OCS status message should be "OK" + Examples: + | ocs_api_version | ocs_status_code | + | 1 | 100 | + | 2 | 200 | + + Scenario: space manager tries to remove password of a public link share of a space (read permission) Given user "Alice" has shared a space "share space" with settings: | shareWith | Brian | @@ -191,3 +216,61 @@ Feature: Share spaces via link | 5 | | 15 | | 4 | + + + Scenario Outline: space manager removes password of a public link share of a space (invite permission) + Given using OCS API version "" + And user "Alice" has shared a space "share space" with settings: + | shareWith | Brian | + | role | manager | + And user "Brian" has created a public link share of the space "share space" with settings: + | permissions | 1 | + | password | %public% | + When user "Brian" updates the last public link share using the sharing API with + | permissions | 0 | + | password | | + Then the HTTP status code should be "200" + And the OCS status code should be "" + And the OCS status message should be "OK" + Examples: + | ocs_api_version | ocs_status_code | + | 1 | 100 | + | 2 | 200 | + + + Scenario Outline: space member tries to remove the password of a public link share of a space + Given using OCS API version "" + And user "Alice" has shared a space "share space" with settings: + | shareWith | Brian | + | role | | + And user "Alice" has created a public link share of the space "share space" with settings: + | permissions | | + | password | %public% | + When user "Brian" updates the last public link share using the sharing API with + | permissions | | + | password | | + Then the HTTP status code should be "" + And the OCS status code should be "997" + And the OCS status message should be "missing permissions to update share" + Examples: + | ocs_api_version | http_status_code | role | permissions | + | 1 | 200 | viewer | 1 | + | 2 | 401 | viewer | 1 | + | 1 | 200 | viewer | 5 | + | 2 | 401 | viewer | 5 | + | 1 | 200 | viewer | 15 | + | 2 | 401 | viewer | 15 | + | 1 | 200 | viewer | 4 | + | 2 | 401 | viewer | 4 | + | 1 | 200 | viewer | 0 | + | 2 | 401 | viewer | 0 | + | 1 | 200 | editor | 1 | + | 2 | 401 | editor | 1 | + | 1 | 200 | editor | 5 | + | 2 | 401 | editor | 5 | + | 1 | 200 | editor | 15 | + | 2 | 401 | editor | 15 | + | 1 | 200 | editor | 4 | + | 2 | 401 | editor | 4 | + | 1 | 200 | editor | 0 | + | 2 | 401 | editor | 0 | diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index c80b6507d2..d40b297609 100755 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -236,7 +236,7 @@ trait Sharing { * | permissions | The permissions to set on the share. | * | | 1 = read; 2 = update; 4 = create; | * | | 8 = delete; 16 = share; 31 = all | - * | | 15 = change | + * | | 15 = change; 0 = invite | * | | 4 = uploadwriteonly | * | | (default: 31, for public shares: 1) | * | | Pass either the (total) number, | diff --git a/tests/acceptance/features/coreApiSharePublicLink1/changingPublicLinkShare.feature b/tests/acceptance/features/coreApiSharePublicLink1/changingPublicLinkShare.feature index 74296b42ab..3de10b72e6 100644 --- a/tests/acceptance/features/coreApiSharePublicLink1/changingPublicLinkShare.feature +++ b/tests/acceptance/features/coreApiSharePublicLink1/changingPublicLinkShare.feature @@ -164,6 +164,26 @@ Feature: changing a public link share And the OCS status message should be "missing required password" + Scenario Outline: normal user removes password of a public link (invite only public link) + Given using OCS API version "" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "PARENT/parent.txt" + And user "Alice" has created a public link share with settings + | path | /PARENT | + | permissions | invite | + | password | %public% | + When user "Alice" updates the last public link share using the sharing API with + | path | /PARENT | + | password | | + | permissions | invite | + Then the HTTP status code should be "200" + And the OCS status code should be "" + And the OCS status message should be "OK" + Examples: + | ocs_api_version | ocs_status_code | + | 1 | 100 | + | 2 | 200 | + + Scenario: administrator removes password of a read-only public link Given admin has created folder "/PARENT" And user "admin" has uploaded file "filesForUpload/textfile.txt" to "PARENT/parent.txt"