From a1dd520262f148ead390baecf38c29dffb37164f Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi <41103328+SwikritiT@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:39:47 +0545 Subject: [PATCH] tests: add test for lock/unlock in public link share (#7789) --- ...ected-failures-localAPI-on-OCIS-storage.md | 35 ++++++ .../features/apiLocks/lockFiles.feature | 113 ++++++++++++++++++ .../features/apiLocks/unlockFiles.feature | 24 ++++ .../bootstrap/WebDavLockingContext.php | 8 +- 4 files changed, 177 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 43cead1b0..0a1ebacb0 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -199,6 +199,18 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiLocks/unlockFiles.feature:88](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L88) - [apiLocks/unlockFiles.feature:89](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L89) - [apiLocks/unlockFiles.feature:90](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L90) +- [apiLocks/lockFiles.feature:388](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L388) +- [apiLocks/lockFiles.feature:389](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L389) +- [apiLocks/lockFiles.feature:390](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L390) +- [apiLocks/lockFiles.feature:391](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L391) +- [apiLocks/lockFiles.feature:392](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L392) +- [apiLocks/lockFiles.feature:393](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L393) +- [apiLocks/lockFiles.feature:429](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L429) +- [apiLocks/lockFiles.feature:430](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L430) +- [apiLocks/lockFiles.feature:431](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L431) +- [apiLocks/lockFiles.feature:432](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L432) +- [apiLocks/lockFiles.feature:433](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L433) +- [apiLocks/lockFiles.feature:434](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L434) #### [Folders can be locked and locking works partially](https://github.com/owncloud/ocis/issues/7641) @@ -231,5 +243,28 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiLocks/unlockFiles.feature:133](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L133) - [apiLocks/unlockFiles.feature:134](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L134) +### [Anonymous user trying lock a file shared to them through a public link gives 405](https://github.com/owncloud/ocis/issues/7790) +- [apiLocks/lockFiles.feature:474](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L474) +- [apiLocks/lockFiles.feature:475](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L475) +- [apiLocks/lockFiles.feature:476](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L476) +- [apiLocks/lockFiles.feature:477](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L477) +- [apiLocks/lockFiles.feature:478](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L478) +- [apiLocks/lockFiles.feature:479](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L479) +- [apiLocks/lockFiles.feature:496](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L496) +- [apiLocks/lockFiles.feature:497](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L497) +- [apiLocks/lockFiles.feature:498](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L498) +- [apiLocks/lockFiles.feature:499](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L499) +- [apiLocks/lockFiles.feature:500](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L500) +- [apiLocks/lockFiles.feature:501](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L501) + +### [anonymous user with viewer role in public link of a folder can lock a file inside it](https://github.com/owncloud/ocis/issues/7785) +- [apiLocks/lockFiles.feature:452](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L452) +- [apiLocks/lockFiles.feature:453](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L453) +- [apiLocks/lockFiles.feature:454](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L454) +- [apiLocks/lockFiles.feature:455](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L455) +- [apiLocks/lockFiles.feature:456](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L456) +- [apiLocks/lockFiles.feature:457](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L457) + + - Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/apiLocks/lockFiles.feature b/tests/acceptance/features/apiLocks/lockFiles.feature index e9d673fc6..dece6da8b 100644 --- a/tests/acceptance/features/apiLocks/lockFiles.feature +++ b/tests/acceptance/features/apiLocks/lockFiles.feature @@ -368,6 +368,29 @@ Feature: lock files | spaces | shared | | spaces | exclusive | + @issue-7641 + Scenario Outline: try to lock a folder as anonymous user + Given using DAV path + And user "Alice" has created folder "PARENT" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "PARENT/textfile0.txt" + And user "Alice" has created a public link share with settings + | path | PARENT | + | permissions | change | + | password | %public% | + When the public locks the last public link shared file using the WebDAV API setting the following properties + | lockscope | | + Then the HTTP status code should be "403" + And 0 locks should be reported for file "PARENT" of user "Alice" by the WebDAV API + And user "Alice" should be able to upload file "filesForUpload/lorem.txt" to "PARENT/textfile0.txt" + And user "Alice" should be able to create folder "/PARENT/sub-folder" + Examples: + | dav-path-version | lock-scope | + | old | shared | + | old | exclusive | + | new | shared | + | new | exclusive | + | spaces | shared | + | spaces | exclusive | Scenario Outline: lock expiration Given using DAV path @@ -386,3 +409,93 @@ Feature: lock files | new | exclusive | | spaces | shared | | spaces | exclusive | + + + Scenario Outline: lock a file inside a folder shared by a link as anonymous user with edit permission + Given using DAV path + And user "Alice" has created folder "PARENT" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "PARENT/textfile0.txt" + And user "Alice" has created a public link share with settings + | path | PARENT | + | permissions | change | + | password | %public% | + When the public locks "textfile0.txt" in the last public link shared folder using the new public WebDAV API setting the following properties + | lockscope | | + Then the HTTP status code should be "200" + And 1 locks should be reported for file "PARENT/textfile0.txt" of user "Alice" by the WebDAV API + And user "Alice" should not be able to upload file "filesForUpload/lorem.txt" to "PARENT/textfile0.txt" + Examples: + | dav-path-version | lock-scope | + | old | shared | + | old | exclusive | + | new | shared | + | new | exclusive | + | spaces | shared | + | spaces | exclusive | + + + Scenario Outline: try to lock a file inside a folder shared by a link as anonymous user with read permission + Given using DAV path + And user "Alice" has created folder "PARENT" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "PARENT/textfile0.txt" + And user "Alice" has created a public link share with settings + | path | PARENT | + | permissions | read | + | password | %public% | + When the public tries to lock "textfile0.txt" in the last public link shared folder using the new public WebDAV API setting the following properties + | lockscope | | + Then the HTTP status code should be "403" + And 0 locks should be reported for file "PARENT/textfile0.txt" of user "Alice" by the WebDAV API + And user "Alice" should be able to upload file "filesForUpload/lorem.txt" to "PARENT/textfile0.txt" + Examples: + | dav-path-version | lock-scope | + | old | shared | + | old | exclusive | + | new | shared | + | new | exclusive | + | spaces | shared | + | spaces | exclusive | + + + Scenario Outline: lock a file shared by a link as anonymous user with edit permission + Given using DAV path + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile0.txt" + And user "Alice" has created a public link share with settings + | path | textfile0.txt | + | permissions | change | + | password | %public% | + When the public locks the last public link shared file using the WebDAV API setting the following properties + | lockscope | | + Then the HTTP status code should be "200" + And 1 locks should be reported for file "textfile0.txt" of user "Alice" by the WebDAV API + And user "Alice" should not be able to upload file "filesForUpload/lorem.txt" to "textfile0.txt" + Examples: + | dav-path-version | lock-scope | + | old | shared | + | old | exclusive | + | new | shared | + | new | exclusive | + | spaces | shared | + | spaces | exclusive | + + + Scenario Outline: try to lock a file shared by a link as anonymous user with read permission + Given using DAV path + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "textfile0.txt" + And user "Alice" has created a public link share with settings + | path | textfile0.txt | + | permissions | read | + | password | %public% | + When the public tries to lock the last public link shared file using the WebDAV API setting the following properties + | lockscope | | + Then the HTTP status code should be "403" + And 0 locks should be reported for file "textfile0.txt" of user "Alice" by the WebDAV API + And user "Alice" should be able to upload file "filesForUpload/lorem.txt" to "textfile0.txt" + Examples: + | dav-path-version | lock-scope | + | old | shared | + | old | exclusive | + | new | shared | + | new | exclusive | + | spaces | shared | + | spaces | exclusive | diff --git a/tests/acceptance/features/apiLocks/unlockFiles.feature b/tests/acceptance/features/apiLocks/unlockFiles.feature index b24ee8a28..41d047159 100644 --- a/tests/acceptance/features/apiLocks/unlockFiles.feature +++ b/tests/acceptance/features/apiLocks/unlockFiles.feature @@ -274,3 +274,27 @@ Feature: unlock locked items | dav-path | | /remote.php/dav/spaces/<> | | /dav/spaces/<> | + + + Scenario Outline: unlock a file as an anonymous user + Given using DAV path + And user "Alice" has created folder "PARENT" + And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "PARENT/textfile0.txt" + And user "Alice" has created a public link share with settings + | path | PARENT | + | permissions | change | + | password | %public% | + And the public has locked "textfile0.txt" in the last public link shared folder setting the following properties + | lockscope | | + When the public unlocks file "textfile0.txt" using the WebDAV API + Then the HTTP status code should be "204" + And 0 locks should be reported for file "PARENT/textfile0.txt" of user "Alice" by the WebDAV API + And user "Alice" should be able to upload file "filesForUpload/lorem.txt" to "PARENT/textfile0.txt" + Examples: + | dav-path-version | lock-scope | + | old | shared | + | old | exclusive | + | new | shared | + | new | exclusive | + | spaces | shared | + | spaces | exclusive | diff --git a/tests/acceptance/features/bootstrap/WebDavLockingContext.php b/tests/acceptance/features/bootstrap/WebDavLockingContext.php index 0e0f38d07..30354d6ee 100644 --- a/tests/acceptance/features/bootstrap/WebDavLockingContext.php +++ b/tests/acceptance/features/bootstrap/WebDavLockingContext.php @@ -68,8 +68,8 @@ class WebDavLockingContext implements Context { $user = $this->featureContext->getActualUsername($user); $baseUrl = $this->featureContext->getBaseUrl(); if ($public === true) { - $type = "public-files"; - $password = null; + $type = "public-files-new"; + $password = $this->featureContext->getActualPassword("%public%"); } else { $type = "files"; $password = $this->featureContext->getPasswordForUser($user); @@ -318,7 +318,8 @@ class WebDavLockingContext implements Context { } /** - * @When the public locks the last public link shared file/folder using the WebDAV API setting the following properties + * @When the public locks the last public link shared file using the WebDAV API setting the following properties + * @When the public tries to lock the last public link shared file using the WebDAV API setting the following properties * * @param TableNode $properties * @@ -360,6 +361,7 @@ class WebDavLockingContext implements Context { /** * @When /^the public locks "([^"]*)" in the last public link shared folder using the (old|new) public WebDAV API setting the following properties$/ + * @When /^the public tries to lock "([^"]*)" in the last public link shared folder using the (old|new) public WebDAV API setting the following properties$/ * * @param string $file * @param string $publicWebDAVAPIVersion