Merge pull request #8622 from owncloud/add-test-for-propfind

[full-ci] [tests-only] Added tests for PROPFIND as sharee
This commit is contained in:
Prarup Gurung
2024-03-18 09:20:06 +05:45
committed by GitHub
6 changed files with 145 additions and 47 deletions
@@ -15,7 +15,7 @@ Feature: Propfind test
Scenario: space-admin checks the PROPFIND request of a space
Given user "Alice" has uploaded a file inside space "new-space" with content "some content" to "testfile.txt"
When user "Alice" sends PROPFIND request to space "new-space" using the WebDAV API
When user "Alice" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
@@ -33,7 +33,7 @@ Feature: Propfind test
And user "Alice" has shared a space "new-space" with settings:
| shareWith | Brian |
| role | <role> |
When user "Brian" sends PROPFIND request to space "new-space" using the WebDAV API
When user "Brian" sends PROPFIND request to space "new-space" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the following headers should match these regular expressions
| X-Request-Id | /^[a-zA-Z]+\/[a-zA-Z]+\.feature:\d+(-\d+)?$/ |
@@ -56,7 +56,7 @@ Feature: Propfind test
And user "Alice" has shared a space "new-space" with settings:
| shareWith | Brian |
| role | <role> |
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain" using the WebDAV API
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "new-space" with these key and value pairs:
| key | value |
@@ -77,7 +77,7 @@ Feature: Propfind test
And user "Alice" has shared a space "new-space" with settings:
| shareWith | Brian |
| role | <role> |
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain/subFolder1/subFolder2" using the WebDAV API
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "folderMain/subFolder1/subFolder2" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "new-space" with these key and value pairs:
| key | value |
@@ -98,7 +98,7 @@ Feature: Propfind test
And user "Alice" has shared a space "new-space" with settings:
| shareWith | Brian |
| role | <role> |
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "testfile.txt" using the WebDAV API
When user "Brian" sends PROPFIND request from the space "new-space" to the resource "testfile.txt" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "new-space" with these key and value pairs:
| key | value |
@@ -15,7 +15,7 @@ Feature: lock files
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
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" 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 |
@@ -37,7 +37,7 @@ Feature: lock files
| 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
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" 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 |
@@ -59,7 +59,7 @@ Feature: lock files
| 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
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" 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 |
@@ -100,7 +100,7 @@ Feature: lock files
| 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
When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" with depth "0" 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 |
@@ -127,7 +127,7 @@ Feature: lock files
| 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
When user "Brian" sends PROPFIND request from the space "Project" to the resource "textfile.txt" with depth "0" 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 |
@@ -168,7 +168,7 @@ Feature: lock files
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
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" 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 |
@@ -192,7 +192,7 @@ Feature: lock files
| 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
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" 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 |
@@ -229,7 +229,7 @@ Feature: lock files
| lockscope | exclusive |
| timeout | Second-3600 |
Then the HTTP status code should be "423"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" 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 |
@@ -250,7 +250,7 @@ Feature: lock files
| lockscope | exclusive |
| timeout | Second-3600 |
Then the HTTP status code should be "423"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" using the WebDAV API
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "textfile.txt" with depth "0" 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 |
@@ -0,0 +1,45 @@
Feature: propfind a shares
As a user
I want to check the PROPFIND response
So that I can make sure that the response contains all the relevant values
Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
| Carol |
@issue-4421
Scenario: sharee PROPFIND a shares when multiple user shares resources with same name
Given user "Alice" has uploaded file with content "to share" to "textfile.txt"
And user "Carol" has uploaded file with content "to share" to "textfile.txt"
And user "Alice" has sent the following share invitation:
| resource | textfile.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
And user "Carol" has sent the following share invitation:
| resource | textfile.txt |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
When user "Brian" sends PROPFIND request to space "Shares" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Brian" should contain a space "Shares" with these key and value pairs:
| key | value |
| oc:fileid | UUIDof:Shares |
And the "PROPFIND" response to user "Brian" should contain a mountpoint "Shares" with these key and value pairs:
| key | value |
| oc:name | textfile.txt |
| oc:permissions | SR |
| oc:size | 8 |
| d:getcontenttype | text/plain |
And the "PROPFIND" response to user "Brian" should contain a mountpoint "Shares" with these key and value pairs:
| key | value |
| oc:name | textfile (1).txt |
| oc:permissions | SR |
| oc:size | 8 |
| d:getcontenttype | text/plain |
@@ -26,7 +26,7 @@ Feature: Tag
| tag level#1 |
| tag with symbols @^$#^%$@%!_+) |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API
When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs:
| key | value |
@@ -34,7 +34,7 @@ Feature: Tag
When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag":
| fileTag |
Then the HTTP status code should be "200"
When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" using the WebDAV API
When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs:
| key | value |
@@ -64,12 +64,12 @@ Feature: Tag
| fileTag |
| tag with symbol @^$#^%$@%!_+) |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "folderMain" using the WebDAV API
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "folderMain" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Alice" should contain a mountpoint "Alice Hansen" with these key and value pairs:
| key | value |
| oc:tags | my tag,important |
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "file.txt" using the WebDAV API
When user "Alice" sends PROPFIND request from the space "Alice Hansen" to the resource "file.txt" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response to user "Alice" should contain a mountpoint "Alice Hansen" with these key and value pairs:
| key | value |
@@ -177,7 +177,7 @@ Feature: Tag
When user "Alice" removes the following tags for folder "folderMain" of space "use-tag":
| folderTag |
| marketing |
And user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API
And user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs:
| key | value |
@@ -255,7 +255,7 @@ Feature: Tag
When user "Alice" creates the following tags for folder "folderMain" of space "use-tag":
| finance, |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API
When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs:
| key | value |
@@ -263,7 +263,7 @@ Feature: Tag
When user "Alice" creates the following tags for file "folderMain/insideTheFolder.txt" of space "use-tag":
| file,,Tag |
Then the HTTP status code should be "200"
When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" using the WebDAV API
When user "Brian" sends PROPFIND request from the space "use-tag" to the resource "folderMain/insideTheFolder.txt" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs:
| key | value |
@@ -283,7 +283,7 @@ Feature: Tag
When user "Alice" creates the following tags for folder "folderMain" of space "use-tag":
| engineering,finance,qa |
Then the HTTP status code should be "200"
When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" using the WebDAV API
When user "Alice" sends PROPFIND request from the space "use-tag" to the resource "folderMain" with depth "0" using the WebDAV API
Then the HTTP status code should be "207"
And the "PROPFIND" response should contain a space "use-tag" with these key and value pairs:
| key | value |
@@ -3597,11 +3597,11 @@ class SpacesContext implements Context {
/**
* @When /^user "([^"]*)" sends PROPFIND request to space "([^"]*)" using the WebDAV API$/
* @When /^user "([^"]*)" sends PROPFIND request from the space "([^"]*)" to the resource "([^"]*)" using the WebDAV API$/
* @When /^user "([^"]*)" sends PROPFIND request to space "([^"]*)" with depth "([^"]*)" using the WebDAV API$/
*
* @param string $user
* @param string $spaceName
* @param ?string $resource
* @param ?string $folderDepth
*
* @return void
*
@@ -3609,9 +3609,29 @@ class SpacesContext implements Context {
*
* @throws GuzzleException
*/
public function userSendsPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = ""): void {
public function userSendsPropfindRequestToSpaceUsingTheWebdavApi(string $user, string $spaceName, ?string $folderDepth = "1"): void {
$this->featureContext->setResponse(
$this->sendPropfindRequestToSpace($user, $spaceName, $resource)
$this->sendPropfindRequestToSpace($user, $spaceName, "", null, $folderDepth)
);
}
/**
* @When /^user "([^"]*)" sends PROPFIND request from the space "([^"]*)" to the resource "([^"]*)" with depth "([^"]*)" using the WebDAV API$/
*
* @param string $user
* @param string $spaceName
* @param string $resource
* @param string $folderDepth
*
* @return void
*
* @throws JsonException
*
* @throws GuzzleException
*/
public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(string $user, string $spaceName, string $resource, string $folderDepth): void {
$this->featureContext->setResponse(
$this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth)
);
}
@@ -3637,7 +3657,7 @@ class SpacesContext implements Context {
$headers[$row['header']] = $row ['value'];
}
$this->featureContext->setResponse(
$this->sendPropfindRequestToSpace($user, $spaceName, '', $headers)
$this->sendPropfindRequestToSpace($user, $spaceName, '', $headers, '0')
);
}
@@ -3646,15 +3666,36 @@ class SpacesContext implements Context {
* @param string $spaceName
* @param string|null $resource
* @param array|null $headers
* @param string|null $folderDepth
*
* @return ResponseInterface
* @throws GuzzleException
*
* @throws JsonException
*/
public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = []): ResponseInterface {
public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = [], ?string $folderDepth = "1"): ResponseInterface {
$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','d:lockdiscovery','d:activelock'];
$properties = [
'oc:id',
'oc:fileid',
'oc:spaceid',
'oc:file-parent',
'oc:shareid',
'oc:name',
'd:displayname',
'd:getetag',
'oc:permissions',
'd:resourcetype',
'oc:size',
'd:getlastmodified',
'oc:tags',
'oc:favorite',
'oc:share-types',
'oc:privatelink',
'd:getcontenttype',
'd:lockdiscovery',
'd:activelock'
];
return WebDavHelper::propfind(
$this->featureContext->getBaseUrl(),
$this->featureContext->getActualUsername($user),
@@ -3662,10 +3703,10 @@ class SpacesContext implements Context {
$resource,
$properties,
$this->featureContext->getStepLineRef(),
"0",
$folderDepth,
"files",
WebDavHelper::DAV_VERSION_SPACES,
"",
null,
$headers
);
}
@@ -3718,50 +3759,62 @@ class SpacesContext implements Context {
$xmlRes = $this->featureContext->getResponseXml();
foreach ($table->getHash() as $row) {
$findItem = $row['key'];
$xmlResponses = $xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem");
Assert::assertNotEmpty(
$xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem"),
$xmlResponses,
'The xml response "' . $xmlRes->asXML() . '" did not contain "<' . $findItem . '>" element'
);
$responseValue = $xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem")[0]->__toString();
$responseValues = [];
foreach ($xmlResponses as $xmlResponse) {
$responseValues[] = $xmlResponse[0]->__toString();
}
$value = str_replace('UUIDof:', '', $row['value']);
switch ($findItem) {
case "oc:fileid":
$resourceType = $xmlRes->xpath("//d:response/d:propstat/d:prop/d:getcontenttype")[0]->__toString();
if ($method === 'PROPFIND') {
if (!$resourceType) {
Assert::assertEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response');
} else {
Assert::assertEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
Assert::assertContainsEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response');
}
} else {
if ($resourceType === 'httpd/unix-directory') {
Assert::assertEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response');
} else {
Assert::assertEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
Assert::assertContainsEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong fileId in the response');
}
}
break;
case "oc:file-parent":
Assert::assertEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong file-parentId in the response');
Assert::assertContainsEquals($this->getResourceId($user, $spaceNameOrMountPoint, $value), $responseValues, 'wrong file-parentId in the response');
break;
case "oc:privatelink":
Assert::assertEquals($this->getPrivateLink($user, $spaceNameOrMountPoint), $responseValue, 'cannot find private link for space or resource in the response');
Assert::assertContainsEquals($this->getPrivateLink($user, $spaceNameOrMountPoint), $responseValues, 'cannot find private link for space or resource in the response');
break;
case "oc:tags":
// The value should be a comma-separated string of tag names.
// We do not care what order they happen to be in, so compare as sorted lists.
$expectedTags = \explode(",", $value);
$expectedTags = \sort($expectedTags);
$actualTags = \explode(",", $responseValue);
$actualTags = \sort($actualTags);
Assert::assertEquals($expectedTags, $actualTags, "wrong $findItem in the response");
\sort($expectedTags);
$expectedTags = \implode(",", $expectedTags);
$actualTags = [];
foreach ($responseValues as $responseValue) {
$responseValue = \explode(",", $responseValue);
\sort($responseValue);
$responseValue = \implode(",", $responseValue);
$actualTags[] = $responseValue;
}
Assert::assertContainsEquals($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");
Assert::assertContainsEquals($value, $responseValues, "wrong $findItem in the response");
} else {
// some time may be required between a lock and propfind request.
$responseValue = explode('-', $responseValue);
$responseValue = explode('-', $responseValues[0]);
$responseValue = \intval($responseValue[1]);
$value = explode('-', $value);
$value = \intval($value[1]);
@@ -3769,7 +3822,7 @@ class SpacesContext implements Context {
}
break;
default:
Assert::assertEquals($value, $responseValue, "wrong $findItem in the response");
Assert::assertContainsEquals($value, $responseValues, "wrong $findItem in the response");
break;
}
}
@@ -914,7 +914,7 @@ class WebDavLockingContext implements Context {
* @throws GuzzleException
*/
public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) {
$response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file);
$response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0');
$this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response);
$responseXml = $this->featureContext->getResponseXml($response);
$xmlPart = $responseXml->xpath("//d:response//d:lockdiscovery/d:activelock");