Skip to content

Commit

Permalink
Update Assertion audience in mock Gateway
Browse files Browse the repository at this point in the history
When rollover is enabled, let the mock gateway update the assertion
audience to the new entity id. That way, the engineblock is able to
receive the assertion from the new entity
  • Loading branch information
MKodde committed Mar 13, 2024
1 parent 11578ad commit 1382d17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,22 @@ class MockStepupGateway
*/
private $gatewayConfiguration;

/**
* @var string
*/
private $sfoRolloverEntityId;

/**
* @param FunctionalTestingStepupGatewayMockConfiguration $gatewayConfiguration
* @throws \Exception
*/
public function __construct(
FunctionalTestingStepupGatewayMockConfiguration $gatewayConfiguration
FunctionalTestingStepupGatewayMockConfiguration $gatewayConfiguration,
$sfoRolloverEntityId
) {
$this->gatewayConfiguration = $gatewayConfiguration;
$this->currentTime = new DateTime();
$this->sfoRolloverEntityId = $sfoRolloverEntityId;
}

/**
Expand Down Expand Up @@ -337,7 +344,12 @@ private function createNewAssertion($nameId, $authnContextClassRef, $destination
$newNameId->setValue($nameId);
$newNameId->setFormat(Constants::NAMEID_UNSPECIFIED);
$newAssertion->setNameId($newNameId);
$newAssertion->setValidAudiences([$this->gatewayConfiguration->getServiceProviderEntityId()]);
$audiences = [$this->gatewayConfiguration->getServiceProviderEntityId()];
// If the entity id being updated, then set that new EntityId as the audience for this assertion
if ($this->sfoRolloverEntityId !== '') {
$audiences = [$this->sfoRolloverEntityId];
}
$newAssertion->setValidAudiences($audiences);
$this->addAuthenticationStatementTo($newAssertion, $authnContextClassRef);

return $newAssertion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ services:
class: OpenConext\EngineBlockFunctionalTestingBundle\Mock\MockStepupGateway
arguments:
- "@engineblock.functional_testing.fixture.stepup_gateway_mock"
- '%stepup.sfo.override_engine_entityid%'

0 comments on commit 1382d17

Please sign in to comment.