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 deleting auth-app token #10814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions tests/acceptance/bootstrap/AuthAppContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function userdeletesAllCreatedAuthAppToken(string $user): 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());
}
}
}
9 changes: 9 additions & 0 deletions tests/acceptance/features/apiAuthApp/token.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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