adding test for create token for non-existing user and deleting token by a different user
This commit is contained in:
1 parent
7146fefb34
commit
ac5c136f04
3 files changed
+58
-1
No files matched your search
@@ -33,6 +33,7 @@ require_once 'bootstrap.php';
|
||||
*/
|
||||
class AuthAppContext implements Context {
|
||||
private FeatureContext $featureContext;
|
||||
private string $lastCreatedToken;
|
||||
|
||||
/**
|
||||
* @BeforeScenario
|
||||
@@ -83,6 +84,7 @@ class AuthAppContext implements Context {
|
||||
["expiry" => $expiration]
|
||||
);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
$this->lastCreatedToken = json_decode($response->getBody()->getContents())->token;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,6 +133,7 @@ class AuthAppContext implements Context {
|
||||
. "HTTP status code 200 is not the expected value " . $response->getStatusCode(),
|
||||
$response
|
||||
);
|
||||
$this->lastCreatedToken = json_decode($response->getBody()->getContents())->token;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,4 +240,24 @@ class AuthAppContext implements Context {
|
||||
)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @When user :user tries to delete the last created auth-app token using the auth-app API
|
||||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userTriesToDeleteLastCreatedAuthAppTokensUsingTheAuthAppApi(string $user): void {
|
||||
$baseUrl = $this->featureContext->getBaseUrl();
|
||||
$user = $this->featureContext->getActualUsername($user);
|
||||
$password = $this->featureContext->getPasswordForUser($user);
|
||||
$deleteResponse = AuthAppHelper::deleteAppAuthToken(
|
||||
$baseUrl,
|
||||
$user,
|
||||
$password,
|
||||
$this->lastCreatedToken,
|
||||
);
|
||||
$this->featureContext->setResponse($deleteResponse);
|
||||
$this->featureContext->pushToLastHttpStatusCodesArray((string)$deleteResponse->getStatusCode());
|
||||
}
|
||||
}
|
||||
@@ -342,5 +342,13 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
||||
- [apiOcm/deleteFederatedConnections.feature:123](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/deleteFederatedConnections.feature#L123)
|
||||
- [apiOcm/deleteFederatedConnections.feature:130](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/deleteFederatedConnections.feature#L130)
|
||||
|
||||
#### [server returns status code 500 when creating token for non-existent user (Impersonation)](https://github.com/owncloud/ocis/issues/10815)
|
||||
- [apiAuthApp/token.feature:250](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiAuthApp/token.feature#L250)
|
||||
- [apiAuthApp/token.feature:256](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiAuthApp/token.feature#L256)
|
||||
|
||||
#### [Server returns status code 500 when deleting auth-app token of a different user](https://github.com/owncloud/ocis/issues/10921)
|
||||
- [apiAuthApp/token.feature:263](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiAuthApp/token.feature#L263)
|
||||
- [apiAuthApp/token.feature:269](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiAuthApp/token.feature#L269)
|
||||
|
||||
Note: always have an empty line at the end of this file.
|
||||
The bash script that processes this file requires that the last line has a newline on the end.
|
||||
@@ -244,4 +244,30 @@ Feature: create auth-app token
|
||||
And the content in the response should include the following content:
|
||||
"""
|
||||
error parsing expiry. Use e.g. 30m or 72h
|
||||
"""
|
||||
"""
|
||||
|
||||
@env-config @issue-10815
|
||||
Scenario: try to create auth-app token for non-existing user
|
||||
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true"
|
||||
When user "Admin" creates auth-app token for user "Brian" with expiration time "72h" using the auth-app API
|
||||
Then the HTTP status code should be "403"
|
||||
|
||||
@env-config @issue-10815
|
||||
Scenario: try to create auth-app token for non-existing user with impersonation enabled
|
||||
Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true"
|
||||
And user "Admin" has created auth-app token for user "Alice" with expiration time "72h" using the auth-app API
|
||||
When user "Admin" tries to delete the last created auth-app token using the auth-app API
|
||||
Then the HTTP status code should be "403"
|
||||
|
||||
@issue-10921
|
||||
Scenario: try to delete auth-app token of a normal user by admin user
|
||||
Given user "Alice" has created auth-app token with expiration time "72h" using the auth-app API
|
||||
When user "Admin" tries to delete the last created auth-app token using the auth-app API
|
||||
Then the HTTP status code should be "403"
|
||||
|
||||
@issue-10921
|
||||
Scenario: try to delete auth-app token of a user by another non-admin user
|
||||
Given user "Brian" has been created with default attributes
|
||||
And user "Brian" has created auth-app token with expiration time "72h" using the auth-app API
|
||||
When user "Admin" tries to delete the last created auth-app token using the auth-app API
|
||||
Then the HTTP status code should be "403"
|
||||
Reference in new issue
Block a user