public function test_adds_service_type_sso()
 {
     $message = new AuthnRequest();
     $context = $this->createContext(ProfileContext::ROLE_IDP, $message);
     $this->setEndpointResolver(true, function (CriteriaSet $criteriaSet) {
         $this->criteriaSetShouldHaveServiceTypeCriteria($criteriaSet, SingleSignOnService::class);
         return [TestHelper::getEndpointReferenceMock($this, $endpoint = new SingleSignOnService())];
     });
     $this->action->execute($context);
 }
 public function test_adds_location_criteria_for_authn_request_with_acs_url()
 {
     $message = new AuthnRequest();
     $message->setAssertionConsumerServiceURL($url = 'http://domain.com/acs');
     $context = $this->createContext(ProfileContext::ROLE_IDP, $message);
     $this->setEndpointResolver(true, function (CriteriaSet $criteriaSet) use($url) {
         $this->criteriaSetShouldHaveLocationCriteria($criteriaSet, $url);
         return [TestHelper::getEndpointReferenceMock($this, $endpoint = new SingleSignOnService())];
     });
     $this->action->execute($context);
 }
 public function test_adds_idp_sso_descriptor_type_when_sso_sp_entity_is_own_id()
 {
     $message = new AuthnRequest();
     $context = $this->createContext(ProfileContext::ROLE_IDP, $message);
     $context->getOwnEntityContext()->setEntityDescriptor(new EntityDescriptor($ownEntityId = 'http://own.id'));
     $context->getLogoutContext()->setSsoSessionState((new SsoSessionState())->setSpEntityId($ownEntityId));
     $this->setEndpointResolver(true, function (CriteriaSet $criteriaSet) {
         $this->criteriaSetShouldHaveDescriptorTypeCriteria($criteriaSet, IdpSsoDescriptor::class);
         return [TestHelper::getEndpointReferenceMock($this, $endpoint = new SingleLogoutService())];
     });
     $this->action->execute($context);
 }
예제 #4
0
 public function test_finds_acs_endpoint_and_sets_outbounding_authn_request_acs_url()
 {
     $action = new ACSUrlAction($loggerMock = TestHelper::getLoggerMock($this), $endpointResolverMock = $this->getEndpointResolverMock());
     $context = new ProfileContext(Profiles::SSO_SP_SEND_AUTHN_REQUEST, ProfileContext::ROLE_SP);
     $context->getOwnEntityContext()->setEntityDescriptor($entityDescriptorMock = $this->getEntityDescriptorMock());
     $entityDescriptorMock->expects($this->once())->method('getAllEndpoints')->willReturn([TestHelper::getEndpointReferenceMock($this, $endpoint = new AssertionConsumerService('http://localhost/acs'))]);
     $endpointResolverMock->expects($this->once())->method('resolve')->with($this->isInstanceOf(CriteriaSet::class), $this->isType('array'))->willReturnCallback(function (CriteriaSet $criteriaSet, array $candidates) {
         $this->assertTrue($criteriaSet->has(DescriptorTypeCriteria::class));
         $this->assertEquals(SpSsoDescriptor::class, $criteriaSet->getSingle(DescriptorTypeCriteria::class)->getDescriptorType());
         $this->assertTrue($criteriaSet->has(ServiceTypeCriteria::class));
         $this->assertEquals(AssertionConsumerService::class, $criteriaSet->getSingle(ServiceTypeCriteria::class)->getServiceType());
         $this->assertTrue($criteriaSet->has(BindingCriteria::class));
         $this->assertEquals([SamlConstants::BINDING_SAML2_HTTP_POST], $criteriaSet->getSingle(BindingCriteria::class)->getAllBindings());
         return $candidates;
     });
     $context->getOutboundContext()->setMessage($authnRequest = new AuthnRequest());
     $action->execute($context);
     $this->assertEquals($endpoint->getLocation(), $authnRequest->getAssertionConsumerServiceURL());
 }
 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);
 }