示例#1
0
 public function test_has_option()
 {
     $state = new SsoSessionState();
     $this->assertFalse($state->hasOption('a'));
     $state->addOption('a', 123);
     $this->assertTrue($state->hasOption('a'));
 }
示例#2
0
 public function test_adds_sso_session_state()
 {
     $state = new SsoState();
     $session1 = new SsoSessionState();
     $session1->setIdpEntityId($session1Idp = 'http://idp-1.com');
     $session1->setSpEntityId($session1sp = 'http://sp-1.com');
     $state->addSsoSession($session1);
     $this->assertTrue(is_array($state->getSsoSessions()));
     $this->assertCount(1, $state->getSsoSessions());
     $session2 = new SsoSessionState();
     $session2->setIdpEntityId($session1Idp = 'http://idp-2.com');
     $session2->setSpEntityId($session1sp = 'http://sp-2.com');
     $state->addSsoSession($session1);
     $this->assertCount(2, $state->getSsoSessions());
 }
 public function test_serialization()
 {
     $state = new SsoSessionState();
     $state->setIdpEntityId('idp');
     $state->setSpEntityId('sp');
     $state->setNameId('name-id');
     $state->setNameIdFormat('name-id-format');
     $state->setSessionIndex('session-index');
     $state->getParameters()->replace(['a' => 'abc', 'b' => 22, 'c' => [1, 2]]);
     /** @var SsoSessionState $other */
     $other = unserialize(serialize($state));
     $this->assertInstanceOf(SsoSessionState::class, $other);
     $this->assertInstanceOf(ParameterBag::class, $other->getParameters());
     $this->assertEquals($state->getIdpEntityId(), $other->getIdpEntityId());
     $this->assertEquals($state->getSpEntityId(), $other->getSpEntityId());
     $this->assertEquals($state->getNameId(), $other->getNameId());
     $this->assertEquals($state->getNameIdFormat(), $other->getNameIdFormat());
     $this->assertEquals($state->getSessionIndex(), $other->getSessionIndex());
     $this->assertEquals($state->getParameters()->all(), $other->getParameters()->all());
 }
示例#4
0
 /**
  * @param SsoState  $ssoState
  * @param Assertion $assertion
  * @param \DateTime $now
  * @param string    $ownEntityId
  * @param string    $partyEntityId
  *
  * @return SsoSessionState
  */
 protected function createSession(SsoState $ssoState, Assertion $assertion, \DateTime $now, $ownEntityId, $partyEntityId)
 {
     $ssoSession = new SsoSessionState();
     $ssoSession->setIdpEntityId($partyEntityId)->setSpEntityId($ownEntityId)->setNameId($assertion->getSubject()->getNameID()->getValue())->setNameIdFormat($assertion->getSubject()->getNameID()->getFormat())->setSessionIndex($assertion->getFirstAuthnStatement()->getSessionIndex())->setSessionInstant($assertion->getFirstAuthnStatement()->getAuthnInstantDateTime())->setFirstAuthOn($now)->setLastAuthOn($now);
     $ssoState->addSsoSession($ssoSession);
     return $ssoSession;
 }
示例#5
0
 public function test_modify()
 {
     $state = new SsoState();
     $state->addSsoSession($session1 = new SsoSessionState());
     $session1->setIdpEntityId('idp-1');
     $state->addSsoSession($session2 = new SsoSessionState());
     $session2->setIdpEntityId('idp-2');
     $state->modify(function (SsoSessionState $session) use($session1) {
         return $session->getIdpEntityId() != $session1->getIdpEntityId();
     });
     $sessions = $state->getSsoSessions();
     $this->assertCount(1, $sessions);
     $this->assertEquals($session2->getIdpEntityId(), $sessions[0]->getIdpEntityId());
 }