Added api test for changing app role of user

This commit is contained in:
Prarup Gurung
2023-05-23 15:11:52 +05:45
parent 77e86eda31
commit 8d06acf030
2 changed files with 81 additions and 0 deletions
@@ -2510,4 +2510,37 @@ class GraphContext implements Context {
. "\nExpected user '$user' to have no roles assigned but got '" . json_encode($jsonDecodedResponse) . "'"
);
}
/**
* @When user :user changes the role of user :ofUser to role :role using the Graph API
* @When user :user tries to change the role of user :ofUser to role :role using the Graph API
*
* @param string $user
* @param string $ofUser
* @param string $role
*
* @return void
*
* @throws GuzzleException
* @throws Exception
*/
public function userChangesTheRoleOfUserToRoleUsingTheGraphApi(string $user, string $ofUser, string $role): void {
$userId = $this->featureContext->getAttributeOfCreatedUser($ofUser, 'id') ?? $ofUser;
$credentials = $this->getAdminOrUserCredentials($user);
if (empty($this->appEntity)) {
$this->setApplicationEntity();
}
$this->featureContext->setResponse(
GraphHelper::assignRole(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials['username'],
$credentials['password'],
$this->appEntity["appRoles"][$role],
$this->appEntity["id"],
$userId
)
);
}
}