From 3288602c503dccf860ffde7c14ef4009006e5a80 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 13 Aug 2024 12:09:09 +0200 Subject: [PATCH] tests: Adjust acceptance test for recent graph API changes Searching for federated users requires a $filter now. --- tests/TestHelpers/GraphHelper.php | 26 +++++++++++++++++++ .../apiOcm/searchFederationUsers.feature | 14 +++++----- .../features/bootstrap/GraphContext.php | 21 +++++++++++++++ 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index 35ef00a6c..9cb17d8f4 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -306,6 +306,32 @@ class GraphHelper { ); } + /** + * @param string $baseUrl + * @param string $xRequestId + * @param string $adminUser + * @param string $adminPassword + * @param string $searchTerm + * + * @return ResponseInterface + */ + public static function searchFederatedUser( + string $baseUrl, + string $xRequestId, + string $adminUser, + string $adminPassword, + string $searchTerm + ): ResponseInterface { + $url = self::getFullUrl($baseUrl, "users?\$filter=userType eq 'Federated'&\$search=$searchTerm"); + return HttpRequestHelper::get( + $url, + $xRequestId, + $adminUser, + $adminPassword, + self::getRequestHeaders() + ); + } + /** * @param string $baseUrl * @param string $xRequestId diff --git a/tests/acceptance/features/apiOcm/searchFederationUsers.feature b/tests/acceptance/features/apiOcm/searchFederationUsers.feature index a36fa52ec..fc46eb37c 100755 --- a/tests/acceptance/features/apiOcm/searchFederationUsers.feature +++ b/tests/acceptance/features/apiOcm/searchFederationUsers.feature @@ -18,7 +18,7 @@ Feature: search federation users And "Alice" has created the federation share invitation And using server "REMOTE" And "Brian" has accepted invitation - When user "Brian" searches for user "ali" using Graph API + When user "Brian" searches for federated user "ali" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -53,7 +53,7 @@ Feature: search federation users } """ And using server "LOCAL" - When user "Alice" searches for user "bri" using Graph API + When user "Alice" searches for federated user "bri" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -94,7 +94,7 @@ Feature: search federation users And "Alice" has created the federation share invitation And using server "REMOTE" And "Brian" has accepted invitation - When user "Brian" searches for user "%22alice@example.org%22" using Graph API + When user "Brian" searches for federated user "%22alice@example.org%22" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -129,7 +129,7 @@ Feature: search federation users } """ And using server "LOCAL" - When user "Alice" searches for user "%22brian@example.org%22" using Graph API + When user "Alice" searches for federated user "%22brian@example.org%22" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -170,7 +170,7 @@ Feature: search federation users And "Alice" has created the federation share invitation And using server "REMOTE" And "Brian" has accepted invitation - When user "Brian" searches for user "%22carol@example.org%22" using Graph API + When user "Brian" searches for federated user "%22carol@example.org%22" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -189,7 +189,7 @@ Feature: search federation users } """ And using server "LOCAL" - When user "Carol" searches for user "bria" using Graph API + When user "Carol" searches for federated user "bria" using Graph API Then the HTTP status code should be "200" And the JSON data of the response should match """ @@ -325,4 +325,4 @@ Feature: search federation users """ -# TODO try to find federation users after deleting federated conection \ No newline at end of file +# TODO try to find federation users after deleting federated conection diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 4da2dd3b7..113c6857b 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -1253,6 +1253,27 @@ class GraphContext implements Context { $this->featureContext->setResponse($response); } + /** + * @When user :byUser searches for federated user :searchTerm using Graph API + * + * @param string $byUser + * @param string $searchTerm + * + * @return void + * @throws GuzzleException + */ + public function userSearchesForFederatedUserUsingGraphApi(string $byUser, string $searchTerm): void { + $credentials = $this->getAdminOrUserCredentials($byUser); + $response = GraphHelper::searchFederatedUser( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $credentials['username'], + $credentials['password'], + $searchTerm, + ); + $this->featureContext->setResponse($response); + } + /** * @When user :user tries to get all users using the Graph API * @When user :user gets all users using the Graph API