test: use store for personal, shares and created spaces
This commit is contained in:
8 files changed
+136
-179
No files matched your search
@@ -1042,7 +1042,8 @@ class GraphHelper {
|
||||
array $body = [],
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'me/drives' . $urlArguments);
|
||||
$urlArguments = $urlArguments ? "?$urlArguments" : "";
|
||||
$url = self::getFullUrl($baseUrl, "me/drives$urlArguments");
|
||||
|
||||
return HttpRequestHelper::get($url, $xRequestId, $user, $password, $headers, $body);
|
||||
}
|
||||
@@ -1071,7 +1072,8 @@ class GraphHelper {
|
||||
array $body = [],
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'drives/' . $urlArguments);
|
||||
$urlArguments = $urlArguments ? "?$urlArguments" : "";
|
||||
$url = self::getFullUrl($baseUrl, "drives$urlArguments");
|
||||
|
||||
return HttpRequestHelper::get($url, $xRequestId, $user, $password, $headers, $body);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class HttpRequestHelper {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function numRetriesOnHttpTooEarly(): int {
|
||||
public static function maxHTTPRequestRetries(): int {
|
||||
// Currently reva and oCIS may return HTTP_TOO_EARLY
|
||||
// So try up to 10 times before giving up.
|
||||
return 10;
|
||||
@@ -203,7 +203,7 @@ class HttpRequestHelper {
|
||||
$debugResponses = false;
|
||||
}
|
||||
|
||||
$sendRetryLimit = self::numRetriesOnHttpTooEarly();
|
||||
$sendRetryLimit = self::maxHTTPRequestRetries();
|
||||
$sendCount = 0;
|
||||
$sendExceptionHappened = false;
|
||||
do {
|
||||
|
||||
@@ -2977,6 +2977,8 @@ class FeatureContext extends BehatVariablesContext {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function checkScenario(AfterScenarioScope $scope): void {
|
||||
var_dump("Before running...");
|
||||
var_dump($this->personalSpaces);
|
||||
if (($scope->getTestResult()->getResultCode() !== 0)
|
||||
&& (!self::isExpectedToFail(self::getScenarioLine($scope)))
|
||||
) {
|
||||
|
||||
@@ -2674,7 +2674,7 @@ class GraphContext implements Context {
|
||||
$autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']);
|
||||
$tryAgain = !$share->{'@client.synchronize'}
|
||||
&& $autoSync
|
||||
&& $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
&& $retried < HttpRequestHelper::maxHTTPRequestRetries();
|
||||
|
||||
if ($tryAgain) {
|
||||
$retried += 1;
|
||||
@@ -2918,7 +2918,7 @@ class GraphContext implements Context {
|
||||
string $resource,
|
||||
string $spaceName
|
||||
): void {
|
||||
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
$resourceId = $this->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -2974,7 +2974,7 @@ class GraphContext implements Context {
|
||||
string $owner,
|
||||
string $spaceName
|
||||
): void {
|
||||
$resourceId = $this->featureContext->spacesContext->getResourceId($owner, $spaceName, $file);
|
||||
$resourceId = $this->spacesContext->getResourceId($owner, $spaceName, $file);
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -2994,7 +2994,7 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
*/
|
||||
public function userListsTheActivitiesOfSpaceUsingTheGraphApi(string $user, string $spaceName): void {
|
||||
$spaceId = ($this->featureContext->spacesContext->getSpaceByName($user, $spaceName))["id"];
|
||||
$spaceId = ($this->spacesContext->getSpaceByName($user, $spaceName))->id;
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
@@ -3073,7 +3073,7 @@ class GraphContext implements Context {
|
||||
string $filterType,
|
||||
string $filterValue
|
||||
): void {
|
||||
$resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
$resourceId = $this->spacesContext->getResourceId($user, $spaceName, $resource);
|
||||
$response = GraphHelper::getActivities(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
|
||||
@@ -956,19 +956,20 @@ trait Provisioning {
|
||||
* @return void
|
||||
*/
|
||||
public function initializeUser(string $user, string $password): void {
|
||||
$url = $this->getBaseUrl() . "/graph/v1.0/users/$user";
|
||||
|
||||
if (OcisHelper::isTestingOnReva()) {
|
||||
$url = $this->getBaseUrl()
|
||||
. "/ocs/v$this->ocsApiVersion.php/cloud/users/$user";
|
||||
$url = $this->getBaseUrl() . "/ocs/v$this->ocsApiVersion.php/cloud/users/$user";
|
||||
HttpRequestHelper::get(
|
||||
$url,
|
||||
$this->getStepLineRef(),
|
||||
$user,
|
||||
$password
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
HttpRequestHelper::get(
|
||||
$url,
|
||||
$this->getStepLineRef(),
|
||||
$user,
|
||||
$password
|
||||
);
|
||||
// initialize user by requesting drives
|
||||
// saves the Personal drive id
|
||||
$this->spacesContext->getSpaceByName($user, 'Personal');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2000,7 +2001,8 @@ trait Provisioning {
|
||||
$this->usingServer('LOCAL');
|
||||
foreach ($this->createdUsers as $userData) {
|
||||
$user = $userData['actualUsername'];
|
||||
$this->deleteUser($user);
|
||||
$response = $this->deleteUser($user);
|
||||
$this->theHTTPStatusCodeShouldBe(204, "Failed to delete user '$user'", $response);
|
||||
Assert::assertFalse(
|
||||
$this->userExists($user),
|
||||
"User '$user' should not exist but does exist"
|
||||
@@ -2010,7 +2012,8 @@ trait Provisioning {
|
||||
$this->usingServer('REMOTE');
|
||||
foreach ($this->createdRemoteUsers as $userData) {
|
||||
$user = $userData['actualUsername'];
|
||||
$this->deleteUser($user);
|
||||
$response = $this->deleteUser($user);
|
||||
$this->theHTTPStatusCodeShouldBe(204, "Failed to delete user '$user'", $response);
|
||||
Assert::assertFalse(
|
||||
$this->userExists($user),
|
||||
"User '$user' should not exist but does exist"
|
||||
|
||||
@@ -186,7 +186,7 @@ class SettingsContext implements Context {
|
||||
$decodedBody = \json_decode($rawBody, true, 512, JSON_THROW_ON_ERROR);
|
||||
$tryAgain = false;
|
||||
} catch (Exception $e) {
|
||||
$tryAgain = $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
$tryAgain = $retried < HttpRequestHelper::maxHTTPRequestRetries();
|
||||
|
||||
if (!$tryAgain) {
|
||||
throw $e;
|
||||
|
||||
@@ -72,11 +72,7 @@ class SharingNgContext implements Context {
|
||||
$bodyRows = $body->getRowsHash();
|
||||
$resource = $bodyRows['resource'] ?? "";
|
||||
|
||||
if ($bodyRows['space'] === 'Personal' || $bodyRows['space'] === 'Shares') {
|
||||
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
|
||||
} else {
|
||||
$space = $this->spacesContext->getCreatedSpace($bodyRows['space']);
|
||||
}
|
||||
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
|
||||
$spaceId = $space['id'];
|
||||
|
||||
if ($resource === '' && !\in_array($bodyRows['space'], ['Personal', 'Shares'])) {
|
||||
@@ -269,11 +265,7 @@ class SharingNgContext implements Context {
|
||||
string $fileId = null,
|
||||
bool $federatedShare = false
|
||||
): ResponseInterface {
|
||||
if ($shareInfo['space'] === 'Personal' || $shareInfo['space'] === 'Shares') {
|
||||
$space = $this->spacesContext->getSpaceByName($user, $shareInfo['space']);
|
||||
} else {
|
||||
$space = $this->spacesContext->getCreatedSpace($shareInfo['space']);
|
||||
}
|
||||
$space = $this->spacesContext->getSpaceByName($user, $shareInfo['space']);
|
||||
$spaceId = $space['id'];
|
||||
|
||||
// $fileId is used for trying to share deleted files
|
||||
@@ -363,11 +355,7 @@ class SharingNgContext implements Context {
|
||||
): ResponseInterface {
|
||||
$shareeIds = [];
|
||||
$rows = $table->getRowsHash();
|
||||
if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') {
|
||||
$space = $this->spacesContext->getSpaceByName($user, $rows['space']);
|
||||
} else {
|
||||
$space = $this->spacesContext->getCreatedSpace($rows['space']);
|
||||
}
|
||||
$space = $this->spacesContext->getSpaceByName($user, $rows['space']);
|
||||
$spaceId = $space['id'];
|
||||
|
||||
$sharees = array_map('trim', explode(',', $rows['sharee']));
|
||||
@@ -653,11 +641,7 @@ class SharingNgContext implements Context {
|
||||
*/
|
||||
public function updateResourceShare(string $user, TableNode $body, string $permissionID): ResponseInterface {
|
||||
$bodyRows = $body->getRowsHash();
|
||||
if ($bodyRows['space'] === 'Personal' || $bodyRows['space'] === 'Shares') {
|
||||
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
|
||||
} else {
|
||||
$space = $this->spacesContext->getCreatedSpace($bodyRows['space']);
|
||||
}
|
||||
$space = $this->spacesContext->getSpaceByName($user, $bodyRows['space']);
|
||||
$spaceId = $space["id"];
|
||||
// for updating role of project space shared, we do not need to provide resource
|
||||
$resource = $bodyRows['resource'] ?? '';
|
||||
@@ -1467,7 +1451,7 @@ class SharingNgContext implements Context {
|
||||
return;
|
||||
}
|
||||
|
||||
$tryAgain = !$shareSynced && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
$tryAgain = !$shareSynced && $retried < HttpRequestHelper::maxHTTPRequestRetries();
|
||||
if ($tryAgain) {
|
||||
$retried += 1;
|
||||
echo "[INFO] Wait for share sync status...";
|
||||
|
||||
@@ -54,7 +54,7 @@ class SpacesContext implements Context {
|
||||
/**
|
||||
* key is space name and value is the username that created the space
|
||||
*/
|
||||
private array $createdSpaces;
|
||||
private array $createdSpaces = [];
|
||||
private string $ocsApiUrl = '/ocs/v2.php/apps/files_sharing/api/v1/shares';
|
||||
|
||||
/**
|
||||
@@ -74,6 +74,26 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
private array $storedEtags = [];
|
||||
|
||||
/**
|
||||
* @param string $spaceCreator
|
||||
* @param object $space
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addToCreatedSpace(string $spaceCreator, object $space): void {
|
||||
$spaceName = $space->name;
|
||||
$this->createdSpaces[$spaceName] = $space;
|
||||
$this->createdSpaces[$spaceName]->spaceCreator = $spaceCreator;
|
||||
$this->createdSpaces[$spaceName]->fileId = $space->id . '!' . $space->owner->user->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCreatedSpaces(): array {
|
||||
return $this->createdSpaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $spaceName
|
||||
*
|
||||
@@ -87,46 +107,30 @@ class SpacesContext implements Context {
|
||||
return $this->createdSpaces[$spaceName]['spaceCreator'];
|
||||
}
|
||||
|
||||
private array $personalSpaces = [];
|
||||
|
||||
/**
|
||||
* @param string $spaceCreator
|
||||
* @param ResponseInterface $response
|
||||
* @param string $user
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function getPersonalSpaceForUser(string $user): ?object {
|
||||
$spaceName = $this->featureContext->getUserDisplayName($user);
|
||||
if (!isset($this->personalSpaces[$spaceName])) {
|
||||
return null;
|
||||
}
|
||||
return $this->personalSpaces[$spaceName];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param object $space
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addCreatedSpace(string $spaceCreator, ResponseInterface $response): void {
|
||||
$response = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
$spaceName = $response->name;
|
||||
$this->createdSpaces[$spaceName] = [];
|
||||
$this->createdSpaces[$spaceName]['id'] = $response->id;
|
||||
$this->createdSpaces[$spaceName]['spaceCreator'] = $spaceCreator;
|
||||
$this->createdSpaces[$spaceName]['fileId'] = $response->id . '!' . $response->owner->user->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCreatedSpace(string $spaceName): array {
|
||||
return $this->createdSpaces[$spaceName];
|
||||
}
|
||||
|
||||
private array $availableSpaces = [];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAvailableSpaces(): array {
|
||||
return $this->availableSpaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $availableSpaces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAvailableSpaces(array $availableSpaces): void {
|
||||
$this->availableSpaces = $availableSpaces;
|
||||
public function addPersonalSpaceForUser(string $user, object $space): void {
|
||||
$spaceName = $this->featureContext->getUserDisplayName($user);
|
||||
$this->personalSpaces[$spaceName] = $space;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,8 +179,6 @@ class SpacesContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* The method finds available spaces to the user and returns the space by spaceName
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
*
|
||||
@@ -184,27 +186,48 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getSpaceByName(string $user, string $spaceName): array {
|
||||
$createdSpaces = $this->getCreatedSpaces();
|
||||
$personalSpace = $this->getPersonalSpaceForUser($user);
|
||||
$allSpaces = \array_merge($createdSpaces, [$personalSpace]);
|
||||
|
||||
$storeSpaceFn = 'addToCreatedSpace';
|
||||
if ($spaceName === "Personal") {
|
||||
$spaceName = $this->featureContext->getUserDisplayName($user);
|
||||
$storeSpaceFn = 'addPersonalSpaceForUser';
|
||||
}
|
||||
if (strtolower($user) === 'admin') {
|
||||
$listSpacesFn = 'listAllAvailableSpaces';
|
||||
} else {
|
||||
$listSpacesFn = 'listAllAvailableSpacesOfUser';
|
||||
|
||||
if (isset($allSpaces[$spaceName])) {
|
||||
return (array) $allSpaces[$spaceName];
|
||||
}
|
||||
|
||||
// Sometimes listing available spaces might not return newly created/shared spaces.
|
||||
// So we try again until we find the space or we reach the max number of retries (i.e. 10)
|
||||
$retried = 0;
|
||||
do {
|
||||
// empty the available spaces array
|
||||
$this->setAvailableSpaces([]);
|
||||
$response = GraphHelper::getAllSpaces(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
"",
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
$spaces = $this->featureContext->getJsonDecodedResponseBodyContent($response)->value;
|
||||
|
||||
$this->$listSpacesFn($user);
|
||||
$spaces = $this->getAvailableSpaces();
|
||||
$found = false;
|
||||
$foundSpace = [];
|
||||
foreach ($spaces as $space) {
|
||||
if ($space->name === "Shares") {
|
||||
$this->addPersonalSpaceForUser("Shares", $space);
|
||||
}
|
||||
if ($space->name === $spaceName) {
|
||||
$found = true;
|
||||
$foundSpace = $space;
|
||||
$this->$storeSpaceFn($user, $space);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$tryAgain = !\array_key_exists($spaceName, $spaces)
|
||||
&& $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||
$tryAgain = !$found && $retried < HttpRequestHelper::maxHTTPRequestRetries();
|
||||
if ($tryAgain) {
|
||||
$retried += 1;
|
||||
echo "Space '$spaceName' not found for user '$user', retrying ($retried)...\n";
|
||||
@@ -213,12 +236,7 @@ class SpacesContext implements Context {
|
||||
}
|
||||
} while ($tryAgain);
|
||||
|
||||
Assert::assertArrayHasKey($spaceName, $spaces, "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"
|
||||
);
|
||||
return $spaces[$spaceName];
|
||||
return (array) $foundSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,22 +485,16 @@ class SpacesContext implements Context {
|
||||
* @throws Exception|GuzzleException
|
||||
*/
|
||||
public function deleteAllProjectSpaces(): void {
|
||||
$query = "\$filter=driveType eq project";
|
||||
$userAdmin = $this->featureContext->getAdminUsername();
|
||||
$drives = $this->getCreatedSpaces();
|
||||
|
||||
$this->listAllAvailableSpaces(
|
||||
$userAdmin,
|
||||
$query
|
||||
);
|
||||
$drives = $this->getAvailableSpaces();
|
||||
|
||||
foreach ($drives as $value) {
|
||||
if (!\array_key_exists("deleted", $value["root"])) {
|
||||
foreach ($drives as $drive) {
|
||||
if (!isset($drive->root->deleted)) {
|
||||
GraphHelper::disableSpace(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$userAdmin,
|
||||
$this->featureContext->getPasswordForUser($userAdmin),
|
||||
$value["id"],
|
||||
$drive->id,
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
}
|
||||
@@ -490,7 +502,7 @@ class SpacesContext implements Context {
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$userAdmin,
|
||||
$this->featureContext->getPasswordForUser($userAdmin),
|
||||
$value["id"],
|
||||
$drive->id,
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
}
|
||||
@@ -556,22 +568,20 @@ class SpacesContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listAllAvailableSpacesOfUser(
|
||||
public function listAllMySpaces(
|
||||
string $user,
|
||||
string $query = '',
|
||||
array $headers = []
|
||||
): ResponseInterface {
|
||||
$response = GraphHelper::getMySpaces(
|
||||
return GraphHelper::getMySpaces(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
"?" . $query,
|
||||
$query,
|
||||
$this->featureContext->getStepLineRef(),
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
$this->rememberTheAvailableSpaces($response);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -587,7 +597,7 @@ class SpacesContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserListsAllHisAvailableSpacesUsingTheGraphApi(string $user, string $query = ''): void {
|
||||
$this->featureContext->setResponse($this->listAllAvailableSpacesOfUser($user, $query));
|
||||
$this->featureContext->setResponse($this->listAllMySpaces($user, $query));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,30 +623,7 @@ class SpacesContext implements Context {
|
||||
foreach ($headersTable as $row) {
|
||||
$headers[$row['header']] = $row ['value'];
|
||||
}
|
||||
$this->featureContext->setResponse($this->listAllAvailableSpacesOfUser($user, '', $headers));
|
||||
}
|
||||
|
||||
/**
|
||||
* The method is used on the administration setting tab, which only the Admin user and the Space admin user have access to
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $query
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function listAllAvailableSpaces(string $user, string $query = ''): ResponseInterface {
|
||||
$response = GraphHelper::getAllSpaces(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
"?" . $query,
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
$this->rememberTheAvailableSpaces($response);
|
||||
return $response;
|
||||
$this->featureContext->setResponse($this->listAllMySpaces($user, '', $headers));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -653,9 +640,14 @@ class SpacesContext implements Context {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theUserListsAllAvailableSpacesUsingTheGraphApi(string $user, string $query = ''): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->listAllAvailableSpaces($user, $query)
|
||||
$response = GraphHelper::getAllSpaces(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
$query,
|
||||
$this->featureContext->getStepLineRef()
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -721,37 +713,11 @@ class SpacesContext implements Context {
|
||||
);
|
||||
$this->featureContext->setResponse($response);
|
||||
if ($response->getStatusCode() === 201) {
|
||||
$this->addCreatedSpace($user, $response);
|
||||
$space = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
$this->addToCreatedSpace($user, $space);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remember the available Spaces
|
||||
*
|
||||
* @param ResponseInterface|null $response
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function rememberTheAvailableSpaces(?ResponseInterface $response = null): void {
|
||||
if ($response) {
|
||||
$rawBody = $response->getBody()->getContents();
|
||||
} else {
|
||||
$rawBody = $this->featureContext->getResponse()->getBody()->getContents();
|
||||
}
|
||||
$drives = json_decode($rawBody, true, 512, JSON_THROW_ON_ERROR);
|
||||
if (isset($drives["value"])) {
|
||||
$drives = $drives["value"];
|
||||
}
|
||||
|
||||
$spaces = [];
|
||||
foreach ($drives as $drive) {
|
||||
$spaces[$drive["name"]] = $drive;
|
||||
}
|
||||
$this->setAvailableSpaces($spaces);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
@@ -1049,7 +1015,7 @@ class SpacesContext implements Context {
|
||||
string $grantedUser,
|
||||
string $role
|
||||
): void {
|
||||
$response = $this->listAllAvailableSpacesOfUser($user);
|
||||
$response = $this->listAllMySpaces($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"Expected response status code should be 200",
|
||||
@@ -1105,7 +1071,7 @@ class SpacesContext implements Context {
|
||||
string $shouldOrNot,
|
||||
string $spaceName
|
||||
): void {
|
||||
$response = $this->listAllAvailableSpacesOfUser($user);
|
||||
$response = $this->listAllMySpaces($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"Expected response status code should be 200",
|
||||
@@ -1137,7 +1103,7 @@ class SpacesContext implements Context {
|
||||
string $user,
|
||||
string $spaceName
|
||||
): void {
|
||||
$response = $this->listAllAvailableSpacesOfUser($user);
|
||||
$response = $this->listAllMySpaces($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"Expected response status code should be 200",
|
||||
@@ -1758,12 +1724,13 @@ class SpacesContext implements Context {
|
||||
): void {
|
||||
$space = ["name" => $spaceName, "driveType" => $spaceType, "quota" => ["total" => $quota]];
|
||||
$response = $this->createSpace($user, $space);
|
||||
$this->addCreatedSpace($user, $response);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
201,
|
||||
"Expected response status code should be 201 (Created)",
|
||||
$response
|
||||
);
|
||||
$space = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
$this->addToCreatedSpace($user, $space);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1783,12 +1750,13 @@ class SpacesContext implements Context {
|
||||
): void {
|
||||
$space = ["name" => $spaceName];
|
||||
$response = $this->createSpace($user, $space);
|
||||
$this->addCreatedSpace($user, $response);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
201,
|
||||
"Expected response status code should be 201 (Created)",
|
||||
$response
|
||||
);
|
||||
$space = $this->featureContext->getJsonDecodedResponseBodyContent($response);
|
||||
$this->addToCreatedSpace($user, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2420,14 +2388,12 @@ class SpacesContext implements Context {
|
||||
string $fileContent,
|
||||
string $destination
|
||||
): array {
|
||||
$response = $this->listAllAvailableSpacesOfUser($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
$spaceId = $this->getSpaceIdByName($user, $spaceName);
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$response = $this->featureContext->uploadFileWithContent(
|
||||
$user,
|
||||
$fileContent,
|
||||
$destination,
|
||||
$spaceId,
|
||||
$space["id"],
|
||||
true
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(['201', '204'], "", $response);
|
||||
@@ -4622,7 +4588,7 @@ class SpacesContext implements Context {
|
||||
string $role,
|
||||
string $expirationDate = null
|
||||
): void {
|
||||
$response = $this->listAllAvailableSpacesOfUser($user);
|
||||
$response = $this->listAllMySpaces($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"Expected response status code should be 200",
|
||||
|
||||
Reference in new issue
Block a user