Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test-only] new lock tests #7595

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ default:
- SpacesTUSContext:
- GraphContext:
- OcisConfigContext:
- WebDavLockingContext:

apiSpacesShares:
paths:
Expand Down
11 changes: 11 additions & 0 deletions tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,16 @@ The expected failures in this file are from features in the owncloud/ocis repo.

- [apiGraph/addUserToGroup.feature:420](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L420)

### [500 error if viewer tries to lock file](https://github.com/owncloud/ocis/issues/7600)

- [apiSpaces/lockFiles.feature:144](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockFiles.feature#L144)
- [apiSpaces/lockFiles.feature:207](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockFiles.feature#L207)

### [Shared file locking is not possible using different path](https://github.com/owncloud/ocis/issues/7599)

- [apiSpaces/lockFiles.feature:179](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockFiles.feature#L179)
- [apiSpaces/lockFiles.feature:180](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockFiles.feature#L180)
- [apiSpaces/lockFiles.feature:181](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockFiles.feature#L181)

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.
217 changes: 217 additions & 0 deletions tests/acceptance/features/apiSpaces/lockFiles.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
Feature: lock files
As a user
I want to lock files

Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |


Scenario Outline: lock a file
Given using <dav-path-version> DAV path
And user "Alice" has uploaded a file inside space "Alice Hansen" with content "some content" to "textfile.txt"
When user "Alice" locks file "textfile.txt" using the WebDAV API setting the following properties
| lockscope | exclusive |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs:
| key | value |
| d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | |
| d:lockdiscovery/d:activelock/d:depth | Infinity |
| d:lockdiscovery/d:activelock/d:timeout | Infinity |
| d:lockdiscovery/d:activelock/oc:ownername | Alice Hansen |
Examples:
| dav-path-version |
| old |
| new |
| spaces |


Scenario Outline: lock a file with a timeout
Given using <dav-path-version> DAV path
And user "Alice" has uploaded a file inside space "Alice Hansen" with content "some content" to "textfile.txt"
When user "Alice" locks file "textfile.txt" using the WebDAV API setting the following properties
| lockscope | exclusive |
| timeout | Second-5000 |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs:
| key | value |
| d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | |
| d:lockdiscovery/d:activelock/d:depth | Infinity |
| d:lockdiscovery/d:activelock/d:timeout | Second-5000 |
| d:lockdiscovery/d:activelock/oc:ownername | Alice Hansen |
Examples:
| dav-path-version |
| old |
| new |
| spaces |


Scenario Outline: lock a file using file-id
Given user "Alice" has uploaded a file inside space "Alice Hansen" with content "some content" to "textfile.txt"
And we save it into "FILEID"
When user "Alice" locks file using file-id path "<dav-path>" using the WebDAV API setting the following properties
| lockscope | exclusive |
| timeout | Second-3600 |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs:
| key | value |
| d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | |
| d:lockdiscovery/d:activelock/d:depth | Infinity |
| d:lockdiscovery/d:activelock/d:timeout | Second-3600 |
| d:lockdiscovery/d:activelock/oc:ownername | Alice Hansen |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario Outline: user cannot lock file twice
Given using <dav-path-version> DAV path
And user "Alice" has uploaded a file inside space "Alice Hansen" with content "some content" to "textfile.txt"
And user "Alice" has locked file "textfile.txt" setting the following properties
| lockscope | exclusive |
When user "Alice" tries to lock file "textfile.txt" using the WebDAV API setting the following properties
| lockscope | exclusive |
Then the HTTP status code should be "423"
Examples:
| dav-path-version |
| old |
| new |
| spaces |


Scenario Outline: lock a file in the project space
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And using spaces DAV path
And user "Alice" has created a space "Project" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "Project" with content "some content" to "textfile.txt"
And user "Alice" has shared a space "Project" with settings:
| shareWith | Brian |
| role | <role> |
When user "Brian" locks file "textfile.txt" inside the space "Project" using the WebDAV API setting the following properties
| lockscope | exclusive |
| timeout | Second-3600 |
Then the HTTP status code should be "200"
When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Brian" should contain a space "Project" with these key and value pairs:
| key | value |
| d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | |
| d:lockdiscovery/d:activelock/d:depth | Infinity |
| d:lockdiscovery/d:activelock/d:timeout | Second-3600 |
| d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy |
Examples:
| role |
| manager |
| editor |


Scenario Outline: lock a file in the project space using file-id
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And using spaces DAV path
And user "Alice" has created a space "Project" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "Project" with content "some content" to "textfile.txt"
And we save it into "FILEID"
And user "Alice" has shared a space "Project" with settings:
| shareWith | Brian |
| role | <role> |
When user "Brian" locks file using file-id path "<dav-path>" using the WebDAV API setting the following properties
| lockscope | exclusive |
| timeout | Second-3600 |
Then the HTTP status code should be "200"
When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Brian" should contain a space "Project" with these key and value pairs:
| key | value |
| d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | |
| d:lockdiscovery/d:activelock/d:depth | Infinity |
| d:lockdiscovery/d:activelock/d:timeout | Second-3600 |
| d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy |
Examples:
| role | dav-path |
| manager | /remote.php/dav/spaces/<<FILEID>> |
| editor | /dav/spaces/<<FILEID>> |


Scenario: viewer cannot lock a file in the project space
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And using spaces DAV path
And user "Alice" has created a space "Project" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "Project" with content "some content" to "textfile.txt"
And we save it into "FILEID"
And user "Alice" has shared a space "Project" with settings:
| shareWith | Brian |
| role | viewer |
When user "Brian" locks file "textfile.txt" inside the space "Project" using the WebDAV API setting the following properties
| lockscope | exclusive |
Then the HTTP status code should be "403"
When user "Brian" locks file using file-id path "/dav/spaces/<<FILEID>>" using the WebDAV API setting the following properties
| lockscope | exclusive |
Then the HTTP status code should be "403"


Scenario Outline: lock a file in the shares
Given using <dav-path-version> DAV path
And user "Alice" has uploaded a file inside space "Alice Hansen" with content "some content" to "textfile.txt"
And user "Alice" has created a share inside of space "Alice Hansen" with settings:
| path | textfile.txt |
| shareWith | Brian |
| role | editor |
When user "Brian" locks file "/Shares/textfile.txt" using the WebDAV API setting the following properties
| lockscope | exclusive |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs:
| key | value |
| d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | |
| d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy |
Examples:
| dav-path-version |
| old |
| new |
| spaces |


Scenario Outline: lock a file in the shares using file-id
Given user "Alice" has uploaded a file inside space "Alice Hansen" with content "some content" to "textfile.txt"
And we save it into "FILEID"
And user "Alice" has created a share inside of space "Alice Hansen" with settings:
| path | textfile.txt |
| shareWith | Brian |
| role | editor |
When user "Brian" locks file using file-id path "<dav-path>" using the WebDAV API setting the following properties
| lockscope | exclusive |
| timeout | Second-3600 |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Alice" should contain a space "Alice Hansen" with these key and value pairs:
| key | value |
| d:lockdiscovery/d:activelock/d:lockscope/d:exclusive | |
| d:lockdiscovery/d:activelock/oc:ownername | Brian Murphy |
Examples:
| dav-path |
| /remote.php/dav/spaces/<<FILEID>> |
| /dav/spaces/<<FILEID>> |


Scenario: viewer cannot lock a file in the shares using file-id
Given user "Alice" has uploaded a file inside space "Alice Hansen" with content "some content" to "textfile.txt"
And we save it into "FILEID"
And user "Alice" has created a share inside of space "Alice Hansen" with settings:
| path | textfile.txt |
| shareWith | Brian |
| role | viewer |
When user "Brian" locks file using file-id path "<dav-path>" using the WebDAV API setting the following properties
| lockscope | exclusive |
Then the HTTP status code should be "403"

15 changes: 14 additions & 1 deletion tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3476,7 +3476,7 @@ public function searchResultShouldContainSpace(string $user, string $spaceName):
*/
public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = ""): void {
$this->setSpaceIDByName($user, $spaceName);
$properties = ['oc:permissions','oc:file-parent','oc:fileid','oc:share-types','oc:privatelink','d:resourcetype','oc:size','oc:name','d:getcontenttype', 'oc:tags'];
$properties = ['oc:permissions','oc:file-parent','oc:fileid','oc:share-types','oc:privatelink','d:resourcetype','oc:size','oc:name','d:getcontenttype','oc:tags','d:lockdiscovery','d:activelock'];
$this->featureContext->setResponse(
WebDavHelper::propfind(
$this->featureContext->getBaseUrl(),
Expand Down Expand Up @@ -3510,6 +3510,7 @@ public function theResponseShouldContainSpace(string $method, string $space, Tab

/**
* @Then /^the "([^"]*)" response to user "([^"]*)" should contain a mountpoint "([^"]*)" with these key and value pairs:$/
* @Then /^the "([^"]*)" response to user "([^"]*)" should contain a space "([^"]*)" with these key and value pairs:$/
*
* @param string $method # method should be either PROPFIND or REPORT
* @param string $user
Expand Down Expand Up @@ -3577,6 +3578,18 @@ public function theResponseShouldContain(string $method, string $user, string $s
$actualTags = \sort($actualTags);
Assert::assertEquals($expectedTags, $actualTags, "wrong $findItem in the response");
break;
case "d:lockdiscovery/d:activelock/d:timeout":
if ($value === "Infinity") {
Assert::assertEquals($value, $responseValue, "wrong $findItem in the response");
} else {
// some time may be required between a lock and propfind request.
$responseValue = explode('-', $responseValue);
$responseValue = \intval($responseValue[1]);
$value = explode('-', $value);
$value = \intval($value[1]);
Assert::assertTrue($responseValue >= ($value - 3));
}
break;
default:
Assert::assertEquals($value, $responseValue, "wrong $findItem in the response");
break;
Expand Down
Loading