[tests-only][full-ci]Adds tests for sending PATCH request to other user's space (#5320)

* Adds tests for sending PATCH request to other user's space

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* address reviews

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
This commit is contained in:
Swikriti Tripathi authored and GitHub committed 2023-01-04 12:08:01 +01:00
1 parent ef99674ad7
commit 13a7065f3a
3 files changed
+41 -2

No files matched your search

+1 -1
View File
@@ -82,7 +82,7 @@ class GraphHelper {
*
* @return string
*/
private static function getFullUrl(string $baseUrl, string $path): string {
public static function getFullUrl(string $baseUrl, string $path): string {
$fullUrl = $baseUrl;
if (\substr($fullUrl, -1) !== '/') {
$fullUrl .= '/';
@@ -224,7 +224,7 @@ Feature: Change data of space
| 0 | between "201" and "204" |
| -1 | between "201" and "204" |
Scenario: user sends invalid space uuid via the Graph API
When user "Admin" tries to change the name of the "non-existing" space to "new name"
Then the HTTP status code should be "404"
@@ -232,3 +232,13 @@ Feature: Change data of space
Then the HTTP status code should be "404"
When user "Alice" tries to change the description of the "non-existing" space to "new description"
Then the HTTP status code should be "404"
Scenario: user sends PATCH request to other user's space that they don't have access to
Given these users have been created with default attributes and without skeleton files:
| username |
| Carol |
When user "Carol" sends PATCH request to the space "Personal" of user "Alice" with data "{}"
Then the HTTP status code should be "404"
When user "Carol" sends PATCH request to the space "Project Jupiter" of user "Alice" with data "{}"
Then the HTTP status code should be "404"
@@ -766,6 +766,35 @@ class SpacesContext implements Context {
);
}
/**
* @When /^user "([^"]*)" sends PATCH request to the space "([^"]*)" of user "([^"]*)" with data "([^"]*)"$/
*
* @param string $user
* @param string $spaceName
* @param string $owner
* @param string $data
*
* @return void
* @throws GuzzleException
*/
public function userSendsPatchRequestToTheSpaceOfUserWithData(string $user, string $spaceName, string $owner, string $data): void {
$space = $this->getSpaceByName($owner, $spaceName);
Assert::assertIsArray($space);
Assert::assertNotEmpty($spaceId = $space["id"]);
$url = GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'drives/' . $spaceId);
$this->featureContext->setResponse(
HttpRequestHelper::sendRequest(
$url,
"",
"PATCH",
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
null,
$data
)
);
}
/**
* @Then /^the (?:propfind|search) result of the space should (not|)\s?contain these (?:files|entries):$/
*