[test-only] ApiTest.check all response items (#4886)

* check response

* php-style fix
This commit is contained in:
Viktor Scharf
2022-10-25 13:48:01 +02:00
committed by GitHub
parent e9219e4103
commit 51c16e41be
5 changed files with 100 additions and 36 deletions

View File

@@ -348,6 +348,7 @@ def testPipelines(ctx):
localApiTests(ctx, "ocis", "apiAccountsHashDifficulty"),
localApiTests(ctx, "ocis", "apiSpaces"),
localApiTests(ctx, "ocis", "apiSpacesShares"),
localApiTests(ctx, "ocis", "apiContract"),
localApiTests(ctx, "ocis", "apiArchiver"),
localApiTests(ctx, "ocis", "apiGraph"),
]

View File

@@ -70,6 +70,26 @@ default:
- WebDavPropertiesContext:
- TUSContext:
- SpacesTUSContext:
apiContract:
paths:
- '%paths.base%/../features/apiContract'
context: *common_ldap_suite_context
contexts:
- SpacesContext:
- OccContext:
- FeatureContext: *common_feature_context_params
- CapabilitiesContext:
- ChecksumContext:
- FavoritesContext:
- FilesVersionsContext:
- OCSContext:
- PublicWebDavContext:
- SearchContext:
- TrashbinContext:
- WebDavPropertiesContext:
- TUSContext:
- SpacesTUSContext:
apiArchiver:
paths:

View File

@@ -0,0 +1,50 @@
@api @skipOnOcV10
Feature: Report test
check that the REPORT response contains all the relevant value
Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production
See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839
Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
And using spaces DAV path
And the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "find data" with the default quota using the GraphApi
And user "Alice" has created a folder "folderMain/SubFolder1/subFOLDER2" in space "find data"
And user "Alice" has uploaded a file inside space "find data" with content "some content" to "folderMain/SubFolder1/subFOLDER2/insideTheFolder.txt"
And using new DAV path
Scenario: check the response of the found folder
Given user "Alice" shares the following entity "folderMain" inside of space "find data" with user "Brian" with role "viewer"
And user "Brian" has accepted share "/folderMain" offered by user "Alice"
When user "Brian" searches for "SubFolder1" using the WebDAV API
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:
| key | value |
| oc:fileid | UUIDof:SubFolder1 |
| oc:file-parent | UUIDof:folderMain |
| oc:shareroot | /folderMain |
| oc:name | SubFolder1 |
| d:getcontenttype | httpd/unix-directory |
| oc:permissions | SR |
| oc:size | 12 |
Scenario: check the response of the found file
Given user "Alice" shares the following entity "folderMain" inside of space "find data" with user "Brian" with role "editor"
And user "Brian" has accepted share "/folderMain" offered by user "Alice"
When user "Brian" searches for "insideTheFolder.txt" using the WebDAV API
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:
| key | value |
| oc:fileid | UUIDof:SubFolder1/subFOLDER2/insideTheFolder.txt |
| oc:file-parent | UUIDof:SubFolder1/subFOLDER2 |
| oc:shareroot | /folderMain |
| oc:name | insideTheFolder.txt |
| d:getcontenttype | text/plain |
| oc:permissions | SRDNVW |
| d:getcontentlength | 12 |

View File

@@ -97,32 +97,3 @@ Feature: Search
Then the HTTP status code should be "207"
And the search result should contain "1" entries
And for user "Alice" the search result should contain space "find data"
Scenario Outline: search result for project space contains resource parentID
When user "Alice" searches for "<searchObject>" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "1" entries
And the search result of user "Alice" should contain these entries:
| /<searchObject> |
And for user "Alice" the response should contains the parent "<parentFolder>" from space "find data"
Examples:
| searchObject | parentFolder |
| SubFolder1 | folderMain |
| insideTheFolder.txt | folderMain/SubFolder1/subFOLDER2 |
| folderMain | find data |
Scenario Outline: search result for Shares contains resource parentID
Given user "Alice" shares the following entity "folderMain" inside of space "find data" with user "Brian" with role "viewer"
And user "Brian" has accepted share "/folderMain" offered by user "Alice"
When user "Brian" searches for "<searchObject>" using the WebDAV API
Then the HTTP status code should be "207"
And the search result should contain "1" entries
And the search result of user "Brian" should contain these entries:
| /<searchObject> |
And for user "Brian" the response should contains the parent "<parentFolder>" from mountpoint "folderMain"
Examples:
| searchObject | parentFolder |
| insideTheFolder.txt | SubFolder1/subFOLDER2 |
| SubFolder1 | folderMain |

View File

@@ -2995,19 +2995,41 @@ class SpacesContext implements Context {
}
/**
* @Then /^for user "([^"]*)" the response should contains the parent "([^"]*)" from (?:space|mountpoint) "([^"]*)"$/
* @Then /^for user "([^"]*)" the REPORT response should contain a (?:space|mountpoint) "([^"]*)" with these key and value pairs:$/
*
* @param string $user
* @param string $parent
* @param string $space
* @param TableNode $table
*
* @return void
* @throws GuzzleException
*/
public function responseShouldContainParent(string $user, string $parent, string $space): void {
// get a response after a Report request (called in the core)
$responseArray = json_decode(json_encode($this->featureContext->getResponseXml()->xpath("//d:response/d:propstat/d:prop/oc:file-parent")), true, 512, JSON_THROW_ON_ERROR);
Assert::assertNotEmpty($responseArray, "search result is empty");
Assert::assertEquals($this->getFolderId($user, $space, $parent), $responseArray[0][0], 'wrong file-parentId');
public function reportResponseShouldContain(string $user, string $space, TableNode $table): void {
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
$xmlRes = $this->featureContext->getResponseXml();
$resourceType = $xmlRes->xpath("//d:response/d:propstat/d:prop/d:getcontenttype")[0]->__toString();
foreach ($table->getHash() as $row) {
$findItem = $row['key'];
$responseValue = $xmlRes->xpath("//d:response/d:propstat/d:prop/$findItem")[0]->__toString();
Assert::assertNotEmpty($responseValue, "response doesn't contain $findItem or empty");
$value = str_replace('UUIDof:', '', $row['value']);
switch ($findItem) {
case "oc:fileid":
if ($resourceType === 'httpd/unix-directory') {
Assert::assertEquals($this->getFolderId($user, $space, $value), $responseValue, 'wrong fileId in the response');
} else {
Assert::assertEquals($this->getFileId($user, $space, $value), $responseValue, 'wrong fileId in the response');
}
break;
case "oc:file-parent":
Assert::assertEquals($this->getFolderId($user, $space, $value), $responseValue, 'wrong file-parentId in the response');
break;
default:
Assert::assertEquals($value, $responseValue, "wrong $findItem in the response");
break;
}
}
}
}