diff --git a/tests/acceptance/bootstrap/AuthAppContext.php b/tests/acceptance/bootstrap/AuthAppContext.php index cf9ea26b11f..5efe0b07a88 100644 --- a/tests/acceptance/bootstrap/AuthAppContext.php +++ b/tests/acceptance/bootstrap/AuthAppContext.php @@ -23,6 +23,7 @@ use Behat\Behat\Context\Context; use Behat\Behat\Hook\Scope\BeforeScenarioScope; use TestHelpers\BehatHelper; +use PHPUnit\Framework\Assert; use TestHelpers\AuthAppHelper; require_once 'bootstrap.php'; @@ -154,4 +155,29 @@ public function theAdministratorCreatesAppTokenForUserWithExpirationTimeViaAuthA ) ); } + + /** + * @When user :user deletes all created auth-app token + * + * @param string $user + * + * @return void + */ + public function userdeletesAllCreatedAuthAppToken(string $user): void { + $responses = AuthAppHelper::listAllAppAuthTokensForUser( + $this->featureContext->getBaseUrl(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getPasswordForUser($user), + ); + $responses = json_decode($responses->getBody()->getContents()); + foreach ($responses as $response) { + $deleteResponse = AuthAppHelper::deleteAppAuthToken( + $this->featureContext->getBaseUrl(), + $this->featureContext->getActualUsername($user), + $this->featureContext->getPasswordForUser($user), + $response->token + ); + $this->featureContext->pushToLastHttpStatusCodesArray((string)$deleteResponse->getStatusCode()); + } + } } diff --git a/tests/acceptance/features/apiAuthApp/token.feature b/tests/acceptance/features/apiAuthApp/token.feature index f3626ef4a90..ac1ec941688 100644 --- a/tests/acceptance/features/apiAuthApp/token.feature +++ b/tests/acceptance/features/apiAuthApp/token.feature @@ -129,3 +129,12 @@ Feature: create auth-app token } } """ + + @env-config + Scenario: user deletes auth-app token + Given the config "AUTH_APP_ENABLE_IMPERSONATION" has been set to "true" + And user "Alice" has created app token with expiration time "72h" using the auth-app API + And the administrator has created app token for user "Alice" 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" deletes all created auth-app token + Then the HTTP status code of responses on each endpoint should be "200, 200, 200" respectively \ No newline at end of file