Skip to content

Commit f556408

Browse files
committed
Add a test for self vetting a token after SAT
OpenConext/Stepup-SelfService#466
1 parent 53497e1 commit f556408

File tree

3 files changed

+82
-104
lines changed

3 files changed

+82
-104
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,4 +440,14 @@ private function vetGsspToken($identityData)
440440
$this->connectToApi('ra', 'secret');
441441
$this->apiContext->iRequest('POST', '/command');
442442
}
443+
444+
/**
445+
* @When die printing content
446+
*/
447+
public function diePrintingContent()
448+
{
449+
echo $this->minkContext->getSession()->getCurrentUrl();
450+
echo $this->minkContext->getSession()->getPage()->getContent();
451+
die;
452+
}
443453
}

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

Lines changed: 27 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,25 @@ public function iAmLoggedInIntoTheSelfServicePortalAs($userName)
9999
}
100100

101101

102+
/**
103+
* @Given /^I log in again into selfservice$/
104+
*/
105+
public function loginAgainIntoSelfService()
106+
{
107+
// We visit the Self Service location url
108+
$this->minkContext->visit($this->selfServiceUrl);
109+
$this->minkContext->pressButton('Sign out');
110+
111+
$this->minkContext->visit($this->selfServiceUrl);
112+
$this->minkContext->pressButton('Yes, continue');
113+
// Pass through Gateway (already authenticated)
114+
$this->minkContext->pressButton('Submit');
115+
116+
$this->iSwitchLocaleTo('English');
117+
$this->minkContext->assertPageContainsText('Registration Portal');
118+
}
119+
120+
102121
/**
103122
* @Given /^I log into the selfservice portal as "([^"]*)" with activation preference "([^"]*)"$/
104123
*/
@@ -117,7 +136,7 @@ public function ilogIntoTheSelfServicePortalAsWithPreference($userName, $prefere
117136
*/
118137
public function registerNewToken(string $tokenType)
119138
{
120-
$this->minkContext->assertPageAddress('/registration/select-token');
139+
$this->minkContext->visit('/registration/select-token');
121140

122141
switch ($tokenType) {
123142
case 'Yubikey':
@@ -173,79 +192,6 @@ public function registerNewToken(string $tokenType)
173192
}
174193
}
175194

176-
/**
177-
* @When I self-vet a new SMS token with my Yubikey token
178-
179-
*/
180-
public function selfVetNewSmsToken()
181-
{
182-
$this->minkContext->visit($this->selfServiceUrl);
183-
$this->minkContext->assertPageAddress('/overview');
184-
185-
$this->minkContext->assertPageContainsText('The following tokens are registered for your account');
186-
$this->minkContext->assertPageContainsText('Yubikey');
187-
188-
$this->minkContext->visit('/registration/select-token');
189-
190-
// Select the sms second factor type
191-
$this->minkContext->getSession()
192-
->getPage()
193-
->find('css', '[href="/registration/sms/send-challenge"]')->click();
194-
$this->minkContext->assertPageAddress('/registration/sms/send-challenge');
195-
196-
// Start registration
197-
$this->minkContext->assertPageContainsText('Send SMS code');
198-
$this->minkContext->fillField('ss_send_sms_challenge_subscriber', '612345678');
199-
$this->minkContext->pressButton('Send code');
200-
201-
$this->minkContext->assertPageContainsText('Enter the code that was sent to your phone');
202-
$this->minkContext->fillField('ss_verify_sms_challenge_challenge', '999');
203-
$this->minkContext->pressButton('Verify');
204-
205-
$this->minkContext->assertPageContainsText('Verify your e-mail');
206-
$this->minkContext->assertPageContainsText('Check your inbox');
207-
$this->minkContext->visit(
208-
$this->getEmailVerificationUrl()
209-
);
210-
// Now we should be on the choose vetting page
211-
$this->minkContext->assertPageContainsText('Use your existing token');
212-
$page = $this->minkContext->getSession()->getPage();
213-
$form = $page->find('css', 'form[action$="self-vet"]');
214-
$form->submit();
215-
$this->minkContext->pressButton('Yes, continue');
216-
$this->minkContext->pressButton('Submit');
217-
$this->authContext->authenticateUserYubikeyInGateway();
218-
}
219-
220-
/**
221-
* @Given /^I try to self\-vet a new Yubikey token with my SMS token$/
222-
*/
223-
public function iTryToSelfVetANewYubikeyTokenWithMySMSToken()
224-
{
225-
$this->minkContext->visit($this->selfServiceUrl);
226-
$this->minkContext->assertPageAddress('/overview');
227-
228-
$this->minkContext->assertPageContainsText('The following tokens are registered for your account');
229-
$this->minkContext->assertPageContainsText('SMS');
230-
$this->minkContext->assertPageContainsText('+31 (0) 612345678');
231-
232-
$this->minkContext->visit('/registration/select-token');
233-
234-
// Select the sms second factor type
235-
$this->minkContext->getSession()
236-
->getPage()
237-
->find('css', '[href="/registration/yubikey/prove-possession"]')->click();
238-
$this->minkContext->assertPageAddress('/registration/yubikey/prove-possession');
239-
240-
// Start registration
241-
$this->minkContext->assertPageContainsText('Link your YubiKey');
242-
$this->minkContext->fillField('ss_prove_yubikey_possession_otp', 'ccccccdhgrbtfddefpkffhkkukbgfcdilhiltrrncmig');
243-
$page = $this->minkContext->getSession()->getPage();
244-
$form = $page->find('css', 'form[name="ss_prove_yubikey_possession"]');
245-
$form->submit();
246-
247-
}
248-
249195
/**
250196
* @When I verify my e-mail address
251197
*/
@@ -325,23 +271,7 @@ public function verifyEmailAddressAndChooseVettingType(string $vettingType)
325271
$this->iChooseToActivateMyTokenUsingSat();
326272
break;
327273
case "Self vetting":
328-
// Select the sms second factor type
329-
$this->minkContext->getSession()
330-
->getPage()
331-
->find('css', '[href="/registration/sms/send-challenge"]')->click();
332-
$this->minkContext->assertPageAddress('/registration/sms/send-challenge');
333-
334-
// Start registration
335-
$this->minkContext->assertPageContainsText('Send SMS code');
336-
$this->minkContext->fillField('ss_send_sms_challenge_subscriber', '612345678');
337-
$this->minkContext->pressButton('Send code');
338-
339-
$this->minkContext->assertPageContainsText('Enter the code that was sent to your phone');
340-
$this->minkContext->fillField('ss_verify_sms_challenge_challenge', '999');
341-
$this->minkContext->pressButton('Verify');
342-
343-
344-
$this->iChooseToActivateMyTokenUsingSat();
274+
$this->iChooseToVetMyTokenMyself();
345275
break;
346276
default:
347277
throw new Exception(sprintf('Vetting type "%s" is not supported', $vettingType));
@@ -435,6 +365,12 @@ public function iChooseToActivateMyTokenUsingSAT()
435365
$this->minkContext->pressButton('sat-button');
436366
}
437367

368+
public function iChooseToVetMyTokenMyself()
369+
{
370+
$this->minkContext->assertPageContainsText('Use your existing token');
371+
$this->minkContext->pressButton('self-vet-button');
372+
}
373+
438374
/**
439375
* @Then I can add an :recoveryTokenType recovery token using :tokenType
440376
*/

stepup/tests/behat/features/self_vet.feature

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Feature: A user manages his tokens in the selfservice portal
2020
"show_raa_contact_information": true,
2121
"verify_email": true,
2222
"self_vet": true,
23+
"allow_self_asserted_tokens": true,
2324
"allowed_second_factors": [],
2425
"number_of_tokens_per_identity": 3
2526
}
@@ -30,18 +31,49 @@ Feature: A user manages his tokens in the selfservice portal
3031

3132
Scenario: A user self vets a token in selfservice
3233
Given a user "joe-a2" identified by "urn:collab:person:institution-a.example.com:joe-a2" from institution "institution-a.example.com" with UUID "00000000-0000-4000-a000-000000000001"
33-
And the user "urn:collab:person:institution-a.example.com:joe-a2" has a vetted "yubikey" with identifier "00000001"
34-
And I am logged in into the selfservice portal as "joe-a2"
35-
And I self-vet a new SMS token with my Yubikey token
36-
And I visit the "overview" page in the selfservice portal
34+
And the user "urn:collab:person:institution-a.example.com:joe-a2" has a vetted "yubikey" with identifier "00000001"
35+
When I am logged in into the selfservice portal as "joe-a2"
36+
And I register a new "SMS" token
37+
And I verify my e-mail address and choose the "Self vetting" vetting type
38+
And I visit the "overview" page in the selfservice portal
3739
Then I should see "The following tokens are registered for your account."
38-
And I should see "SMS"
39-
And I should see "Yubikey"
40+
And I should see "SMS"
41+
And I should see "Yubikey"
4042

41-
Scenario: A user needs a suitable token to self vet
42-
Given a user "joe-a3" identified by "urn:collab:person:institution-a.example.com:joe-a3" from institution "institution-a.example.com"
43-
And the user "urn:collab:person:institution-a.example.com:joe-a3" has a vetted "sms" with identifier "+31 (0) 612345678"
44-
And I am logged in into the selfservice portal as "joe-a3"
45-
And I try to self-vet a new Yubikey token with my SMS token
46-
# The self vet option is not available on the token vetting page
47-
Then I should not see "Use your existing token"
43+
Scenario: A user can self vet a token with a lower LOA
44+
Given a user "joe-a2" identified by "urn:collab:person:institution-a.example.com:joe-a3" from institution "institution-a.example.com" with UUID "00000000-0000-4000-a000-000000000002"
45+
And the user "urn:collab:person:institution-a.example.com:joe-a3" has a vetted "sms" with identifier "+31 (0) 612345678"
46+
When I am logged in into the selfservice portal as "joe-a3"
47+
And I register a new "Yubikey" token
48+
And I verify my e-mail address
49+
And I visit the "overview" page in the selfservice portal
50+
And I activate my token
51+
Then I should see "Activation code"
52+
53+
Scenario: A user can self vet a token with the same LOA
54+
Given a user "joe-a4" identified by "urn:collab:person:institution-a.example.com:joe-a4" from institution "institution-a.example.com" with UUID "00000000-0000-4000-a000-000000000003"
55+
And the user "urn:collab:person:institution-a.example.com:joe-a4" has a vetted "demo-gssp" with identifier "gssp-identifier123"
56+
When I am logged in into the selfservice portal as "joe-a4"
57+
And I register a new "Yubikey" token
58+
And I verify my e-mail address and choose the "Self vetting" vetting type
59+
And I visit the "overview" page in the selfservice portal
60+
Then I should see "The following tokens are registered for your account."
61+
And I should see "Demo GSSP"
62+
And I should see "Yubikey"
63+
64+
65+
Scenario: A user can self vet a token after registering a token using SAT
66+
Given I am logged in into the selfservice portal as "joe-a5"
67+
And I register a new "Demo GSSP" token
68+
And I verify my e-mail address and choose the "Self Asserted Token registration" vetting type
69+
And I vet my "Demo GSSP" second factor in selfservice
70+
When I receive the following attributes for "joe-a5" from the IdP:
71+
| name | value |
72+
| urn:mace:dir:attribute-def:eduPersonEntitlement | urn:mace:surf.nl:surfsecureid:activation:self |
73+
And I log in again into selfservice
74+
And I register a new "Yubikey" token
75+
And I verify my e-mail address and choose the "Self vetting" vetting type
76+
And I visit the "overview" page in the selfservice portal
77+
Then I should see "The following tokens are registered for your account."
78+
And I should see "Demo GSSP"
79+
And I should see "Yubikey"

0 commit comments

Comments
 (0)