forward-port of relative quota amount of personal space tests from stable-2.0 (#5524)

This commit is contained in:
Roshan Lamichhane
2023-02-07 16:55:26 +05:45
committed by GitHub
parent a2798f26be
commit 19e1d63dab
3 changed files with 58 additions and 0 deletions

View File

@@ -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"
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 |

View File

@@ -940,6 +940,24 @@ class OCSContext implements Context {
);
}
/**
* Parses the xml answer to return data items from ocs response
*
* @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.

View File

@@ -3226,4 +3226,27 @@ class SpacesContext implements Context {
)
);
}
/**
* @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)) {
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"
);
}
}
}