Merge pull request #4338 from owncloud/chageQuotaOfThePersonalSpace
[test-only]Api test. add tests for changing quota of the personal space
This commit is contained in:
@@ -38,3 +38,9 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
|||||||
- [apiSpaces/moveSpaces.feature:185](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/moveSpaces.feature#L185)
|
- [apiSpaces/moveSpaces.feature:185](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/moveSpaces.feature#L185)
|
||||||
- [apiSpaces/moveSpaces.feature:186](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/moveSpaces.feature#L186)
|
- [apiSpaces/moveSpaces.feature:186](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/moveSpaces.feature#L186)
|
||||||
- [apiSpaces/moveSpaces.feature:189](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/moveSpaces.feature#L189)
|
- [apiSpaces/moveSpaces.feature:189](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/moveSpaces.feature#L189)
|
||||||
|
|
||||||
|
### [Changing personal drive quota on another user as admin is not possible](https://github.com/owncloud/ocis/issues/4325)
|
||||||
|
- [apiSpaces/changeSpaces.feature:221](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changeSpaces.feature#L221)
|
||||||
|
- [apiSpaces/changeSpaces.feature:222](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changeSpaces.feature#L222)
|
||||||
|
- [apiSpaces/changeSpaces.feature:223](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changeSpaces.feature#L223)
|
||||||
|
- [apiSpaces/changeSpaces.feature:224](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/changeSpaces.feature#L224)
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ Feature: Change data of space
|
|||||||
When user "<user>" has uploaded a file inside space "Project Jupiter" with content "" to ".space/newSpaceImage.png"
|
When user "<user>" has uploaded a file inside space "Project Jupiter" with content "" to ".space/newSpaceImage.png"
|
||||||
And user "<user>" sets the file ".space/newSpaceImage.png" as a space image in a special section of the "Project Jupiter" space
|
And user "<user>" sets the file ".space/newSpaceImage.png" as a space image in a special section of the "Project Jupiter" space
|
||||||
Then the HTTP status code should be "200"
|
Then the HTTP status code should be "200"
|
||||||
And the user "<user>" should have a space called "Project Jupiter" owned by "Alice" with space image ".space/newSpaceImage.png" with these key and value pairs:
|
And the user "<user>" should have a space called "Project Jupiter" owned by "Alice" with space image ".space/newSpaceImage.png" with these key and value pairs:
|
||||||
| key | value |
|
| key | value |
|
||||||
| name | Project Jupiter |
|
| name | Project Jupiter |
|
||||||
| special@@@0@@@size | 0 |
|
| special@@@0@@@size | 0 |
|
||||||
@@ -195,4 +195,30 @@ Feature: Change data of space
|
|||||||
Examples:
|
Examples:
|
||||||
| user |
|
| user |
|
||||||
| Alice |
|
| Alice |
|
||||||
| Brian |
|
| Brian |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: An admin user set own quota of a personal space via the Graph API
|
||||||
|
When user "Admin" changes the quota of the "Admin" space to "<quotaValue>"
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
When user "Admin" uploads a file inside space "Admin" with content "file is more than 15 bytes" to "file.txt" using the WebDAV API
|
||||||
|
Then the HTTP status code should be <code>
|
||||||
|
Examples:
|
||||||
|
| quotaValue | code |
|
||||||
|
| 15 | "507" |
|
||||||
|
| 10000 | between "201" and "204" |
|
||||||
|
| 0 | between "201" and "204" |
|
||||||
|
| -1 | between "201" and "204" |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario Outline: An admin user set an user personal space quota of via the Graph API
|
||||||
|
When user "Admin" changes the quota of the "Brian Murphy" space to "<quotaValue>"
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
When user "Brian" uploads a file inside space "Brian Murphy" with content "file is more than 15 bytes" to "file.txt" using the WebDAV API
|
||||||
|
Then the HTTP status code should be <code>
|
||||||
|
Examples:
|
||||||
|
| quotaValue | code |
|
||||||
|
| 15 | "507" |
|
||||||
|
| 10000 | between "201" and "204" |
|
||||||
|
| 0 | between "201" and "204" |
|
||||||
|
| -1 | between "201" and "204" |
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ class SpacesContext implements Context {
|
|||||||
*/
|
*/
|
||||||
private $storedEtags = [];
|
private $storedEtags = [];
|
||||||
|
|
||||||
private $etagPropfindBody = '<?xml version="1.0"?>'
|
private $etagPropfindBody = '<?xml version="1.0"?>'
|
||||||
. '<d:propfind xmlns:d="DAV:" '
|
. '<d:propfind xmlns:d="DAV:" '
|
||||||
. 'xmlns:oc="http://owncloud.org/ns" '
|
. 'xmlns:oc="http://owncloud.org/ns" '
|
||||||
. 'xmlns:ocs="http://open-collaboration-services.org/ns">'
|
. 'xmlns:ocs="http://open-collaboration-services.org/ns">'
|
||||||
.'<d:prop><d:getetag/></d:prop></d:propfind>';
|
. '<d:prop><d:getetag/></d:prop></d:propfind>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $spaceName
|
* @param string $spaceName
|
||||||
@@ -246,7 +246,11 @@ class SpacesContext implements Context {
|
|||||||
if ($spaceName === "Personal") {
|
if ($spaceName === "Personal") {
|
||||||
$spaceName = $this->featureContext->getUserDisplayName($user);
|
$spaceName = $this->featureContext->getUserDisplayName($user);
|
||||||
}
|
}
|
||||||
$this->theUserListsAllHisAvailableSpacesUsingTheGraphApi($user);
|
if (strtolower($user) === 'admin') {
|
||||||
|
$this->theUserListsAllAvailableSpacesUsingTheGraphApi($user);
|
||||||
|
} else {
|
||||||
|
$this->theUserListsAllHisAvailableSpacesUsingTheGraphApi($user);
|
||||||
|
}
|
||||||
$spaces = $this->getAvailableSpaces();
|
$spaces = $this->getAvailableSpaces();
|
||||||
Assert::assertIsArray($spaces[$spaceName], "Space with name $spaceName for user $user not found");
|
Assert::assertIsArray($spaces[$spaceName], "Space with name $spaceName for user $user not found");
|
||||||
Assert::assertNotEmpty($spaces[$spaceName]["root"]["webDavUrl"], "WebDavUrl for space with name $spaceName for user $user not found");
|
Assert::assertNotEmpty($spaces[$spaceName]["root"]["webDavUrl"], "WebDavUrl for space with name $spaceName for user $user not found");
|
||||||
@@ -393,6 +397,51 @@ class SpacesContext implements Context {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @AfterScenario
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws Exception|GuzzleException
|
||||||
|
*/
|
||||||
|
public function cleanDataAfterTests(): void {
|
||||||
|
// TODO enable when admin can disable and delete spaces
|
||||||
|
// $this->deleteAllSpacesOfTheType('project');
|
||||||
|
// $this->deleteAllSpacesOfTheType('personal');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method first disables and then deletes spaces
|
||||||
|
*
|
||||||
|
* @param string $driveType
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws Exception|GuzzleException
|
||||||
|
*/
|
||||||
|
public function deleteAllSpacesOfTheType(string $driveType): void {
|
||||||
|
$query = "\$filter=driveType eq $driveType";
|
||||||
|
$userAdmin = $this->featureContext->getAdminUsername();
|
||||||
|
|
||||||
|
for ($i = 0; $i < 2; ++$i) {
|
||||||
|
$this->theUserListsAllAvailableSpacesUsingTheGraphApi(
|
||||||
|
$userAdmin,
|
||||||
|
$query
|
||||||
|
);
|
||||||
|
$drives = $this->getAvailableSpaces();
|
||||||
|
|
||||||
|
if (!empty($drives)) {
|
||||||
|
foreach ($drives as $value) {
|
||||||
|
if (!\array_key_exists("deleted", $value["root"])) {
|
||||||
|
$this->sendDisableSpaceRequest($userAdmin, $value["name"]);
|
||||||
|
} else {
|
||||||
|
$this->sendDeleteSpaceRequest($userAdmin, $value["name"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send Graph List My Spaces Request
|
* Send Graph List My Spaces Request
|
||||||
*
|
*
|
||||||
@@ -560,7 +609,6 @@ class SpacesContext implements Context {
|
|||||||
* @param string $xRequestId
|
* @param string $xRequestId
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @return ResponseInterface
|
* @return ResponseInterface
|
||||||
*
|
*
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
@@ -1748,55 +1796,55 @@ class SpacesContext implements Context {
|
|||||||
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
|
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" to "([^"]*)" in space "([^"]*)" using the WebDAV API$/
|
* @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" to "([^"]*)" in space "([^"]*)" using the WebDAV API$/
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $fileSource
|
* @param string $fileSource
|
||||||
* @param string $fileDestination
|
* @param string $fileDestination
|
||||||
* @param string $spaceName
|
* @param string $spaceName
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function userMovesFileWithinSpaceUsingTheWebDAVAPI(
|
public function userMovesFileWithinSpaceUsingTheWebDAVAPI(
|
||||||
string $user,
|
string $user,
|
||||||
string $fileSource,
|
string $fileSource,
|
||||||
string $fileDestination,
|
string $fileDestination,
|
||||||
string $spaceName
|
string $spaceName
|
||||||
):void {
|
):void {
|
||||||
$space = $this->getSpaceByName($user, $spaceName);
|
$space = $this->getSpaceByName($user, $spaceName);
|
||||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName(
|
||||||
$user,
|
$user,
|
||||||
$fileDestination,
|
$fileDestination,
|
||||||
$spaceName
|
$spaceName
|
||||||
);
|
);
|
||||||
|
|
||||||
$fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/");
|
$fullUrl = $space["root"]["webDavUrl"] . '/' . \trim($fileSource, "/");
|
||||||
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
|
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MOVE request for files|folders
|
* MOVE request for files|folders
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $fullUrl
|
* @param string $fullUrl
|
||||||
* @param string $headers
|
* @param string $headers
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws GuzzleException
|
* @throws GuzzleException
|
||||||
*/
|
*/
|
||||||
public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array $headers):void {
|
public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array $headers):void {
|
||||||
$this->featureContext->setResponse(
|
$this->featureContext->setResponse(
|
||||||
HttpRequestHelper::sendRequest(
|
HttpRequestHelper::sendRequest(
|
||||||
$fullUrl,
|
$fullUrl,
|
||||||
$this->featureContext->getStepLineRef(),
|
$this->featureContext->getStepLineRef(),
|
||||||
'MOVE',
|
'MOVE',
|
||||||
$user,
|
$user,
|
||||||
$this->featureContext->getPasswordForUser($user),
|
$this->featureContext->getPasswordForUser($user),
|
||||||
$headers,
|
$headers,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/
|
* @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/
|
||||||
@@ -1823,31 +1871,30 @@ class SpacesContext implements Context {
|
|||||||
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
|
$this->copyFilesAndFoldersRequest($user, $fullUrl, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/
|
||||||
* @When /^user "([^"]*)" moves (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/
|
*
|
||||||
*
|
* @param string $user
|
||||||
* @param string $user
|
* @param string $fileSource
|
||||||
* @param string $fileSource
|
* @param string $fromSpaceName
|
||||||
* @param string $fromSpaceName
|
* @param string $fileDestination
|
||||||
* @param string $fileDestination
|
* @param string $toSpaceName
|
||||||
* @param string $toSpaceName
|
*
|
||||||
*
|
* @return void
|
||||||
* @return void
|
* @throws GuzzleException
|
||||||
* @throws GuzzleException
|
*/
|
||||||
*/
|
public function userMovesFileFromAndToSpaceBetweenSpaces(
|
||||||
public function userMovesFileFromAndToSpaceBetweenSpaces(
|
string $user,
|
||||||
string $user,
|
string $fileSource,
|
||||||
string $fileSource,
|
string $fromSpaceName,
|
||||||
string $fromSpaceName,
|
string $fileDestination,
|
||||||
string $fileDestination,
|
string $toSpaceName
|
||||||
string $toSpaceName
|
):void {
|
||||||
):void {
|
$space = $this->getSpaceByName($user, $fromSpaceName);
|
||||||
$space = $this->getSpaceByName($user, $fromSpaceName);
|
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName);
|
||||||
$headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName);
|
$fullUrl = $space["root"]["webDavUrl"] . '/' . \ltrim($fileSource, "/");
|
||||||
$fullUrl = $space["root"]["webDavUrl"] . '/' . \ltrim($fileSource, "/");
|
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
|
||||||
$this->moveFilesAndFoldersRequest($user, $fullUrl, $headers);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a url for destination with spacename
|
* returns a url for destination with spacename
|
||||||
@@ -2852,7 +2899,7 @@ class SpacesContext implements Context {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$should = ($shouldOrNot !== "not");
|
$should = ($shouldOrNot !== "not");
|
||||||
$responseArray = json_decode(json_encode($this->featureContext->getResponseXml()->data),true, 512, JSON_THROW_ON_ERROR);
|
$responseArray = json_decode(json_encode($this->featureContext->getResponseXml()->data), true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
if ($should) {
|
if ($should) {
|
||||||
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
|
Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty');
|
||||||
|
|||||||
Reference in New Issue
Block a user