From 9550754ace104909367abb06065223d963d996bc Mon Sep 17 00:00:00 2001 From: Bas Date: Fri, 1 Nov 2024 16:37:34 +0100 Subject: [PATCH] Add activation flow preference test Add a test tom for the preferred activation flow query params --- .../features/bootstrap/SelfServiceContext.php | 47 ++++++++++++++++++- .../selfservice_activation_flow.feature | 20 ++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 stepup/tests/behat/features/selfservice_activation_flow.feature diff --git a/stepup/tests/behat/features/bootstrap/SelfServiceContext.php b/stepup/tests/behat/features/bootstrap/SelfServiceContext.php index e591679..7b3fddc 100644 --- a/stepup/tests/behat/features/bootstrap/SelfServiceContext.php +++ b/stepup/tests/behat/features/bootstrap/SelfServiceContext.php @@ -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 */ @@ -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'); diff --git a/stepup/tests/behat/features/selfservice_activation_flow.feature b/stepup/tests/behat/features/selfservice_activation_flow.feature new file mode 100644 index 0000000..06e985d --- /dev/null +++ b/stepup/tests/behat/features/selfservice_activation_flow.feature @@ -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"