Search in sources :

Example 1 with LdapTokenAttributeConversion

use of org.forgerock.openam.cts.utils.LdapTokenAttributeConversion in project OpenAM by OpenRock.

the class LdapAdapterTest method shouldPerformUpdate.

@Test
public void shouldPerformUpdate() throws Exception {
    // Given
    Token first = new Token("weasel", TokenType.OAUTH);
    Token second = new Token("badger", TokenType.OAUTH);
    Connection mockConnection = mock(Connection.class);
    Result successResult = mockSuccessfulResult();
    given(mockConnection.modify(any(ModifyRequest.class))).willReturn(successResult);
    LdapDataLayerConfiguration config = mock(LdapDataLayerConfiguration.class);
    when(config.getTokenStoreRootSuffix()).thenReturn(DN.valueOf("ou=unit-test"));
    LDAPDataConversion dataConversion = new LDAPDataConversion();
    LdapTokenAttributeConversion conversion = new LdapTokenAttributeConversion(dataConversion, config);
    LdapAdapter adapter = new LdapAdapter(conversion, null, null);
    // When
    adapter.update(mockConnection, first, second);
    // Then
    verify(mockConnection).modify(any(ModifyRequest.class));
}
Also used : LdapTokenAttributeConversion(org.forgerock.openam.cts.utils.LdapTokenAttributeConversion) LdapDataLayerConfiguration(org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration) Connection(org.forgerock.opendj.ldap.Connection) PartialToken(org.forgerock.openam.sm.datalayer.api.query.PartialToken) Token(org.forgerock.openam.cts.api.tokens.Token) ModifyRequest(org.forgerock.opendj.ldap.requests.ModifyRequest) LDAPDataConversion(org.forgerock.openam.cts.utils.LDAPDataConversion) Result(org.forgerock.opendj.ldap.responses.Result) Test(org.testng.annotations.Test)

Example 2 with LdapTokenAttributeConversion

use of org.forgerock.openam.cts.utils.LdapTokenAttributeConversion in project OpenAM by OpenRock.

the class LdapAdapterTest method shouldNoNothingIfNoModificaitonsOnUpdate.

@Test
public void shouldNoNothingIfNoModificaitonsOnUpdate() throws Exception {
    // Given
    String tokenId = "badger";
    Token first = new Token(tokenId, TokenType.OAUTH);
    Token second = new Token(tokenId, TokenType.OAUTH);
    Connection mockConnection = mock(Connection.class);
    LdapDataLayerConfiguration config = mock(LdapDataLayerConfiguration.class);
    when(config.getTokenStoreRootSuffix()).thenReturn(DN.valueOf("ou=unit-test"));
    LDAPDataConversion dataConversion = new LDAPDataConversion();
    LdapTokenAttributeConversion conversion = new LdapTokenAttributeConversion(dataConversion, config);
    adapter = new LdapAdapter(conversion, mockQueryVisitor, mockQueryFactory);
    // When
    adapter.update(mockConnection, first, second);
    // Then
    verify(mockConnection, never()).modify(any(ModifyRequest.class));
}
Also used : LdapTokenAttributeConversion(org.forgerock.openam.cts.utils.LdapTokenAttributeConversion) LdapDataLayerConfiguration(org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration) Connection(org.forgerock.opendj.ldap.Connection) PartialToken(org.forgerock.openam.sm.datalayer.api.query.PartialToken) Token(org.forgerock.openam.cts.api.tokens.Token) ModifyRequest(org.forgerock.opendj.ldap.requests.ModifyRequest) LDAPDataConversion(org.forgerock.openam.cts.utils.LDAPDataConversion) Test(org.testng.annotations.Test)

Aggregations

Token (org.forgerock.openam.cts.api.tokens.Token)2 LDAPDataConversion (org.forgerock.openam.cts.utils.LDAPDataConversion)2 LdapTokenAttributeConversion (org.forgerock.openam.cts.utils.LdapTokenAttributeConversion)2 PartialToken (org.forgerock.openam.sm.datalayer.api.query.PartialToken)2 LdapDataLayerConfiguration (org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration)2 Connection (org.forgerock.opendj.ldap.Connection)2 ModifyRequest (org.forgerock.opendj.ldap.requests.ModifyRequest)2 Test (org.testng.annotations.Test)2 Result (org.forgerock.opendj.ldap.responses.Result)1