From e836b2d1388fb24b8c97ec78bfbff334590e4b61 Mon Sep 17 00:00:00 2001 From: Prajwol Amatya <83579989+PrajwolAmatya@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:10:59 +0545 Subject: [PATCH] added test for getting details of a single group (#5760) addressed reviews updated steps with JSON drill-down functionality reviews addressed fixed linter error conflicts resolved fixed errors addressed reviews --- tests/TestHelpers/GraphHelper.php | 2 +- .../features/apiGraph/getGroup.feature | 26 +++++++++++++++++++ .../features/bootstrap/GraphContext.php | 22 ++++++++++++++++ .../coreApiCapabilities/capabilities.feature | 4 +-- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index 8ed3baf3bd..d2f1a9888e 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -31,7 +31,7 @@ class GraphHelper { * @return string */ public static function getUUIDv4Regex(): string { - return '[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}'; + return '[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}'; } /** diff --git a/tests/acceptance/features/apiGraph/getGroup.feature b/tests/acceptance/features/apiGraph/getGroup.feature index f75c466b15..e48c2ea2fe 100644 --- a/tests/acceptance/features/apiGraph/getGroup.feature +++ b/tests/acceptance/features/apiGraph/getGroup.feature @@ -105,3 +105,29 @@ Feature: get groups and their members When user "Brian" gets all the members information of group "tea-lover" using the Graph API Then the HTTP status code should be "401" And the last response should be an unauthorized response + + + Scenario: Get details of a group + Given group "tea-lover" has been created + When user "Alice" gets details of the group "tea-lover" using the Graph API + Then the HTTP status code should be "200" + And the JSON data of the response should match + """ + { + "type": "object", + "required": [ + "displayName", + "id" + ], + "properties": { + "displayName": { + "type": "string", + "enum": ["tea-lover"] + }, + "id": { + "type": "string", + "pattern": "^%group_id_pattern%$" + } + } + } + """ diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 8f3b376067..7d3aca3f2d 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -2081,4 +2081,26 @@ class GraphContext implements Context { . "\nExpected rolId for role '$role'' to be '" . $this->appEntity["appRoles"][$role] . "' but got '" . $response['appRoleId'] . "'" ); } + + /** + * @When user :user gets details of the group :groupName using the Graph API + * + * @param string $user + * @param string $groupName + * + * @return void + */ + public function userGetsDetailsOfTheGroupUsingTheGraphApi(string $user, string $groupName): void { + $credentials = $this->getAdminOrUserCredentials($user); + + $this->featureContext->setResponse( + GraphHelper::getGroup( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $credentials["username"], + $credentials["password"], + $groupName + ) + ); + } } diff --git a/tests/acceptance/features/coreApiCapabilities/capabilities.feature b/tests/acceptance/features/coreApiCapabilities/capabilities.feature index f1afe49697..74b1d191fa 100644 --- a/tests/acceptance/features/coreApiCapabilities/capabilities.feature +++ b/tests/acceptance/features/coreApiCapabilities/capabilities.feature @@ -9,7 +9,7 @@ Feature: capabilities When the administrator retrieves the capabilities using the capabilities API Then the OCS status code should be "100" And the HTTP status code should be "200" - And the JSON data of the response should match + And the ocs JSON data of the response should match """ { "type": "object", @@ -212,7 +212,7 @@ Feature: capabilities @smokeTest Scenario: getting default capabilities with admin user When the administrator retrieves the capabilities using the capabilities API - And the ocs JSON data of the response should match + Then the ocs JSON data of the response should match """ { "type": "object",