Skip to content

Commit

Permalink
Add activation flow preference test
Browse files Browse the repository at this point in the history
Add a test tom for the prefered activation flow query params
  • Loading branch information
pablothedude committed Nov 4, 2024
1 parent c7f55cc commit 2ae8392
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
47 changes: 46 additions & 1 deletion stepup/tests/behat/features/bootstrap/SelfServiceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ public function iAmLoggedInIntoTheSelfServicePortalAs($userName)
$this->minkContext->assertPageContainsText('Registration Portal');
}


/**
* @Given /^I log into the selfservice portal as "([^"]*)" with activation preference "([^"]*)"$/
*/
public function ilogIntoTheSelfServicePortalAsWithPreference($userName, $preference)
{
// We visit the Self Service location url
$this->minkContext->visit($this->selfServiceUrl.'?activate='.$preference);
$this->authContext->authenticateWithIdentityProviderFor($userName);
$this->authContext->passTroughGatewaySsoAssertionConsumerService();
$this->iSwitchLocaleTo('English');
$this->minkContext->assertPageContainsText('Registration Portal');
}

/**
* @When I register a new :tokenType token
*/
Expand Down Expand Up @@ -214,10 +228,41 @@ public function iTryToSelfVetANewYubikeyTokenWithMySMSToken()

}

/**
* @When I verify my e-mail address
*/
public function verifyEmailAddress()
{
## And we should now be on the mail verification page
$this->minkContext->assertPageContainsText('Verify your e-mail');
$this->minkContext->assertPageContainsText('Check your inbox');

$this->minkContext->visit(
$this->getEmailVerificationUrl()
);
}

/**
* @When I activate my token
*/
public function activateToken()
{
$matches = [];
preg_match('#/second-factor/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/vetting-types#', $this->minkContext->getSession()->getPage()->getContent(), $matches);
if (empty($matches)) {
throw new Exception('Could not find a valid second factor verification id in the url');
}
$href = reset($matches);

$this->minkContext->getSession()
->getPage()
->find('css', '[href="'.$href.'"]')->click();
}

/**
* @When I verify my e-mail address and choose the :vettingType vetting type
*/
public function verifyEmailAddress(string $vettingType)
public function verifyEmailAddressAndChooseVettingType(string $vettingType)
{
## And we should now be on the mail verification page
$this->minkContext->assertPageContainsText('Verify your e-mail');
Expand Down
20 changes: 20 additions & 0 deletions stepup/tests/behat/features/selfservice_activation_flow.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: A user manages his tokens in the SelfService portal
In order to use a second factor token
As a user
I must be able to manage my second factor tokens

Scenario: A user registers a Yubikey token in selfservice using RA vetting preference
Given I log into the selfservice portal as "joe-a4" with activation preference "ra"
When I register a new "Yubikey" token
And I verify my e-mail address
And I visit the "overview" page in the selfservice portal
And I activate my token
Then I should see "Activation code"

Scenario: A user registers a Yubikey token in selfservice using self vetting preference
Given I log into the selfservice portal as "joe-a5" with activation preference "self"
When I register a new "Yubikey" token
And I verify my e-mail address
And I visit the "overview" page in the selfservice portal
And I activate my token
Then I should see "Add recovery method"

0 comments on commit 2ae8392

Please sign in to comment.