adding test for trying to create auth app-token for other user without impersonation env

This commit is contained in:
Niraj Acharya
2025-02-10 12:56:14 +05:45
parent 84b9cbf2b8
commit b5e5d9414c
4 changed files with 32 additions and 19 deletions

View File

@@ -49,7 +49,7 @@ class AuthAppContext implements Context {
}
/**
* @When user :user creates app token with expiration time :expiration using the auth-app API
* @When user :user creates auth-app token with expiration time :expiration using the auth-app API
*
* @param string $user
* @param string $expiration
@@ -68,7 +68,7 @@ class AuthAppContext implements Context {
}
/**
* @Given user :user has created app token with expiration time :expiration using the auth-app API
* @Given user :user has created auth-app token with expiration time :expiration using the auth-app API
*
* @param string $user
* @param string $expiration
@@ -103,21 +103,23 @@ class AuthAppContext implements Context {
}
/**
* @Given the administrator has created app token for user :impersonatedUser with expiration time :expiration using the auth-app API
* @Given user :user has created auth-app token for user :impersonatedUser with expiration time :expiration using the auth-app API
*
* @param string $user
* @param string $impersonatedUser
* @param string $expiration
*
* @return void
*/
public function theAdministratorHasCreatedAppTokenWithExpirationTimeImpersonatingUserUsingTheAuthAppApi(
public function userHasCreatedAppTokenWithExpirationTimeImpersonatingUserUsingTheAuthAppApi(
string $user,
string $impersonatedUser,
string $expiration,
): void {
$response = AuthAppHelper::createAppAuthToken(
$this->featureContext->getBaseUrl(),
$this->featureContext->getAdminUsername(),
$this->featureContext->getAdminPassword(),
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
[
"expiry" => $expiration,
"userName" => $this->featureContext->getActualUsername($impersonatedUser)
@@ -132,22 +134,24 @@ class AuthAppContext implements Context {
}
/**
* @When the administrator creates app token for user :impersonatedUser with expiration time :expiration using the auth-app API
* @When /^user "([^"]*)" (?:creates|tries to create) auth-app token for user "([^"]*)" with expiration time "([^"]*)" using the auth-app API$/
*
* @param string $user
* @param string $impersonatedUser
* @param string $expiration
*
* @return void
*/
public function theAdministratorCreatesAppTokenForUserWithExpirationTimeViaAuthAppApi(
public function theUserCreatesAppTokenForUserWithExpirationTimeViaAuthAppApi(
string $user,
string $impersonatedUser,
string $expiration,
): void {
$this->featureContext->setResponse(
AuthAppHelper::createAppAuthToken(
$this->featureContext->getBaseUrl(),
$this->featureContext->getAdminUsername(),
$this->featureContext->getAdminPassword(),
$this->featureContext->getActualUsername($user),
$this->featureContext->getPasswordForUser($user),
[
"expiry" => $expiration,
"userName" => $this->featureContext->getActualUsername($impersonatedUser)