Skip to content

Commit

Permalink
Enable sfo tests and create the adfs feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Aug 27, 2024
1 parent c506cc2 commit e16356e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
9 changes: 9 additions & 0 deletions stepup/tests/behat/features/adfs.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: As an institution that uses ADFS support on the second factor only feature
In order to do ADFS second factor authentications
I must be able to successfully authenticate with my second factor tokens

Scenario: A user logs in using ADFS parameters
Given a service provider configured for second-factor-only
When I visit the ADFS service provider
And I verify the "yubikey" second factor
Then I am logged on the service provider
32 changes: 29 additions & 3 deletions stepup/tests/behat/features/bootstrap/SecondFactorAuthContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SecondFactorAuthContext implements Context
const SSO_SP = 'default-sp';
const SFO_SP = 'second-sp';
const TEST_NAMEID = 'urn:collab:person:institution-a.example.com:jane-a1';
const TEST_NAMEID_ADFS = 'urn:collab:person:dev.openconext.local:admin';

/**
* @var \Behat\MinkExtension\Context\MinkContext
Expand Down Expand Up @@ -95,11 +96,34 @@ public function visitServiceProvider()
$this->minkContext->fillField('idp', $this->activeIdp);
$this->minkContext->fillField('sp', $this->activeSp);
$this->minkContext->fillField('loa', $this->requiredLoa);
$this->minkContext->uncheckOption('emulateadfs');

if ($this->activeIdp === self::SFO_IDP) {
$this->minkContext->fillField('subject', self::TEST_NAMEID);
}
$this->minkContext->pressButton('Login');
if ($this->activeIdp === self::SFO_IDP) {
$this->minkContext->pressButton('Submit');
}
}

/**
* @When I visit the ADFS service provider
*/
public function visitAdfsServiceProvider()
{
$this->minkContext->visit($this->spTestUrl);
$this->minkContext->fillField('idp', $this->activeIdp);
$this->minkContext->selectOption('sp', $this->activeSp);
$this->minkContext->fillField('loa', $this->requiredLoa);
$this->minkContext->selectOption('ssobinding', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST');
$this->minkContext->checkOption('emulateadfs');

if ($this->activeIdp === self::SFO_IDP) {
$this->minkContext->fillField('subject', self::TEST_NAMEID_ADFS);
}
$this->minkContext->pressButton('Login');
$this->minkContext->pressButton('Yes, continue');
}

private function fillField($session, $field, $value)
Expand Down Expand Up @@ -145,7 +169,6 @@ public function verifySpecifiedSecondFactor($tokenType, $smsChallenge = null)
$tokenType
)
);
break;
}
}

Expand Down Expand Up @@ -216,8 +239,11 @@ public function authenticateUserInDummyGsspApplication()

public function authenticateUserYubikeyInGateway()
{
$this->minkContext->assertPageAddress('https://gateway.dev.openconext.local/verify-second-factor/sso/yubikey');

try {
$this->minkContext->assertPageAddress('https://gateway.dev.openconext.local/verify-second-factor/sso/yubikey');
} catch (Exception $e) {
$this->minkContext->assertPageAddress('https://gateway.dev.openconext.local/verify-second-factor/sfo/yubikey');
}
// Give an OTP
$this->minkContext->fillField('gateway_verify_yubikey_otp_otp', 'ccccccdhgrbtucnfhrhltvfkchlnnrndcbnfnnljjdgf');
// Simulate the enter press the yubikey otp generator
Expand Down
2 changes: 0 additions & 2 deletions stepup/tests/behat/features/sfo.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@SKIP
# Skipped awaiting a fix of the SSP, allowing for SFO authentications
Feature: A user authenticates with a service provider configured for second-factor-only
In order to login on a service provider
As a user
Expand Down
2 changes: 1 addition & 1 deletion stepup/tests/behat/fixtures/middleware-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"entity_id": "https://ssp.dev.openconext.local/simplesaml/module.php/saml/sp/metadata.php/second-sp",
"public_key": "MIIECTCCAnECFCUUC/wBq6SyLyGi8sMZl2bB0cFmMA0GCSqGSIb3DQEBCwUAMEExFjAUBgNVBAMMDXNpbXBsZXNhbWwgU1AxJzAlBgNVBAoMHkRldmVsb3BtZW50IERvY2tlciBlbnZpcm9ubWVudDAeFw0yMzA1MjUwOTMzMTZaFw0yODA1MjMwOTMzMTZaMEExFjAUBgNVBAMMDXNpbXBsZXNhbWw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h/RqaACMGdqhq93kzjy/FIzJvId3gcrUbK3NsFCVf5bXc32TkalocvEyZ4Id81IUcTi6RepEA=",
"acs": [
"https://ssp.dev.openconext.local/simplesaml/module.php/saml/sp/saml2-acs.php/second-sp"
"https://ssp.dev.openconext.local/simplesaml/module.php/debugsp/acs/second-sp"
],
"loa": {
"__default__": "http://dev.openconext.local/assurance/loa1"
Expand Down

0 comments on commit e16356e

Please sign in to comment.