Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] adding test for trying to create auth app-token without expiry using cli #10988

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions tests/acceptance/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function theAdministratorChecksTheBackupConsistencyUsingTheCli(): void {

/**
* @When the administrator creates app token for user :user with expiration time :expirationTime using the auth-app CLI
* @When the administrator tries to create app token for user :user with expiration time :expirationTime using the auth-app CLI
*
* @param string $user
* @param string $expirationTime
Expand Down Expand Up @@ -286,19 +287,28 @@ public function theAdministratorRemovesTheVersionsOfFilesInSpaceUsingSpaceId(str
}

/**
* @Then the command should be successful
* @Then /^the command should be (successful|unsuccessful)$/
*
* @param string $successfulOrNot
*
* @return void
*/
public function theCommandShouldBeSuccessful(): void {
public function theCommandShouldBeSuccessful(string $successfulOrNot): void {
$response = $this->featureContext->getResponse();
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response);

$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);

Assert::assertSame("OK", $jsonResponse["status"]);
$expectedStatus = 'Ok';
$expectedExitCode = 0;
if ($successfulOrNot === "unsuccessful") {
$expectedStatus = "ERROR";
$expectedExitCode = 1;
}

Assert::assertSame($expectedStatus, $jsonResponse["status"]);
Assert::assertSame(
0,
$expectedExitCode,
$jsonResponse["exitCode"],
"Expected exit code to be 0, but got " . $jsonResponse["exitCode"]
);
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/features/cliCommands/authAppToken.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ Feature: create auth-app token
"maxItems": 0
}
"""


Scenario: try to creates auth-app token without expiry via CLI
When the administrator tries to create app token for user "Alice" with expiration time "" using the auth-app CLI
Then the command should be unsuccessful
And the command output should contain "time: invalid duration"