Search in sources :

Example 6 with Entry

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);
}
Also used : LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Entry(org.forgerock.opendj.ldap.Entry) Calendar(java.util.Calendar) Token(org.forgerock.openam.cts.api.tokens.Token) Test(org.testng.annotations.Test)

Example 7 with Entry

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());
}
Also used : LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Entry(org.forgerock.opendj.ldap.Entry) Test(org.testng.annotations.Test)

Example 8 with Entry

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());
}
Also used : LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Entry(org.forgerock.opendj.ldap.Entry) Attribute(org.forgerock.opendj.ldap.Attribute) Test(org.testng.annotations.Test)

Example 9 with Entry

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());
}
Also used : LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Entry(org.forgerock.opendj.ldap.Entry) LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Token(org.forgerock.openam.cts.api.tokens.Token) Test(org.testng.annotations.Test)

Example 10 with Entry

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);
}
Also used : LinkedHashMapEntry(org.forgerock.opendj.ldap.LinkedHashMapEntry) Entry(org.forgerock.opendj.ldap.Entry) Attribute(org.forgerock.opendj.ldap.Attribute) Token(org.forgerock.openam.cts.api.tokens.Token) Test(org.testng.annotations.Test)

Aggregations

Entry (org.forgerock.opendj.ldap.Entry)15 LinkedHashMapEntry (org.forgerock.opendj.ldap.LinkedHashMapEntry)12 Test (org.testng.annotations.Test)8 Token (org.forgerock.openam.cts.api.tokens.Token)4 Attribute (org.forgerock.opendj.ldap.Attribute)4 Connection (org.forgerock.opendj.ldap.Connection)4 LdapException (org.forgerock.opendj.ldap.LdapException)4 SearchResultEntry (org.forgerock.opendj.ldap.responses.SearchResultEntry)4 SearchRequest (org.forgerock.opendj.ldap.requests.SearchRequest)3 SMSDataEntry (com.sun.identity.sm.SMSDataEntry)2 SMSEntry (com.sun.identity.sm.SMSEntry)2 SMSException (com.sun.identity.sm.SMSException)2 Calendar (java.util.Calendar)2 LinkedList (java.util.LinkedList)2 ByteString (org.forgerock.opendj.ldap.ByteString)2 ResultCode (org.forgerock.opendj.ldap.ResultCode)2 ModifyRequest (org.forgerock.opendj.ldap.requests.ModifyRequest)2 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 FileInputStream (java.io.FileInputStream)1