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));
}
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));
}
Aggregations