[tests-only][full-ci]Add lock related tests for /Shares on ocis (#4404)
This commit is contained in:
1 parent
e2e96ff436
commit
f9cd1f5271
3 files changed
+271
-56
No files matched your search
@@ -33,3 +33,13 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
|||||||
### [PROPFIND on accepted shares with identical names containing brackets exit with 404](https://github.com/owncloud/ocis/issues/4421)
|
### [PROPFIND on accepted shares with identical names containing brackets exit with 404](https://github.com/owncloud/ocis/issues/4421)
|
||||||
|
|
||||||
- [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12)
|
- [apiSpaces/changingFilesShare.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changingFilesShare.feature#L12)
|
||||||
|
|
||||||
|
#### [Webdav LOCK operations](https://github.com/owncloud/ocis/issues/1284)
|
||||||
|
- [apiSpaces/lockSpaces.feature:31](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L31)
|
||||||
|
- [apiSpaces/lockSpaces.feature:32](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L32)
|
||||||
|
- [apiSpaces/lockSpaces.feature:50](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L50)
|
||||||
|
- [apiSpaces/lockSpaces.feature:51](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L51)
|
||||||
|
- [apiSpaces/lockSpaces.feature:71](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L71)
|
||||||
|
- [apiSpaces/lockSpaces.feature:72](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L72)
|
||||||
|
- [apiSpaces/lockSpaces.feature:89](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L89)
|
||||||
|
- [apiSpaces/lockSpaces.feature:90](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/lockSpaces.feature#L90)
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
@api @skipOnOcV10
|
||||||
|
Feature: lock
|
||||||
|
# Note: This Feature includes all the tests from core (apiWebdavLock suite) related to /Shares since in core no implementation is there for space Shares Jail
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given these users have been created with default attributes and without skeleton files:
|
||||||
|
| username |
|
||||||
|
| Alice |
|
||||||
|
| Brian |
|
||||||
|
| Carol |
|
||||||
|
And user "Alice" has created folder "PARENT"
|
||||||
|
And user "Brian" has created folder "PARENT"
|
||||||
|
And user "Carol" has created folder "PARENT"
|
||||||
|
And using spaces DAV path
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the owner
|
||||||
|
Given user "Alice" has shared folder "PARENT" with user "Brian"
|
||||||
|
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||||
|
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||||
|
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||||
|
And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties
|
||||||
|
| lockscope | <lock-scope> |
|
||||||
|
When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API
|
||||||
|
And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API
|
||||||
|
And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API
|
||||||
|
Then the HTTP status code of responses on all endpoints should be "423"
|
||||||
|
And as "Alice" file "/PARENT/textfile.txt" should not exist
|
||||||
|
Examples:
|
||||||
|
| lock-scope |
|
||||||
|
| shared |
|
||||||
|
| exclusive |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: lock should propagate correctly when uploaded overwriting to a reshare that was locked by the owner
|
||||||
|
Given user "Alice" has uploaded file with content "ownCloud test text file parent" to "PARENT/parent.txt"
|
||||||
|
And user "Alice" has shared folder "PARENT" with user "Brian"
|
||||||
|
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||||
|
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||||
|
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||||
|
And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties
|
||||||
|
| lockscope | <lock-scope> |
|
||||||
|
When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API
|
||||||
|
And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API
|
||||||
|
And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/parent.txt" using the WebDAV API
|
||||||
|
Then the HTTP status code of responses on all endpoints should be "423"
|
||||||
|
And the content of file "/PARENT/parent.txt" for user "Alice" should be "ownCloud test text file parent"
|
||||||
|
Examples:
|
||||||
|
| lock-scope |
|
||||||
|
| shared |
|
||||||
|
| exclusive |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: lock should propagate correctly when the public uploads to a reshared share that was locked by the original owner
|
||||||
|
Given user "Alice" has shared folder "PARENT" with user "Brian"
|
||||||
|
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||||
|
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||||
|
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||||
|
And user "Carol" has created a public link share inside of space "Shares Jail" with settings:
|
||||||
|
| path | PARENT |
|
||||||
|
| shareType | 3 |
|
||||||
|
| permissions | 15 |
|
||||||
|
| name | public link |
|
||||||
|
And user "Alice" has locked folder "/PARENT" inside space "Personal" setting the following properties
|
||||||
|
| lockscope | <lock-scope> |
|
||||||
|
When the public uploads file "test.txt" with content "test" using the new public WebDAV API
|
||||||
|
Then the HTTP status code should be "423"
|
||||||
|
And as "Alice" file "/PARENT/test.txt" should not exist
|
||||||
|
Examples:
|
||||||
|
| lock-scope |
|
||||||
|
| shared |
|
||||||
|
| exclusive |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: lock should propagate correctly when uploaded to a reshare that was locked by the resharing user
|
||||||
|
Given user "Alice" has shared folder "PARENT" with user "Brian"
|
||||||
|
And user "Brian" has accepted share "/PARENT" offered by user "Alice"
|
||||||
|
And user "Brian" has shared the following entity "PARENT" inside of space "Shares Jail" with user "Carol" with role "editor"
|
||||||
|
And user "Carol" has accepted share "/PARENT" offered by user "Brian"
|
||||||
|
And user "Brian" has locked folder "/PARENT" inside space "Shares Jail" setting the following properties
|
||||||
|
| lockscope | <lock-scope> |
|
||||||
|
When user "Carol" uploads a file inside space "Shares Jail" with content "uploaded by carol" to "PARENT/textfile.txt" using the WebDAV API
|
||||||
|
And user "Brian" uploads a file inside space "Shares Jail" with content "uploaded by brian" to "PARENT/textfile.txt" using the WebDAV API
|
||||||
|
And user "Alice" uploads file "filesForUpload/textfile.txt" to "/PARENT/textfile.txt" using the WebDAV API
|
||||||
|
Then the HTTP status code of responses on all endpoints should be "423"
|
||||||
|
And as "Alice" file "/PARENT/textfile.txt" should not exist
|
||||||
|
Examples:
|
||||||
|
| lock-scope |
|
||||||
|
| shared |
|
||||||
|
| exclusive |
|
||||||
@@ -97,6 +97,12 @@ class SpacesContext implements Context {
|
|||||||
*/
|
*/
|
||||||
private $storedEtags = [];
|
private $storedEtags = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string[][]
|
||||||
|
*/
|
||||||
|
private $tokenOfLastLock = [];
|
||||||
|
|
||||||
private $etagPropfindBody = '<?xml version="1.0"?>'
|
private $etagPropfindBody = '<?xml version="1.0"?>'
|
||||||
. '<d:propfind xmlns:d="DAV:" '
|
. '<d:propfind xmlns:d="DAV:" '
|
||||||
. 'xmlns:oc="http://owncloud.org/ns" '
|
. 'xmlns:oc="http://owncloud.org/ns" '
|
||||||
@@ -457,7 +463,7 @@ class SpacesContext implements Context {
|
|||||||
}
|
}
|
||||||
$this->sendDeleteSpaceRequest($userName, $value["name"]);
|
$this->sendDeleteSpaceRequest($userName, $value["name"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -696,27 +702,27 @@ class SpacesContext implements Context {
|
|||||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, $method, $user, $password, $headers);
|
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, $method, $user, $password, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send proppatch request to url
|
* send proppatch request to url
|
||||||
* @param string $fullUrl
|
*
|
||||||
* @param string $user
|
* @param string $fullUrl
|
||||||
* @param string $password
|
* @param string $user
|
||||||
* @param string $xRequestId
|
* @param string $password
|
||||||
* @param array $headers
|
* @param string $xRequestId
|
||||||
* @param mixed|null $body
|
* @param array $headers
|
||||||
* @return ResponseInterface
|
* @param mixed|null $body
|
||||||
*/
|
* @return ResponseInterface
|
||||||
public function sendPropPatchRequest(
|
*/
|
||||||
string $fullUrl,
|
public function sendPropPatchRequest(
|
||||||
string $user,
|
string $fullUrl,
|
||||||
string $password,
|
string $user,
|
||||||
string $xRequestId = '',
|
string $password,
|
||||||
array $headers = [],
|
string $xRequestId = '',
|
||||||
$body
|
array $headers = [],
|
||||||
): ResponseInterface
|
$body
|
||||||
{
|
): ResponseInterface {
|
||||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PROPPATCH', $user, $password, $headers, $body);
|
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PROPPATCH', $user, $password, $headers, $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" lists all available spaces via the GraphApi$/
|
* @When /^user "([^"]*)" lists all available spaces via the GraphApi$/
|
||||||
@@ -2135,7 +2141,7 @@ class SpacesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" shares the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/
|
* Request to send share of resource inside of space
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $entity
|
* @param string $entity
|
||||||
@@ -2146,13 +2152,7 @@ class SpacesContext implements Context {
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function sendShareEntityInsideOfSpaceRequest(
|
public function sendRequestForShareOfEntityInsideOfSpace(string $user, string $entity, string $spaceName, string $userRecipient, string $role):void {
|
||||||
string $user,
|
|
||||||
string $entity,
|
|
||||||
string $spaceName,
|
|
||||||
string $userRecipient,
|
|
||||||
string $role
|
|
||||||
): void {
|
|
||||||
$space = $this->getSpaceByName($user, $spaceName);
|
$space = $this->getSpaceByName($user, $spaceName);
|
||||||
$body = [
|
$body = [
|
||||||
"space_ref" => $space['id'] . "/" . $entity,
|
"space_ref" => $space['id'] . "/" . $entity,
|
||||||
@@ -2174,6 +2174,54 @@ class SpacesContext implements Context {
|
|||||||
$this->setLastShareData();
|
$this->setLastShareData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When /^user "([^"]*)" shares the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param string $entity
|
||||||
|
* @param string $spaceName
|
||||||
|
* @param string $userRecipient
|
||||||
|
* @param string $role
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function sharesTheFollowingEntityInsideOfSpace(
|
||||||
|
string $user,
|
||||||
|
string $entity,
|
||||||
|
string $spaceName,
|
||||||
|
string $userRecipient,
|
||||||
|
string $role
|
||||||
|
): void {
|
||||||
|
$this->sendRequestForShareOfEntityInsideOfSpace($user, $entity, $spaceName, $userRecipient, $role);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^user "([^"]*)" has shared the following entity "([^"]*)" inside of space "([^"]*)" with user "([^"]*)" with role "([^"]*)"$/
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param string $entity
|
||||||
|
* @param string $spaceName
|
||||||
|
* @param string $userRecipient
|
||||||
|
* @param string $role
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function hasSharedTheFollowingEntityInsideOfSpace(
|
||||||
|
string $user,
|
||||||
|
string $entity,
|
||||||
|
string $spaceName,
|
||||||
|
string $userRecipient,
|
||||||
|
string $role
|
||||||
|
): void {
|
||||||
|
$this->sendRequestForShareOfEntityInsideOfSpace($user, $entity, $spaceName, $userRecipient, $role);
|
||||||
|
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||||
|
200,
|
||||||
|
"Expected response status code should be 200"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" creates a public link share inside of space "([^"]*)" with settings:$/
|
* @When /^user "([^"]*)" creates a public link share inside of space "([^"]*)" with settings:$/
|
||||||
*
|
*
|
||||||
@@ -3016,6 +3064,74 @@ class SpacesContext implements Context {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request to lock the resource inside of space
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param string $resource
|
||||||
|
* @param TableNode $properties
|
||||||
|
* @param string $spaceName
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function sendRequestToLockResouceInsideOfSpace(string $user, string $resource, TableNode $properties, string $spaceName):void {
|
||||||
|
$body
|
||||||
|
= "<?xml version='1.0' encoding='UTF-8'?>" .
|
||||||
|
"<d:lockinfo xmlns:d='DAV:'> ";
|
||||||
|
$headers = [];
|
||||||
|
$this->featureContext->verifyTableNodeRows($properties, [], ['lockscope', 'depth', 'timeout']);
|
||||||
|
$propertiesRows = $properties->getRowsHash();
|
||||||
|
foreach ($propertiesRows as $property => $value) {
|
||||||
|
if ($property === "depth" || $property === "timeout") {
|
||||||
|
//properties that are set in the header not in the xml
|
||||||
|
$headers[$property] = $value;
|
||||||
|
} else {
|
||||||
|
$body .= "<d:$property><d:$value/></d:$property>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$body .= "</d:lockinfo>";
|
||||||
|
$space = $this->getSpaceByName($user, $spaceName);
|
||||||
|
$fullUrl = $space['root']['webDavUrl'] . '/' . ltrim($resource, '/');
|
||||||
|
$this->featureContext->setResponse(
|
||||||
|
HttpRequestHelper::sendRequest(
|
||||||
|
$fullUrl,
|
||||||
|
"",
|
||||||
|
'LOCK',
|
||||||
|
$user,
|
||||||
|
$this->featureContext->getPasswordForUser($user),
|
||||||
|
[],
|
||||||
|
$body
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||||
|
200,
|
||||||
|
__METHOD__ . " Failed to lock the resource $resource"
|
||||||
|
);
|
||||||
|
$responseXml = $this->featureContext->getResponseXml(null, __METHOD__);
|
||||||
|
$this->featureContext->setResponseXmlObject($responseXml);
|
||||||
|
$xmlPart = $responseXml->xpath("//d:locktoken/d:href");
|
||||||
|
if (\is_array($xmlPart) && isset($xmlPart[0])) {
|
||||||
|
$this->tokenOfLastLock[$user][$resource] = (string) $xmlPart[0];
|
||||||
|
} else {
|
||||||
|
Assert::fail("could not find lock token after trying to lock '$resource'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^user "([^"]*)" has locked folder "([^"]*)" inside space "([^"]*)" setting the following properties$/
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param string $resource
|
||||||
|
* @param TableNode $properties
|
||||||
|
* @param string $spaceName
|
||||||
|
*
|
||||||
|
* @throws Exception | GuzzleException
|
||||||
|
*/
|
||||||
|
public function userHasLockedResourceOfSpace(string $user, string $resource, TableNode $properties, string $spaceName) {
|
||||||
|
$this->sendRequestToLockResouceInsideOfSpace($user, $resource, $properties, $spaceName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" creates a public link share of the space "([^"]*)" with settings:$/
|
* @When /^user "([^"]*)" creates a public link share of the space "([^"]*)" with settings:$/
|
||||||
*
|
*
|
||||||
@@ -3225,21 +3341,20 @@ class SpacesContext implements Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" favorites element "([^"]*)" in space "([^"]*)" using the WebDAV API$/
|
* @When /^user "([^"]*)" favorites element "([^"]*)" in space "([^"]*)" using the WebDAV API$/
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param string $spaceName
|
* @param string $spaceName
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void
|
public function userFavoritesElementInSpaceUsingTheWebdavApi(string $user, string $path, string $spaceName): void {
|
||||||
{
|
$space = $this->getSpaceByName($user, $spaceName);
|
||||||
$space = $this->getSpaceByName($user, $spaceName);
|
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/");
|
||||||
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($path, "/");
|
$body = '<?xml version="1.0"?>
|
||||||
$body = '<?xml version="1.0"?>
|
|
||||||
<d:propertyupdate xmlns:d="DAV:"
|
<d:propertyupdate xmlns:d="DAV:"
|
||||||
xmlns:oc="http://owncloud.org/ns">
|
xmlns:oc="http://owncloud.org/ns">
|
||||||
<d:set>
|
<d:set>
|
||||||
@@ -3248,15 +3363,15 @@ class SpacesContext implements Context {
|
|||||||
</d:prop>
|
</d:prop>
|
||||||
</d:set>
|
</d:set>
|
||||||
</d:propertyupdate>';
|
</d:propertyupdate>';
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
$this->sendProppatchRequest(
|
$this->sendProppatchRequest(
|
||||||
$fullUrl,
|
$fullUrl,
|
||||||
$user,
|
$user,
|
||||||
$this->featureContext->getPasswordForUser($user),
|
$this->featureContext->getPasswordForUser($user),
|
||||||
$this->featureContext->getStepLineRef(),
|
$this->featureContext->getStepLineRef(),
|
||||||
[],
|
[],
|
||||||
$body
|
$body
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user