test: do not try graph endpoints if testing on reva

This commit is contained in:
Saw-jan
2024-12-04 16:29:59 +05:45
parent bedddc4728
commit 529d29e5b1
2 changed files with 15 additions and 33 deletions

View File

@@ -520,30 +520,25 @@ class WebDavHelper {
if (\array_key_exists($user, self::$spacesIdRef) && \array_key_exists("personal", self::$spacesIdRef[$user])) {
return self::$spacesIdRef[$user]["personal"];
}
$trimmedBaseUrl = \trim($baseUrl, "/");
$drivesPath = '/graph/v1.0/me/drives';
$fullUrl = $trimmedBaseUrl . $drivesPath;
$response = HttpRequestHelper::get(
$fullUrl,
$xRequestId,
$user,
$password
);
Assert::assertEquals(200, $response->getStatusCode(), "Cannot list drives for user '$user'");
$personalSpaceId = '';
$drives = HttpRequestHelper::getJsonDecodedResponseBodyContent($response);
foreach ($drives->value as $drive) {
if ($drive->driveType === "personal") {
$personalSpaceId = $drive->id;
break;
if (!OcisHelper::isTestingOnReva()) {
$response = GraphHelper::getMySpaces($baseUrl, $user, $password, '', $xRequestId);
Assert::assertEquals(200, $response->getStatusCode(), "Cannot list drives for user '$user'");
$drives = HttpRequestHelper::getJsonDecodedResponseBodyContent($response);
foreach ($drives->value as $drive) {
if ($drive->driveType === "personal") {
$personalSpaceId = $drive->id;
break;
}
}
}
if (!$personalSpaceId) {
// the graph endpoint did not give a useful answer
// try getting the information from the webdav endpoint
$fullUrl = "$trimmedBaseUrl/" . self::getDavPath(self::DAV_VERSION_NEW, $user);
$fullUrl = "$baseUrl/" . self::getDavPath(self::DAV_VERSION_NEW, $user);
$response = HttpRequestHelper::sendRequest(
$fullUrl,
$xRequestId,