Skip to content

Commit

Permalink
test: do not try graph endpoints if testing on reva
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Dec 6, 2024
1 parent 12e2098 commit 0ffab04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 33 deletions.
27 changes: 11 additions & 16 deletions tests/acceptance/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,30 +520,25 @@ public static function getPersonalSpaceIdForUser(string $baseUrl, string $user,
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,
Expand Down
21 changes: 4 additions & 17 deletions tests/acceptance/bootstrap/SharingNgContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1794,31 +1794,18 @@ public function checkIfShareExists(string $share, string $sharee, string $sharer
}

/**
* @Then user :sharee should have a share :share shared by user :sharer from space :space
* @Then /^user "([^"]*)" (should|should not) have a share "([^"]*)" shared by user "([^"]*)" from space "([^"]*)"$/
*
* @param string $sharee
* @param string $shouldOrNot
* @param string $share
* @param string $sharer
* @param string $space
*
* @return void
*/
public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string $share, string $sharer, string $space): void {
$this->checkIfShareExists($share, $sharee, $sharer, $space);
}

/**
* @Then user :sharee should not have a share :share shared by user :sharer from space :space
*
* @param string $sharee
* @param string $share
* @param string $sharer
* @param string $space
*
* @return void
*/
public function userShouldNotHaveShareSharedByUserFromSpace(string $sharee, string $share, string $sharer, string $space): void {
$this->checkIfShareExists($share, $sharee, $sharer, $space, false);
public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void {
$this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should");
}

/**
Expand Down

0 comments on commit 0ffab04

Please sign in to comment.