adding test for creating auth token for an app using cli

This commit is contained in:
Niraj Acharya
2024-12-24 09:56:07 +05:45
parent 9a1015839b
commit 558839faa6
5 changed files with 96 additions and 21 deletions
+39
View File
@@ -121,6 +121,45 @@ class CliContext implements Context {
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}
/**
* @When the administrator creates app token for user :user with expiration time :expirationTime using the auth-app CLI
*
* @param string $user
* @param string $expirationTime
*
* @return void
*/
public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void {
$user = $this->featureContext->getActualUserName($user);
$command = "auth-app create --user-name=$user --expiration=$expirationTime";
$body = [
"command" => $command
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}
/**
* @Given user :user has created app token with expiration time :expirationTime using the auth-app CLI
*
* @param string $user
* @param string $expirationTime
*
* @return void
*/
public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void {
$user = $this->featureContext->getActualUserName($user);
$command = "auth-app create --user-name=$user --expiration=$expirationTime";
$body = [
"command" => $command
];
$response = CliHelper::runCommand($body);
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
Assert::assertSame("OK", $jsonResponse["status"]);
Assert::assertSame(0, $jsonResponse["exitCode"], "Expected exit code to be 0, but got " . $jsonResponse["exitCode"]);
}
/**
* @When the administrator removes all the file versions using the CLI