mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 21:00:30 -06:00
add tests change space
This commit is contained in:
36
tests/acceptance/features/apiSpaces/changeSpaces.feature
Normal file
36
tests/acceptance/features/apiSpaces/changeSpaces.feature
Normal file
@@ -0,0 +1,36 @@
|
||||
@api @skipOnOcV10
|
||||
Feature: Change data of space
|
||||
As a user
|
||||
I want to be able to change the data of the created space(increase the quota, change name, etc.)
|
||||
|
||||
Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production
|
||||
See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839
|
||||
|
||||
Background:
|
||||
Given user "Alice" has been created with default attributes and without skeleton files
|
||||
And the administrator gives "Alice" the role "Admin" using the settings api
|
||||
|
||||
Scenario: Alice changes a name of the space via the Graph api, she expects a 204 code and checks that the space name has changed
|
||||
When user "Alice" creates a space "Project Jupiter" of type "project" with quota "20" using the GraphApi
|
||||
And user "Alice" lists all available spaces via the GraphApi
|
||||
And user "Alice" changes the name of the "Project Jupiter" space to "Project Death Star"
|
||||
Then the HTTP status code should be "204"
|
||||
When user "Alice" lists all available spaces via the GraphApi
|
||||
Then the json responded should contain a space "Project Death Star" with these key and value pairs:
|
||||
| key | value |
|
||||
| driveType | project |
|
||||
| name | Project Death Star |
|
||||
| quota@@@total | 20 |
|
||||
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
|
||||
|
||||
Scenario: Alice increases quota of the space via the Graph api, she expects a 204 code and checks that the quota has changed
|
||||
When user "Alice" creates a space "Project Earth" of type "project" with quota "20" using the GraphApi
|
||||
And user "Alice" lists all available spaces via the GraphApi
|
||||
And user "Alice" changes the quota of the "Project Earth" space to "100"
|
||||
Then the HTTP status code should be "204"
|
||||
When user "Alice" lists all available spaces via the GraphApi
|
||||
Then the json responded should contain a space "Project Earth" with these key and value pairs:
|
||||
| key | value |
|
||||
| name | Project Earth |
|
||||
| quota@@@total | 100 |
|
||||
|
||||
@@ -874,4 +874,104 @@ class SpacesContext implements Context {
|
||||
|
||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, $method, $user, $password, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" changes the name of the "([^"]*)" space to "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
* @param string $newName
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateSpaceName(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $newName
|
||||
): void {
|
||||
$space = $this->getSpaceByName($spaceName);
|
||||
$spaceId = $space["id"];
|
||||
|
||||
$bodyData = ["Name" => $newName];
|
||||
$body = json_encode($bodyData, JSON_THROW_ON_ERROR);
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendUpdateSpaceRequest(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$body,
|
||||
$spaceId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" changes the quota of the "([^"]*)" space to "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
* @param int $newQuota
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateSpaceQuota(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
int $newQuota
|
||||
): void {
|
||||
$space = $this->getSpaceByName($spaceName);
|
||||
$spaceId = $space["id"];
|
||||
|
||||
$bodyData = ["quota" => ["total" => $newQuota]];
|
||||
$body = json_encode($bodyData, JSON_THROW_ON_ERROR);
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendUpdateSpaceRequest(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$body,
|
||||
$spaceId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Graph Update Space Request
|
||||
*
|
||||
* @param string $baseUrl
|
||||
* @param string $user
|
||||
* @param string $password
|
||||
* @param mixed $body
|
||||
* @param string $spaceId
|
||||
* @param string $xRequestId
|
||||
* @param array $headers
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function sendUpdateSpaceRequest(
|
||||
string $baseUrl,
|
||||
string $user,
|
||||
string $password,
|
||||
$body,
|
||||
string $spaceId,
|
||||
string $xRequestId = '',
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$fullUrl = $baseUrl;
|
||||
if (!str_ends_with($fullUrl, '/')) {
|
||||
$fullUrl .= '/';
|
||||
}
|
||||
$fullUrl .= "graph/v1.0/Drive($spaceId)";
|
||||
$method = 'PATCH';
|
||||
|
||||
return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, $method, $user, $password, $headers, $body);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user