mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 20:29:54 -06:00
adding test for creating auth token for an app using cli
This commit is contained in:
@@ -68,7 +68,7 @@ class AuthAppContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given user :user has created app token with expiration time :expiration
|
||||
* @Given user :user has created app token with expiration time :expiration using the auth-app API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $expiration
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -431,6 +431,7 @@ default:
|
||||
contexts:
|
||||
- FeatureContext: *common_feature_context_params
|
||||
- AuthAppContext:
|
||||
- CliContext:
|
||||
|
||||
cliCommands:
|
||||
paths:
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
Feature: create auth token
|
||||
Feature: create auth-app token
|
||||
As a user
|
||||
I want to create App Tokens
|
||||
I want to create auth-app Tokens
|
||||
So that I can use 3rd party apps
|
||||
|
||||
Background:
|
||||
Given user "Alice" has been created with default attributes
|
||||
|
||||
|
||||
Scenario: user creates app token
|
||||
Scenario: user creates auth-app token
|
||||
When user "Alice" creates app token with expiration time "72h" using the auth-app API
|
||||
Then the HTTP status code should be "200"
|
||||
And the JSON data of the response should match
|
||||
@@ -22,7 +22,6 @@ Feature: create auth token
|
||||
],
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z0-9]{16}$"
|
||||
},
|
||||
"label": {
|
||||
@@ -34,8 +33,8 @@ Feature: create auth token
|
||||
|
||||
|
||||
Scenario: user lists app tokens
|
||||
Given user "Alice" has created app token with expiration time "72h"
|
||||
And user "Alice" has created app token with expiration time "2h"
|
||||
Given user "Alice" has created app token with expiration time "72h" using the auth-app API
|
||||
And user "Alice" has created app token with expiration time "72h" using the auth-app CLI
|
||||
When user "Alice" lists all created tokens using the auth-app API
|
||||
Then the HTTP status code should be "200"
|
||||
And the JSON data of the response should match
|
||||
@@ -46,22 +45,42 @@ Feature: create auth token
|
||||
"maxItems": 2,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"token",
|
||||
"expiration_date",
|
||||
"created_date",
|
||||
"label"
|
||||
],
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string",
|
||||
"pattern": "^\\$2a\\$11\\$[A-Za-z0-9./]{53}$"
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"token",
|
||||
"expiration_date",
|
||||
"created_date",
|
||||
"label"
|
||||
],
|
||||
"properties": {
|
||||
"token": {
|
||||
"pattern": "^\\$2a\\$11\\$[A-Za-z0-9./]{53}$"
|
||||
},
|
||||
"label": {
|
||||
"const": "Generated via API"
|
||||
}
|
||||
}
|
||||
},
|
||||
"label": {
|
||||
"const": "Generated via API"
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"token",
|
||||
"expiration_date",
|
||||
"created_date",
|
||||
"label"
|
||||
],
|
||||
"properties": {
|
||||
"token": {
|
||||
"pattern": "^\\$2a\\$11\\$[A-Za-z0-9./]{53}$"
|
||||
},
|
||||
"label": {
|
||||
"const": "Generated via CLI"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
16
tests/acceptance/features/cliCommands/authAppToken.feature
Normal file
16
tests/acceptance/features/cliCommands/authAppToken.feature
Normal file
@@ -0,0 +1,16 @@
|
||||
@env-config
|
||||
Feature: create auth-app token
|
||||
As an admin
|
||||
I want to create auth-app Tokens
|
||||
So that I can use 3rd party apps
|
||||
|
||||
|
||||
Scenario: creates auth-app token via CLI
|
||||
Given the following configs have been set:
|
||||
| config | value |
|
||||
| OCIS_ADD_RUN_SERVICES | auth-app |
|
||||
| PROXY_ENABLE_APP_AUTH | true |
|
||||
And user "Alice" has been created with default attributes
|
||||
When the administrator creates app token for user "Alice" with expiration time "72h" using the auth-app CLI
|
||||
Then the command should be successful
|
||||
And the command output should contain "App token created for Alice"
|
||||
Reference in New Issue
Block a user