Merge pull request #5305 from owncloud/backport-refactor-response-should-contain
[tests-only][full-ci]Backport response should contain refactor to `master` branch
This commit is contained in:
@@ -15,7 +15,7 @@ Feature: Propfind test
|
|||||||
Given user "Alice" has uploaded a file inside space "new-space" with content "some content" to "testfile.txt"
|
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" using the WebDAV API
|
||||||
Then the HTTP status code should be "207"
|
Then the HTTP status code should be "207"
|
||||||
And for user "Alice" the "PROPFIND" response should contain a space "new-space" with these key and value pairs:
|
And the "PROPFIND" response should contain a space "new-space" with these key and value pairs:
|
||||||
| key | value |
|
| key | value |
|
||||||
| oc:fileid | UUIDof:new-space |
|
| oc:fileid | UUIDof:new-space |
|
||||||
| oc:name | new-space |
|
| oc:name | new-space |
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Feature: Report test
|
|||||||
And user "Brian" has accepted share "/folderMain" offered by user "Alice"
|
And user "Brian" has accepted share "/folderMain" offered by user "Alice"
|
||||||
When user "Brian" searches for "SubFolder1" using the WebDAV API
|
When user "Brian" searches for "SubFolder1" using the WebDAV API
|
||||||
Then the HTTP status code should be "207"
|
Then the HTTP status code should be "207"
|
||||||
And for user "Brian" the "REPORT" response should contain a mountpoint "folderMain" with these key and value pairs:
|
And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs:
|
||||||
| key | value |
|
| key | value |
|
||||||
| oc:fileid | UUIDof:SubFolder1 |
|
| oc:fileid | UUIDof:SubFolder1 |
|
||||||
| oc:file-parent | UUIDof:folderMain |
|
| oc:file-parent | UUIDof:folderMain |
|
||||||
@@ -39,7 +39,7 @@ Feature: Report test
|
|||||||
And user "Brian" has accepted share "/folderMain" offered by user "Alice"
|
And user "Brian" has accepted share "/folderMain" offered by user "Alice"
|
||||||
When user "Brian" searches for "insideTheFolder.txt" using the WebDAV API
|
When user "Brian" searches for "insideTheFolder.txt" using the WebDAV API
|
||||||
Then the HTTP status code should be "207"
|
Then the HTTP status code should be "207"
|
||||||
And for user "Brian" the "REPORT" response should contain a mountpoint "folderMain" with these key and value pairs:
|
And the "REPORT" response to user "Brian" should contain a mountpoint "folderMain" with these key and value pairs:
|
||||||
| key | value |
|
| key | value |
|
||||||
| oc:fileid | UUIDof:SubFolder1/subFOLDER2/insideTheFolder.txt |
|
| oc:fileid | UUIDof:SubFolder1/subFOLDER2/insideTheFolder.txt |
|
||||||
| oc:file-parent | UUIDof:SubFolder1/subFOLDER2 |
|
| oc:file-parent | UUIDof:SubFolder1/subFOLDER2 |
|
||||||
|
|||||||
@@ -1505,6 +1505,7 @@ class SpacesContext implements Context {
|
|||||||
$body
|
$body
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$this->setSpaceCreator($spaceName, $user);
|
||||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||||
201,
|
201,
|
||||||
"Expected response status code should be 201 (Created)"
|
"Expected response status code should be 201 (Created)"
|
||||||
@@ -2965,9 +2966,8 @@ class SpacesContext implements Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then /^for user "([^"]*)" the "([^"]*)" response should contain a (?:space|mountpoint) "([^"]*)" with these key and value pairs:$/
|
* @Then /^the "([^"]*)" response should contain a space "([^"]*)" with these key and value pairs:$/
|
||||||
*
|
*
|
||||||
* @param string $user
|
|
||||||
* @param string $method # method should be either PROPFIND or REPORT
|
* @param string $method # method should be either PROPFIND or REPORT
|
||||||
* @param string $space
|
* @param string $space
|
||||||
* @param TableNode $table
|
* @param TableNode $table
|
||||||
@@ -2976,8 +2976,39 @@ class SpacesContext implements Context {
|
|||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
* @throws JsonException
|
* @throws JsonException
|
||||||
*/
|
*/
|
||||||
public function theResponseShouldContain(string $user, string $method, string $space, TableNode $table): void {
|
public function theResponseShouldContainSpace(string $method, string $space, TableNode $table): void {
|
||||||
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
||||||
|
$this->theResponseShouldContain($method, $this->getSpaceCreator($space), $space, $table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^the "([^"]*)" response to user "([^"]*)" should contain a mountpoint "([^"]*)" with these key and value pairs:$/
|
||||||
|
*
|
||||||
|
* @param string $method # method should be either PROPFIND or REPORT
|
||||||
|
* @param string $user
|
||||||
|
* @param string $mountPoint
|
||||||
|
* @param TableNode $table
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
* @throws JsonException
|
||||||
|
*/
|
||||||
|
public function theResponseShouldContainMountPoint(string $method, string $user, string $mountPoint, TableNode $table): void {
|
||||||
|
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
||||||
|
$this->theResponseShouldContain($method, $user, $mountPoint, $table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $method # method should be either PROPFIND or REPORT
|
||||||
|
* @param string $user
|
||||||
|
* @param string $spaceNameOrMountPoint # an entity inside a space, or the space name itself
|
||||||
|
* @param TableNode $table
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
* @throws JsonException
|
||||||
|
*/
|
||||||
|
public function theResponseShouldContain(string $method, string $user, string $spaceNameOrMountPoint, TableNode $table): void {
|
||||||
$xmlRes = $this->featureContext->getResponseXml();
|
$xmlRes = $this->featureContext->getResponseXml();
|
||||||
foreach ($table->getHash() as $row) {
|
foreach ($table->getHash() as $row) {
|
||||||
$findItem = $row['key'];
|
$findItem = $row['key'];
|
||||||
@@ -2989,23 +3020,23 @@ class SpacesContext implements Context {
|
|||||||
$resourceType = $xmlRes->xpath("//d:response/d:propstat/d:prop/d:getcontenttype")[0]->__toString();
|
$resourceType = $xmlRes->xpath("//d:response/d:propstat/d:prop/d:getcontenttype")[0]->__toString();
|
||||||
if ($method === 'PROPFIND') {
|
if ($method === 'PROPFIND') {
|
||||||
if (!$resourceType) {
|
if (!$resourceType) {
|
||||||
Assert::assertEquals($this->getFolderId($user, $space, $value), $responseValue, 'wrong fileId in the response');
|
Assert::assertEquals($this->getFolderId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
|
||||||
} else {
|
} else {
|
||||||
Assert::assertEquals($this->getFileId($user, $space, $value), $responseValue, 'wrong fileId in the response');
|
Assert::assertEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($resourceType === 'httpd/unix-directory') {
|
if ($resourceType === 'httpd/unix-directory') {
|
||||||
Assert::assertEquals($this->getFolderId($user, $space, $value), $responseValue, 'wrong fileId in the response');
|
Assert::assertEquals($this->getFolderId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
|
||||||
} else {
|
} else {
|
||||||
Assert::assertEquals($this->getFileId($user, $space, $value), $responseValue, 'wrong fileId in the response');
|
Assert::assertEquals($this->getFileId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong fileId in the response');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "oc:file-parent":
|
case "oc:file-parent":
|
||||||
Assert::assertEquals($this->getFolderId($user, $space, $value), $responseValue, 'wrong file-parentId in the response');
|
Assert::assertEquals($this->getFolderId($user, $spaceNameOrMountPoint, $value), $responseValue, 'wrong file-parentId in the response');
|
||||||
break;
|
break;
|
||||||
case "oc:privatelink":
|
case "oc:privatelink":
|
||||||
Assert::assertEquals($this->getPrivateLink($user, $space), $responseValue, 'cannot find private link for space or resource in the response');
|
Assert::assertEquals($this->getPrivateLink($user, $spaceNameOrMountPoint), $responseValue, 'cannot find private link for space or resource in the response');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Assert::assertEquals($value, $responseValue, "wrong $findItem in the response");
|
Assert::assertEquals($value, $responseValue, "wrong $findItem in the response");
|
||||||
|
|||||||
Reference in New Issue
Block a user