From 529d29e5b18e10b2704e996aaa641d415ab1a324 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Wed, 4 Dec 2024 16:29:59 +0545 Subject: [PATCH] test: do not try graph endpoints if testing on reva --- tests/acceptance/TestHelpers/WebDavHelper.php | 27 ++++++++----------- .../acceptance/bootstrap/SharingNgContext.php | 21 +++------------ 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/tests/acceptance/TestHelpers/WebDavHelper.php b/tests/acceptance/TestHelpers/WebDavHelper.php index 37567d16ab..0676b941b0 100644 --- a/tests/acceptance/TestHelpers/WebDavHelper.php +++ b/tests/acceptance/TestHelpers/WebDavHelper.php @@ -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, diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index aebc33c05c..96a0842fc2 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -1794,31 +1794,18 @@ class SharingNgContext implements Context { } /** - * @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"); } /**