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);
}
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();
}
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());
}
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");
}
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());
}
Aggregations