Skip to content

Commit bc2c6b7

Browse files
committed
Test recovery token removal
1 parent fad1aff commit bc2c6b7

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

stepup/tests/behat/features/bootstrap/SelfServiceContext.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,35 @@ public function numberOfTokensRegistered(int $nofRecoveryTokens)
460460
}
461461
}
462462

463+
464+
/**
465+
* @When I remove the :recoveryTokenType recovery token
466+
*/
467+
public function removeRecoveryToken(string $recoveryTokenType)
468+
{
469+
$this->minkContext->visit('/overview');
470+
switch ($recoveryTokenType){
471+
case 'SMS':
472+
$page = $this->minkContext->getMink()->getSession()->getPage();
473+
$deleteButtons = $page->findAll('css', 'a[data-test_revoketokentype="sms"]');
474+
475+
if (empty($deleteButtons)) {
476+
throw new Exception('No recovery token remove button(s) found on the page');
477+
}
478+
$deleteButtons[0]->click();
479+
$this->minkContext->assertPageContainsText('Remove recovery token');
480+
$this->minkContext->assertPageContainsText('Recovery phone number');
481+
482+
$this->minkContext->pressButton('Remove');
483+
484+
$this->minkContext->assertPageAddress('/overview');
485+
$this->minkContext->assertPageContainsText('Your recovery token was removed successfully');
486+
break;
487+
default:
488+
throw new Exception(sprintf('Recovery token type %s is not supported', $recoveryTokenType));
489+
}
490+
}
491+
463492
private function performYubikeyAuthentication()
464493
{
465494
$this->minkContext->fillField('gateway_verify_yubikey_otp_otp', 'ccccccdhgrbtfddefpkffhkkukbgfcdilhiltrrncmig');

stepup/tests/behat/features/selfservice_sat.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@ Feature: A user manages his tokens in the SelfService portal
3131
And I vet my "Yubikey" second factor in selfservice
3232
Then I can add an "SMS" recovery token using "Yubikey"
3333
And "2" recovery tokens are activated
34+
35+
Scenario: A user can remove a recovery token
36+
Given I am logged in into the selfservice portal as "user-a5"
37+
When I register a new "Yubikey" token
38+
And I verify my e-mail address and choose the "Self Asserted Token registration" vetting type
39+
And I vet my "Yubikey" second factor in selfservice
40+
Then I can add an "SMS" recovery token using "Yubikey"
41+
And "2" recovery tokens are activated
42+
When I remove the "SMS" recovery token
43+
Then "1" recovery tokens are activated

0 commit comments

Comments
 (0)