use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class LdapAdapterTest method shouldUseConnectionForCreate.
@Test
public void shouldUseConnectionForCreate() throws Exception {
// Given
Token token = new Token("badger", TokenType.SESSION);
Result successResult = mockSuccessfulResult();
given(mockConnection.add(any(Entry.class))).willReturn(successResult);
given(mockConversion.getEntry(any(Token.class))).willReturn(mock(Entry.class));
// When
adapter.create(mockConnection, token);
// Then
verify(mockConnection).add(any(Entry.class));
}
use of org.forgerock.openam.cts.api.tokens.Token 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 org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class SessionAdapterTest method shouldHandleMissingCommaInBlob.
@Test
public void shouldHandleMissingCommaInBlob() {
// Given
String latestAccessTime = "1376308558";
Token token = new Token("badger", TokenType.SESSION);
String someJSONLikeText = "{\"latestAccessTime\":" + latestAccessTime + "}";
token.setBlob(someJSONLikeText.getBytes());
// When
String result = adapter.filterLatestAccessTime(token);
// Then
assertEquals(result, latestAccessTime);
}
use of org.forgerock.openam.cts.api.tokens.Token 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 org.forgerock.openam.cts.api.tokens.Token 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();
}
Aggregations