use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class OAuthAdapterTest method shouldNotDeserialiseATokenWhichDoesntContainAMap.
@Test
public void shouldNotDeserialiseATokenWhichDoesntContainAMap() {
// Given
JSONSerialisation serialisation = new JSONSerialisation(new ObjectMapper());
OAuthAdapter adapter = generateOAuthAdapter();
Token token = new Token("", TokenType.OAUTH);
token.setBlob(serialisation.serialise("badger").getBytes());
// When
JsonValue fromToken = adapter.fromToken(token);
// Then
assertThat(fromToken).isNull();
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class CTSMonitoringStoreImplTest method shouldNotAddTokenOperationForSpecificTokenTypeIfTokenIsNull.
@Test
public void shouldNotAddTokenOperationForSpecificTokenTypeIfTokenIsNull() throws InterruptedException {
//Given
Token token = null;
CTSOperation operation = CTSOperation.READ;
boolean successful = true;
//When
ctsOperationsMonitoringStore.addTokenOperation(token, operation, successful);
//Then
verify(tokenOperationsStore, never()).addTokenOperation(Matchers.<TokenType>anyObject(), eq(operation), eq(successful));
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class JSONSerialisationTest method shouldDeserialiseSerialisedToken.
@Test
public void shouldDeserialiseSerialisedToken() {
// Given
Token token = new Token("id", TokenType.OAUTH);
// When
Token result = serialization.deserialise(serialization.serialise(token), Token.class);
// Then
TokenTestUtils.assertTokenEquals(result, token);
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class LdapTokenAttributeConversionTest method shouldUnderstandEmptyStrings.
@Test
public void shouldUnderstandEmptyStrings() {
// Given
Entry entry = new LinkedHashMapEntry();
entry.addAttribute(CoreTokenField.TOKEN_ID.toString(), "id");
entry.addAttribute(CoreTokenField.TOKEN_TYPE.toString(), TokenType.OAUTH.toString());
entry.addAttribute(CoreTokenField.STRING_ONE.toString(), LdapTokenAttributeConversion.EMPTY);
LdapTokenAttributeConversion conversion = generateTokenAttributeConversion();
// When
Token result = conversion.tokenFromEntry(entry);
// Then
String string = result.getValue(CoreTokenField.STRING_ONE);
assertTrue(string.isEmpty());
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class LdapTokenAttributeConversionTest method shouldHandleEmptyStrings.
@Test
public void shouldHandleEmptyStrings() {
// Given
Token token = new Token("id", TokenType.OAUTH);
token.setAttribute(CoreTokenField.STRING_ONE, "");
LdapTokenAttributeConversion conversion = generateTokenAttributeConversion();
// When
Entry result = conversion.getEntry(token);
// Then
Attribute attribute = result.getAttribute(CoreTokenField.STRING_ONE.toString());
assertNull(attribute);
}
Aggregations