[tests-only][full-ci]Extend tests related to assign role (#5584)

* Extend assign role test coverage

* Check app Entity has been set or not
This commit is contained in:
Amrita
2023-03-03 09:17:34 +05:45
committed by GitHub
parent 8962038d6e
commit 4377754573
2 changed files with 42 additions and 14 deletions
@@ -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'],