public function test_get_all_attribute_statements() { $assertion = new Assertion(); $assertion->addItem(new AuthnStatement()); $assertion->addItem($attributeStatement1 = new AttributeStatement()); $assertion->addItem(new AuthnStatement()); $assertion->addItem($attributeStatement2 = new AttributeStatement()); $arr = $assertion->getAllAttributeStatements(); $this->assertCount(2, $arr); $this->assertSame($attributeStatement1, $arr[0]); $this->assertSame($attributeStatement2, $arr[1]); }
public function test_does_nothing_if_there_is_at_least_one_authn_statement() { $action = new HasAuthnStatementValidatorAction(TestHelper::getLoggerMock($this)); $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP); $context->getInboundContext()->setMessage($response = new Response()); $response->addAssertion($assertion = new Assertion()); $assertion->addItem(new AuthnStatement()); $action->execute($context); }
public function test_pass() { $now = 1000; $assertion = new Assertion(); $assertion->setSubject((new Subject())->addSubjectConfirmation((new SubjectConfirmation())->setSubjectConfirmationData((new SubjectConfirmationData())->setNotOnOrAfter(2000)))); $assertion->addItem((new AuthnStatement())->setSessionNotOnOrAfter(2000)); $assertion->setConditions((new Conditions())->setNotOnOrAfter(2000)->setNotBefore(900)); $validator = new AssertionTimeValidator(); $validator->validateTimeRestrictions($assertion, $now, 10); }
public function test_does_nothing_if_there_is_bearer_assertion() { $action = new HasBearerAssertionsValidatorAction(TestHelper::getLoggerMock($this)); $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP); $context->getInboundContext()->setMessage($response = new Response()); $response->addAssertion($assertion = new Assertion()); $assertion->addItem(new AuthnStatement()); $assertion->setSubject($subject = new Subject()); $subject->addSubjectConfirmation($subjectConfirmation = new SubjectConfirmation()); $subjectConfirmation->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER); $action->execute($context); }
public function test_does_nothing_if_recipient_matches_own_acs_service_location() { $action = new RecipientValidatorAction($loggerMock = TestHelper::getLoggerMock($this), $endpointResolver = TestHelper::getEndpointResolverMock($this)); $assertionContext = TestHelper::getAssertionContext($assertion = new Assertion()); $assertion->addItem(new AuthnStatement()); $assertion->setSubject(new Subject()); $assertion->getSubject()->addSubjectConfirmation($subjectConfirmation = (new SubjectConfirmation())->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER)); $subjectConfirmation->setSubjectConfirmationData((new SubjectConfirmationData())->setRecipient($recipient = 'http://recipient.com')); $profileContext = TestHelper::getProfileContext(); $profileContext->getOwnEntityContext()->setEntityDescriptor($ownEntityDescriptor = new EntityDescriptor()); $assertionContext->setParent($profileContext); $endpointResolver->expects($this->once())->method('resolve')->willReturnCallback(function () use($recipient) { return [TestHelper::getEndpointReferenceMock($this, new AssertionConsumerService())]; }); $action->execute($assertionContext); }
public function test_sets_unknown_assertion_id_to_store() { $action = new RepeatedIdValidatorAction($loggerMock = TestHelper::getLoggerMock($this), $idStoreMock = TestHelper::getIdStoreMock($this)); $assertionContext = TestHelper::getAssertionContext($assertion = new Assertion()); $assertion->setId($assertionId = '123'); $assertion->setIssuer(new Issuer($issuer = 'http://issuer.com')); $assertion->addItem(new AuthnStatement()); $assertion->setSubject(new Subject()); $assertion->getSubject()->addSubjectConfirmation($subjectConfirmation = new SubjectConfirmation()); $subjectConfirmation->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER); $subjectConfirmation->setSubjectConfirmationData(new SubjectConfirmationData()); $subjectConfirmation->getSubjectConfirmationData()->setNotOnOrAfter(new \DateTime()); $idStoreMock->expects($this->once())->method('has')->with($issuer, $assertionId)->willReturn(false); $idStoreMock->expects($this->once())->method('set')->with($issuer, $assertionId, $this->isInstanceOf(\DateTime::class)); $action->execute($assertionContext); }