diff --git a/tests/acceptance/features/apiGraph/assignRole.feature b/tests/acceptance/features/apiGraph/assignRole.feature index bcd76e790..a352818ae 100644 --- a/tests/acceptance/features/apiGraph/assignRole.feature +++ b/tests/acceptance/features/apiGraph/assignRole.feature @@ -31,3 +31,17 @@ Feature: assign role | Space Admin | 401 | | User | 401 | | Guest | 401 | + + + Scenario Outline: assign role to the user with setting api and list role with graph api + Given user "Alice" has been created with default attributes and without skeleton files + And the administrator has given "Alice" the role "" using the settings api + When the administrator retrieves the assigned role of user "Alice" using the Graph API + Then the HTTP status code should be "200" + And the Graph API response should have the role "" + Examples: + | userRole | + | Admin | + | Space Admin | + | User | + | Guest | diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 64e62163f..4117f7399 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -1727,20 +1727,7 @@ class GraphContext implements Context { $userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?? $user; if (empty($this->appEntity)) { - $applicationEntity = ( - $this->featureContext->getJsonDecodedResponse( - GraphHelper::getApplications( - $this->featureContext->getBaseUrl(), - $this->featureContext->getStepLineRef(), - $this->featureContext->getAdminUsername(), - $this->featureContext->getAdminPassword(), - ) - ) - )['value'][0]; - $this->appEntity["id"] = $applicationEntity["id"]; - foreach ($applicationEntity["appRoles"] as $value) { - $this->appEntity["appRoles"][$value['displayName']] = $value['id']; - } + $this->setApplicationEntity(); } $response = GraphHelper::assignRole( @@ -1782,6 +1769,29 @@ class GraphContext implements Context { ); } + /** + * set application Entity in global variable + * + * @return void + * @throws GuzzleException + */ + public function setApplicationEntity(): void { + $applicationEntity = ( + $this->featureContext->getJsonDecodedResponse( + GraphHelper::getApplications( + $this->featureContext->getBaseUrl(), + $this->featureContext->getStepLineRef(), + $this->featureContext->getAdminUsername(), + $this->featureContext->getAdminPassword(), + ) + ) + )['value'][0]; + $this->appEntity["id"] = $applicationEntity["id"]; + foreach ($applicationEntity["appRoles"] as $value) { + $this->appEntity["appRoles"][$value['displayName']] = $value['id']; + } + } + /** * @Then /^the Graph API response should have the role "([^"]*)"$/ * @@ -1789,9 +1799,13 @@ class GraphContext implements Context { * * @return void * @throws Exception + * @throws GuzzleException */ public function theGraphApiResponseShouldHaveTheRole(string $role): void { $response = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['value'][0]; + if (empty($this->appEntity)) { + $this->setApplicationEntity(); + } Assert::assertEquals( $this->appEntity["appRoles"][$role], $response['appRoleId'],