Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] Test scenarios for relative quota amount of personal space #5479

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/acceptance/features/apiSpaces/quota.feature
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,20 @@ Feature: State of the quota
And user "Alice" has uploaded a file inside space "Project Delta" with content "7 bytes" to "test.txt"
When user "Alice" uploads a file inside space "Project Delta" with content "00011 bytes" to "test.txt" using the WebDAV API
Then the HTTP status code should be "507"


Scenario Outline: Check the relative amount of quota of personal space
Given user "Admin" has changed the quota of the personal space of "Alice Hansen" space to "10000"
And user "Alice" has uploaded file "<file_upload>" to "/demo.txt"
When the user "Alice" requests these endpoints with "GET" with basic auth
| endpoint |
| <end_point> |
Then the HTTP status code should be "200"
roshanlc marked this conversation as resolved.
Show resolved Hide resolved
And the OCS status code should be "<ocs_code>"
And the relative quota amount should be "<quota_relative>"
Examples:
| file_upload | end_point | ocs_code | quota_relative |
| /filesForUpload/lorem.txt | /ocs/v1.php/cloud/users/%username% | 100 | 6.99 |
| /filesForUpload/lorem-big.txt | /ocs/v1.php/cloud/users/%username% | 100 | 91.17 |
| /filesForUpload/lorem.txt | /ocs/v2.php/cloud/users/%username% | 200 | 6.99 |
| /filesForUpload/lorem-big.txt | /ocs/v2.php/cloud/users/%username% | 200 | 91.17 |
18 changes: 18 additions & 0 deletions tests/acceptance/features/bootstrap/OCSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,24 @@ public function getOCSResponseStatusCode(ResponseInterface $response):string {
);
}

/**
* Parses the xml answer to return data items from ocs response
SagarGi marked this conversation as resolved.
Show resolved Hide resolved
*
* @param ResponseInterface $response
*
* @return SimpleXMLElement
* @throws Exception
*/
public function getOCSResponseData(ResponseInterface $response): SimpleXMLElement {
$responseXml = $this->featureContext->getResponseXml($response, __METHOD__);
if (isset($responseXml->data)) {
return $responseXml->data;
}
throw new Exception(
"No OCS data items found in responseXml"
);
}

/**
* Parses the xml answer to get ocs response message which doesn't match with
* http one in v1 of the api.
Expand Down
23 changes: 23 additions & 0 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3134,4 +3134,27 @@ public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $res
)
);
}

/**
* @Then the relative quota amount should be :quota_amount
*
* @param string $quotaAmount
*
* @return void
* @throws Exception
*/
public function theRelativeQuotaAmountShouldBe(string $quotaAmount): void {
$data = $this->ocsContext->getOCSResponseData($this->featureContext->getResponse());
if (isset($data->quota, $data->quota->relative)) {
saw-jan marked this conversation as resolved.
Show resolved Hide resolved
Assert::assertEquals(
$data->quota->relative,
$quotaAmount,
"Expected relative quota amount to be $quotaAmount but found to be $data->quota->relative"
);
} else {
throw new Exception(
"No relative quota amount found in responseXml"
);
}
}
}