Compare commits

...

2 Commits

Author SHA1 Message Date
Viktor Scharf
da3a893634 getting all spaces using beta graph endpoint 2025-04-30 12:25:55 +02:00
Viktor Scharf
7bb95d057a check that created user has only one personal space 2025-04-29 16:26:39 +02:00
3 changed files with 90 additions and 1 deletions

View File

@@ -1069,7 +1069,7 @@ class GraphHelper {
array $body = [],
array $headers = []
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'drives/' . $urlArguments);
$url = self::getBetaFullUrl($baseUrl, 'drives/' . $urlArguments);
return HttpRequestHelper::get($url, $xRequestId, $user, $password, $headers, $body);
}

View File

@@ -1985,8 +1985,29 @@ trait Provisioning {
if ($this->isTestingWithLdap()) {
$this->deleteLdapUsersAndGroups();
}
$assertionFailed = false;
$errorMessage = '';
// check that created users have only one personal space
try {
$this->setResponse(
$this->spacesContext->listAllAvailableSpaces("admin", "%24filter=driveType+eq+personal")
);
$this->spacesContext->jsonRespondedShouldContainOnlyOneSpace();
$this->spacesContext->jsonRespondedShouldNotContainSpaceWithoutName();
} catch (\Throwable $e) {
$assertionFailed = true;
$errorMessage = $e->getMessage();
echo "\n[WARNING] Space assertion failed: " . $errorMessage . "\n";
}
$this->cleanupDatabaseUsers();
$this->cleanupDatabaseGroups();
if ($assertionFailed) {
throw new \Exception("Space assertion failed:\n" . $errorMessage);
}
}
/**

View File

@@ -1087,6 +1087,74 @@ class SpacesContext implements Context {
);
}
/**
* @return void
* @throws Exception
*/
public function jsonRespondedShouldContainOnlyOneSpace(): void {
$response = $response ?? $this->featureContext->getResponse();
$decodedResponse = $this->featureContext->getJsonDecodedResponse($response);
$userAdmin = $this->featureContext->getAdminUsername();
$aliases = [];
foreach ($decodedResponse['value'] as $space) {
$alias = $space['driveAlias'];
if (isset($aliases[$alias])) {
GraphHelper::disableSpace(
$this->featureContext->getBaseUrl(),
$userAdmin,
$this->featureContext->getPasswordForUser($userAdmin),
$space["id"],
$this->featureContext->getStepLineRef()
);
GraphHelper::deleteSpace(
$this->featureContext->getBaseUrl(),
$userAdmin,
$this->featureContext->getPasswordForUser($userAdmin),
$space["id"],
$this->featureContext->getStepLineRef()
);
Assert::fail(
"Duplicate space found: '$alias'\nResponse:\n" . json_encode($decodedResponse, JSON_PRETTY_PRINT)
);
}
$aliases[$alias] = true;
}
}
/**
* @return void
* @throws Exception
*/
public function jsonRespondedShouldNotContainSpaceWithoutName(): void {
$response = $response ?? $this->featureContext->getResponse();
$decodedResponse = $this->featureContext->getJsonDecodedResponse($response);
$userAdmin = $this->featureContext->getAdminUsername();
foreach ($decodedResponse['value'] as $space) {
if ($space['name'] === "") {
GraphHelper::disableSpace(
$this->featureContext->getBaseUrl(),
$userAdmin,
$this->featureContext->getPasswordForUser($userAdmin),
$space["id"],
$this->featureContext->getStepLineRef()
);
GraphHelper::deleteSpace(
$this->featureContext->getBaseUrl(),
$userAdmin,
$this->featureContext->getPasswordForUser($userAdmin),
$space["id"],
$this->featureContext->getStepLineRef()
);
Assert::fail(
"Space without name found. \nResponse:\n" . json_encode($decodedResponse, JSON_PRETTY_PRINT)
);
}
}
}
/**
* @Then /^the user "([^"]*)" should (not |)have a space called "([^"]*)"$/
*