use of org.forgerock.opendj.ldap.Entry in project OpenAM by OpenRock.
the class LdapTokenAttributeConversionTest method shouldConvertTokenToEntryAndBack.
@Test
public void shouldConvertTokenToEntryAndBack() {
// Given
LdapTokenAttributeConversion conversion = generateTokenAttributeConversion();
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(LDAPDataConversionTest.BERLIN);
calendar.setTimeInMillis(System.currentTimeMillis());
Token token = new Token("badger", TokenType.SESSION);
token.setAttribute(CoreTokenField.STRING_ONE, "Ferret");
token.setAttribute(CoreTokenField.STRING_TWO, "Weasel");
token.setAttribute(CoreTokenField.INTEGER_ONE, 1234);
token.setAttribute(CoreTokenField.DATE_ONE, calendar);
// When
Entry entry = conversion.getEntry(token);
Token result = conversion.tokenFromEntry(entry);
// Then
TokenTestUtils.assertTokenEquals(token, result);
}
use of org.forgerock.opendj.ldap.Entry in project OpenAM by OpenRock.
the class LdapTokenAttributeConversionTest method shouldNotStripObjectClassIfNotPresent.
@Test
public void shouldNotStripObjectClassIfNotPresent() {
// Given
Entry entry = mock(Entry.class);
given(entry.getAttribute(anyString())).willReturn(null);
// When
LdapTokenAttributeConversion.stripObjectClass(entry);
// Then
verify(entry, times(0)).removeAttribute(anyString(), any());
}
use of org.forgerock.opendj.ldap.Entry in project OpenAM by OpenRock.
the class LdapTokenAttributeConversionTest method shouldNotAddObjectClassIfPresent.
@Test
public void shouldNotAddObjectClassIfPresent() {
// Given
Entry entry = mock(Entry.class);
Attribute attribute = mock(Attribute.class);
given(entry.getAttribute(anyString())).willReturn(attribute);
// When
LdapTokenAttributeConversion.addObjectClass(entry);
// Then
verify(entry, times(0)).addAttribute(anyString(), any());
}
use of org.forgerock.opendj.ldap.Entry 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.opendj.ldap.Entry 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