Skip to content

Commit

Permalink
Merge pull request #5479 from roshanlc/tests-for-relative-quota-amount
Browse files Browse the repository at this point in the history
[tests-only][full-ci] Test scenarios for relative quota amount of personal space
  • Loading branch information
individual-it authored Feb 7, 2023
2 parents f627499 + 15c152b commit fbe05dc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
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"
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
*
* @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)) {
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"
);
}
}
}

0 comments on commit fbe05dc

Please sign in to comment.