Search in sources :

Example 26 with InternalSession

use of com.iplanet.dpro.session.service.InternalSession in project OpenAM by OpenRock.

the class StatelessSessionActivatorTest method shouldGenerateStatelessSessionId.

@Test
public void shouldGenerateStatelessSessionId() throws Exception {
    // Given
    InternalSession mockSession = mock(InternalSession.class);
    String userDn = "fred";
    given(mockLoginState.getUserDN()).willReturn(userDn);
    given(mockSession.activate(userDn, true)).willReturn(true);
    StatelessSession mockStatelessSession = mock(StatelessSession.class);
    given(mockSessionFactory.generate(mockSession)).willReturn(mockStatelessSession);
    SessionID statelessSessionId = new SessionID("stateless");
    given(mockStatelessSession.getID()).willReturn(statelessSessionId);
    // When
    testActivator.activateSession(mockSession, mockLoginState);
    // Then
    verify(mockSessionFactory).generate(mockSession);
    verify(mockLoginState).setSessionID(statelessSessionId);
}
Also used : StatelessSession(org.forgerock.openam.sso.providers.stateless.StatelessSession) InternalSession(com.iplanet.dpro.session.service.InternalSession) SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Example 27 with InternalSession

use of com.iplanet.dpro.session.service.InternalSession in project OpenAM by OpenRock.

the class StatelessSessionActivatorTest method shouldEnsureSessionIsNotScheduled.

@Test
public void shouldEnsureSessionIsNotScheduled() throws Exception {
    // Given
    InternalSession mockSession = mock(InternalSession.class);
    // When
    testActivator.activateSession(mockSession, mockLoginState);
    // Then
    verify(mockSession).cancel();
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) Test(org.testng.annotations.Test)

Example 28 with InternalSession

use of com.iplanet.dpro.session.service.InternalSession in project OpenAM by OpenRock.

the class CoreTokenConfigTest method shouldConvertUserIdToLowerCaseIfCaseSensitive.

@Test
public void shouldConvertUserIdToLowerCaseIfCaseSensitive() {
    // Given
    InternalSession session = mock(InternalSession.class);
    String badger = "BADGER";
    given(session.getUUID()).willReturn(badger);
    CoreTokenConfig config = new CoreTokenConfig();
    assertFalse(config.isCaseSensitiveUserId());
    // When
    String result = config.getUserId(session);
    // Then
    assertEquals(result, badger.toLowerCase());
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) Test(org.testng.annotations.Test)

Example 29 with InternalSession

use of com.iplanet.dpro.session.service.InternalSession in project OpenAM by OpenRock.

the class JSONSerialisationTest method internalSessionDeserialisationDoesNotModifyMapTypes.

@Test(dataProvider = "complex")
public void internalSessionDeserialisationDoesNotModifyMapTypes(String path) throws Exception {
    InternalSession is = serialization.deserialise(getJSON(path), InternalSession.class);
    assertThat(is).isNotNull();
    checkMapType(is, "sessionEventURLs");
    checkMapType(is, "restrictedTokensBySid");
    checkMapType(is, "restrictedTokensByRestriction");
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) Test(org.testng.annotations.Test)

Example 30 with InternalSession

use of com.iplanet.dpro.session.service.InternalSession in project OpenAM by OpenRock.

the class JSONSerialisationTest method complexInternalSessionSerializationWorks.

@Test(dataProvider = "complex")
public void complexInternalSessionSerializationWorks(String path) throws Exception {
    InternalSession is = serialization.deserialise(getJSON(path), InternalSession.class);
    assertThat(is).isNotNull();
    String serialised = serialization.serialise(is);
    assertThat(serialised).isNotNull().isNotEmpty();
    InternalSession is2 = serialization.deserialise(serialised, InternalSession.class);
    assertThat(is2).isNotNull().isNotSameAs(is);
    assertThat(is.getID()).isEqualTo(is2.getID());
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) Test(org.testng.annotations.Test)

Aggregations

InternalSession (com.iplanet.dpro.session.service.InternalSession)42 SessionID (com.iplanet.dpro.session.SessionID)17 Test (org.testng.annotations.Test)16 SSOException (com.iplanet.sso.SSOException)10 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)10 SSOToken (com.iplanet.sso.SSOToken)9 Token (org.forgerock.openam.cts.api.tokens.Token)8 SessionException (com.iplanet.dpro.session.SessionException)6 SSOTokenManager (com.iplanet.sso.SSOTokenManager)5 IOException (java.io.IOException)5 ModelControlException (com.iplanet.jato.model.ModelControlException)4 Map (java.util.Map)4 Session (com.iplanet.dpro.session.Session)3 AuthContextLocal (com.sun.identity.authentication.server.AuthContextLocal)3 AuthD (com.sun.identity.authentication.service.AuthD)3 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)2 AuthException (com.sun.identity.authentication.service.AuthException)2 InvalidPasswordException (com.sun.identity.authentication.spi.InvalidPasswordException)2 ISLocaleContext (com.sun.identity.common.ISLocaleContext)2 SMSException (com.sun.identity.sm.SMSException)2