use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class SessionAdapterTest method shouldAssignSessionHandle.
public void shouldAssignSessionHandle() {
// Given
long timestamp = 12345l;
InternalSession mockSession = mock(InternalSession.class);
SessionID mockSessionID = mock(SessionID.class);
String sessionId = "badger";
String sessionHandle = SessionID.SHANDLE_SCHEME_PREFIX + "ferret";
given(mockSessionID.toString()).willReturn(sessionId);
given(jsonSerialisation.deserialise(anyString(), any(Class.class))).willReturn(mockSession);
given(mockSession.getExpirationTime()).willReturn(timestamp);
given(mockSession.getID()).willReturn(mockSessionID);
given(mockSession.getSessionHandle()).willReturn(sessionHandle);
// some additional required mocking
given(tokenIdFactory.toSessionTokenId(eq(mockSession))).willReturn(sessionId);
given(jsonSerialisation.serialise(any())).willReturn("");
// When
Token token = adapter.toToken(mockSession);
// Then
assertThat(token.<String>getValue(SessionTokenField.SESSION_HANDLE.getField())).isEqualTo(sessionHandle);
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class SessionAdapterTest method shouldAssignSessionID.
@Test
public void shouldAssignSessionID() {
// Given
long timestamp = 12345l;
InternalSession mockSession = mock(InternalSession.class);
SessionID mockSessionID = mock(SessionID.class);
String sessionId = "badger";
String sessionHandle = SessionID.SHANDLE_SCHEME_PREFIX + "ferret";
given(mockSessionID.toString()).willReturn(sessionId);
given(jsonSerialisation.deserialise(anyString(), any(Class.class))).willReturn(mockSession);
given(mockSession.getExpirationTime()).willReturn(timestamp);
given(mockSession.getID()).willReturn(mockSessionID);
given(mockSession.getSessionHandle()).willReturn(sessionHandle);
// some additional required mocking
given(tokenIdFactory.toSessionTokenId(eq(mockSession))).willReturn(sessionId);
given(jsonSerialisation.serialise(any())).willReturn("");
// When
Token token = adapter.toToken(mockSession);
// Then
assertThat(token.<String>getValue(SessionTokenField.SESSION_ID.getField())).isEqualTo(sessionId);
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class SessionAdapterTest method shouldAssignAttributeFromSessionLatestAccessTime.
@Test
public void shouldAssignAttributeFromSessionLatestAccessTime() {
// Given
long timestamp = 12345l;
InternalSession mockSession = mock(InternalSession.class);
SessionID mockSessionID = mock(SessionID.class);
String sessionHandle = SessionID.SHANDLE_SCHEME_PREFIX + "ferret";
given(mockSessionID.toString()).willReturn("badger");
given(jsonSerialisation.deserialise(anyString(), any(Class.class))).willReturn(mockSession);
given(mockSession.getExpirationTime()).willReturn(timestamp);
given(mockSession.getID()).willReturn(mockSessionID);
given(mockSession.getSessionHandle()).willReturn(sessionHandle);
// some additional required mocking
given(tokenIdFactory.toSessionTokenId(eq(mockSession))).willReturn("badger");
given(jsonSerialisation.serialise(any())).willReturn("");
// When
Token token = adapter.toToken(mockSession);
// Then
assertThat(token.getExpiryTimestamp()).isNotNull();
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class StatelessSessionFactoryTest method shouldContainJwtInSessionID.
@Test
public void shouldContainJwtInSessionID() {
SessionID mockSession = mock(SessionID.class);
given(mockSession.getTail()).willReturn("badger");
assertThat(factory.containsJwt(mockSession)).isTrue();
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class StatelessSessionFactoryTest method shouldNotUndoC66DecodingIfNotEncoded.
@Test
public void shouldNotUndoC66DecodingIfNotEncoded() {
// Given
final String fullJwtAlphabet = ".-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
final SessionID sessionID = new SessionID("notencoded@" + fullJwtAlphabet);
// When
final String result = StatelessSessionFactory.getJWTFromSessionID(sessionID, true);
// Then
assertThat(result).isEqualTo(fullJwtAlphabet);
assertThat(sessionID.isC66Encoded()).isFalse();
}
Aggregations