Skip to content

Commit 19003c2

Browse files
committed
Add key rollover test
Prior to this change, there was no specific test that asserted using the key:rollover URL results in a response that is signed with the rollover certificate. This change asserts the response contains the rollover certificate. Resolves #1759
1 parent 4e1fbba commit 19003c2

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

library/EngineBlock/Application/FunctionalTestDiContainer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public function getEncryptionKeysConfiguration()
7979
'publicFile' => '/config/engine/engineblock.crt',
8080
'privateFile' => $basePath . '/ci/qa-config/files/engineblock.pem',
8181
],
82+
'rollover' => [
83+
'publicFile' => $basePath . '/src/OpenConext/EngineBlockFunctionalTestingBundle/Resources/keys/rolled-over.crt',
84+
'privateFile' => $basePath . '/src/OpenConext/EngineBlockFunctionalTestingBundle/Resources/keys/rolled-over.key',
85+
],
8286
];
8387
}
8488
}

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/Context/EngineBlockContext.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) Due to all integration specific features
4848
* @SuppressWarnings(PHPMD.ExcessivePublicCount) Both set up and tasks can be a lot...
4949
* @SuppressWarnings(PHPMD.TooManyFields) Both set up and tasks can be a lot...
50+
* @SuppressWarnings(PHPMD.ExcessiveClassLength) Both set up and tasks can be a lot...
5051
*/
5152
class EngineBlockContext extends AbstractSubContext
5253
{
@@ -323,6 +324,20 @@ public function anIdpInitiatedSingleSignOnForSpIsTriggeredByIdPWithInvalidSignin
323324
);
324325
}
325326

327+
/**
328+
* @Given /^An IdP initiated Single Sign on for SP "([^"]*)" is triggered by IdP "([^"]*)" and specifies the "([^"]*)" signing key$/
329+
*/
330+
public function anIdpInitiatedSingleSignOnForSpIsTriggeredByIdPWithNamedSigningKey($spName, $idpName, $keyId)
331+
{
332+
$mockSp = $this->mockSpRegistry->get($spName);
333+
$mockIdP = $this->mockIdpRegistry->get($idpName);
334+
335+
$mink = $this->getMinkContext();
336+
$mink->visit(
337+
$this->engineBlock->unsolicitedLocation($mockIdP->entityId(), $mockSp->entityId(), $keyId)
338+
);
339+
}
340+
326341
/**
327342
* @Given /^An IdP initiated Single Sign on for SP "([^"]*)" is incorrectly triggered by IdP "([^"]*)"$/
328343
*/

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/Context/MinkContext.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public function theResponseShouldMatchXpath($xpath)
7070
$xpathObj->registerNamespace('md', 'urn:oasis:names:tc:SAML:2.0:metadata');
7171
$xpathObj->registerNamespace('mdui', Common::NS);
7272
$xpathObj->registerNamespace('shibmd', Scope::NS);
73+
$xpathObj->registerNamespace('samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
74+
$xpathObj->registerNamespace('saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
7375
$nodeList = $xpathObj->query($xpath);
7476

7577
if (!$nodeList || $nodeList->length === 0) {
@@ -205,6 +207,8 @@ public function theResponseShouldNotMatchXpath($xpath)
205207
$xpathObj->registerNamespace('ds', XMLSecurityDSig::XMLDSIGNS);
206208
$xpathObj->registerNamespace('md', 'urn:oasis:names:tc:SAML:2.0:metadata');
207209
$xpathObj->registerNamespace('mdui', Common::NS);
210+
$xpathObj->registerNamespace('samlp', 'urn:oasis:names:tc:SAML:2.0:protocol');
211+
$xpathObj->registerNamespace('saml', 'urn:oasis:names:tc:SAML:2.0:assertion');
208212
$nodeList = $xpathObj->query($xpath);
209213

210214
if ($nodeList && $nodeList->length > 0) {

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/UnsolicitedSingleSignOn.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ Feature:
2525
And I give my consent
2626
And I pass through EngineBlock
2727
Then the url should match "functional-testing/Dummy%20SP/acs"
28+
And the response should match xpath '//ds:X509Certificate[starts-with(.,"MIIDuDCCAqCgAwIBAgIJAPdqJ9JQKN6vMA0GCSqGSIb3DQEBBQUAMEYxDzANBgNVBAMT")]'
29+
30+
Scenario: An IdP initiates a login with the rollover signing key
31+
When An IdP initiated Single Sign on for SP "Dummy SP" is triggered by IdP "Dummy IdP" and specifies the "rollover" signing key
32+
And I pass through EngineBlock
33+
And I pass through the IdP
34+
And I give my consent
35+
And I pass through EngineBlock
36+
Then the url should match "functional-testing/Dummy%20SP/acs"
37+
# See src/OpenConext/EngineBlockFunctionalTestingBundle/Resources/keys/rolled-over.crt
38+
And the response should match xpath '//ds:X509Certificate[starts-with(.,"MIIDhTCCAm2gAwIBAgIJALJlbT5u9cXzMA0GCSqG")]'
2839

2940
# Should result in a generic 500 error, the logs specify the problem in greater detail.
3041
Scenario: An IdP initiates a login with an SP identity id query parameter

0 commit comments

Comments
 (0)