mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 21:00:30 -06:00
[tests-only] [full-ci] removing the setresponse in given/then step in webdav context (#7403)
* refactoring the given steps in the webdav context * refactored remaining given/when/then steps * return file id * trim trailing from the folder path * add missing when step and make other minor corrections * set responseXml and correct status code check * correct the naming of steps and helper functions
This commit is contained in:
@@ -472,7 +472,7 @@ Feature: antivirus
|
||||
And user "Alice" has created a space "new-space" with the default quota using the GraphApi
|
||||
And user "Alice" has created a folder ".space" in space "new-space"
|
||||
And user "Alice" has uploaded a file inside space "new-space" with content "Here you can add a description for this Space." to ".space/readme.md"
|
||||
And user "Alice" has uploaded a file inside space "new-space" with content "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*" to ".space/readme.md"
|
||||
When user "Alice" uploads a file inside space "new-space" with content "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*" to ".space/readme.md" using the WebDAV API
|
||||
Then the HTTP status code should be "204"
|
||||
And user "Alice" should get a notification with subject "Virus found" and message:
|
||||
| message |
|
||||
|
||||
@@ -3189,7 +3189,7 @@ class FeatureContext extends BehatVariablesContext {
|
||||
*/
|
||||
public function deleteAllResourceCreatedByAdmin(): void {
|
||||
foreach ($this->adminResources as $resource) {
|
||||
$this->userDeletesFile("admin", $resource);
|
||||
$this->deleteFile("admin", $resource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2525,8 +2525,8 @@ trait Sharing {
|
||||
*/
|
||||
public function userDownloadsFailWithMessage(string $fileName, string $user, PyStringNode $errorMessage):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->downloadFileAsUserUsingPassword($user, $fileName);
|
||||
$receivedErrorMessage = $this->getResponseXml(null, __METHOD__)->xpath('//s:message');
|
||||
$response = $this->downloadFileAsUserUsingPassword($user, $fileName);
|
||||
$receivedErrorMessage = $this->getResponseXml($response, __METHOD__)->xpath('//s:message');
|
||||
Assert::assertEquals(
|
||||
$errorMessage,
|
||||
(string) $receivedErrorMessage[0],
|
||||
|
||||
@@ -1083,6 +1083,7 @@ class SpacesContext implements Context {
|
||||
string $folder,
|
||||
string $spaceName
|
||||
): void {
|
||||
$folder = \trim($folder, '/');
|
||||
$exploded = explode('/', $folder);
|
||||
$path = '';
|
||||
for ($i = 0; $i < \count($exploded); $i++) {
|
||||
@@ -1121,19 +1122,48 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function theUserHasCreateAFolderUsingTheGraphApi(
|
||||
public function userHasCreatedAFolderInSpace(
|
||||
string $user,
|
||||
string $folder,
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->theUserCreatesAFolderUsingTheGraphApi($user, $folder, $spaceName);
|
||||
|
||||
$folder = \trim($folder, '/');
|
||||
$paths = explode('/', $folder);
|
||||
$folderPath = '';
|
||||
foreach ($paths as $path) {
|
||||
$folderPath .= "$path/";
|
||||
$response = $this->createFolderInSpace($user, $folderPath, $spaceName);
|
||||
}
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
201,
|
||||
"Expected response status code should be 201"
|
||||
"Expected response status code should be 201",
|
||||
$response
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param string $folder
|
||||
* @param string $spaceName
|
||||
* @param string $ownerUser
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function createFolderInSpace(
|
||||
string $user,
|
||||
string $folder,
|
||||
string $spaceName,
|
||||
string $ownerUser = ''
|
||||
): ResponseInterface {
|
||||
if ($ownerUser === '') {
|
||||
$ownerUser = $user;
|
||||
}
|
||||
$this->setSpaceIDByName($ownerUser, $spaceName);
|
||||
return $this->featureContext->createFolder($user, $folder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" creates a folder "([^"]*)" in space "([^"]*)" owned by the user "([^"]*)" using the WebDav Api$/
|
||||
*
|
||||
@@ -1152,11 +1182,7 @@ class SpacesContext implements Context {
|
||||
string $spaceName,
|
||||
string $ownerUser = ''
|
||||
): void {
|
||||
if ($ownerUser === '') {
|
||||
$ownerUser = $user;
|
||||
}
|
||||
$this->setSpaceIDByName($ownerUser, $spaceName);
|
||||
$response = $this->featureContext->createFolder($user, $folder);
|
||||
$response = $this->createFolderInSpace($user, $folder, $spaceName, $ownerUser);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
@@ -1168,7 +1194,7 @@ class SpacesContext implements Context {
|
||||
* @param string $content
|
||||
* @param string $destination
|
||||
*
|
||||
* @return string[]
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -1177,9 +1203,10 @@ class SpacesContext implements Context {
|
||||
string $spaceName,
|
||||
string $content,
|
||||
string $destination
|
||||
): array {
|
||||
): void {
|
||||
$this->setSpaceIDByName($user, $spaceName);
|
||||
return $this->featureContext->uploadFileWithContent($user, $content, $destination);
|
||||
$response = $this->featureContext->uploadFileWithContent($user, $content, $destination);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1201,7 +1228,8 @@ class SpacesContext implements Context {
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->setSpaceIDByName($user, $spaceName);
|
||||
$this->featureContext->userUploadsAFileTo($user, $source, $destination);
|
||||
$response = $this->featureContext->uploadFile($user, $source, $destination);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1225,7 +1253,8 @@ class SpacesContext implements Context {
|
||||
string $destination
|
||||
): void {
|
||||
$this->setSpaceIDByName($ownerUser, $spaceName);
|
||||
$this->featureContext->uploadFileWithContent($user, $content, $destination);
|
||||
$response = $this->featureContext->uploadFileWithContent($user, $content, $destination);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1706,19 +1735,19 @@ class SpacesContext implements Context {
|
||||
string $spaceName
|
||||
):void {
|
||||
$this->setSpaceIDByName($user, $spaceName);
|
||||
$this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user));
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user));
|
||||
Assert::assertGreaterThanOrEqual(
|
||||
400,
|
||||
$this->featureContext->getResponse()->getStatusCode(),
|
||||
$response->getStatusCode(),
|
||||
__METHOD__
|
||||
. ' download must fail'
|
||||
);
|
||||
Assert::assertLessThanOrEqual(
|
||||
499,
|
||||
$this->featureContext->getResponse()->getStatusCode(),
|
||||
$response->getStatusCode(),
|
||||
__METHOD__
|
||||
. ' 4xx error expected but got status code "'
|
||||
. $this->featureContext->getResponse()->getStatusCode() . '"'
|
||||
. $response->getStatusCode() . '"'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1830,7 +1859,7 @@ class SpacesContext implements Context {
|
||||
* @param string $fileContent
|
||||
* @param string $destination
|
||||
*
|
||||
* @return string[]
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasUploadedFile(
|
||||
@@ -1840,9 +1869,10 @@ class SpacesContext implements Context {
|
||||
string $destination
|
||||
): array {
|
||||
$this->theUserListsAllHisAvailableSpacesUsingTheGraphApi($user);
|
||||
$fileId = $this->theUserUploadsAFileToSpace($user, $spaceName, $fileContent, $destination);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBeOr(201, 204);
|
||||
return $fileId;
|
||||
$this->setSpaceIDByName($user, $spaceName);
|
||||
$response = $this->featureContext->uploadFileWithContent($user, $fileContent, $destination, true);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(['201', '204'], "", $response);
|
||||
return $response->getHeader('oc-fileid');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2646,7 +2676,8 @@ class SpacesContext implements Context {
|
||||
string $spaceName
|
||||
): void {
|
||||
$this->setSpaceIDByName($user, $spaceName);
|
||||
$this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user));
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user));
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -889,11 +889,11 @@ class TrashbinContext implements Context {
|
||||
):void {
|
||||
$isInTrash = $this->isInTrash($user, $fileName);
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$this->featureContext->downloadFileAsUserUsingPassword($user, $fileName);
|
||||
$response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName);
|
||||
if ($isInTrash) {
|
||||
$this->featureContext->downloadedContentShouldBe($content);
|
||||
$this->featureContext->checkDownloadedContentMatches($content, '', $response);
|
||||
} else {
|
||||
$this->featureContext->downloadedContentShouldBe($alternativeContent);
|
||||
$this->featureContext->checkDownloadedContentMatches($alternativeContent, '', $response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -130,7 +130,6 @@ Feature: multi-link sharing
|
||||
| permissions | read |
|
||||
| name | sharedlink2 |
|
||||
And user "Alice" has deleted file "/textfile0.txt"
|
||||
And the HTTP status code should be "204"
|
||||
When user "Alice" uploads file "filesForUpload/textfile.txt" to "/textfile0.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
And as user "Alice" the file "/textfile0.txt" should not have any shares
|
||||
|
||||
@@ -310,7 +310,7 @@ Feature: upload file
|
||||
Given using <dav-path-version> DAV path
|
||||
And user "Alice" has uploaded file with content "first time upload content" to "file.txt"
|
||||
When user "Alice" uploads a file with content "Overwrite file" and mtime "Thu, 08 Aug 2019 04:18:13 GMT" to "file.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
Then the HTTP status code should be "204"
|
||||
And as "Alice" file "file.txt" should exist
|
||||
And as "Alice" the mtime of the file "file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT"
|
||||
And the content of file "file.txt" for user "Alice" should be "Overwrite file"
|
||||
|
||||
Reference in New Issue
Block a user