Search in sources :

Example 1 with LdapDataLayerConfiguration

use of org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration in project OpenAM by OpenRock.

the class CTSQueueConfigurationTest method setup.

@BeforeMethod
public void setup() throws InvalidConfigurationException {
    mockConfigFactory = mock(ConnectionConfigFactory.class);
    mockConfig = mock(ConnectionConfig.class);
    given(mockConfigFactory.getConfig(any(ConnectionType.class))).willReturn(mockConfig);
    LdapDataLayerConfiguration dataLayerConfiguration = mock(LdapDataLayerConfiguration.class);
    given(dataLayerConfiguration.getStoreMode()).willReturn(StoreMode.DEFAULT);
    Map<ConnectionType, LdapDataLayerConfiguration> configMap = mock(Map.class);
    given(configMap.get(anyObject())).willReturn(dataLayerConfiguration);
    config = new CTSQueueConfiguration(mockConfigFactory, mock(Debug.class));
}
Also used : ConnectionType(org.forgerock.openam.sm.datalayer.api.ConnectionType) LdapDataLayerConfiguration(org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration) ConnectionConfigFactory(org.forgerock.openam.sm.ConnectionConfigFactory) ConnectionConfig(org.forgerock.openam.sm.ConnectionConfig) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with LdapDataLayerConfiguration

use of org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration 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 3 with LdapDataLayerConfiguration

use of org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration in project OpenAM by OpenRock.

the class LdapTokenAttributeConversionTest method shouldProduceDNWithTokenId.

@Test
public void shouldProduceDNWithTokenId() {
    // Given
    String tokenId = "badger";
    LdapDataLayerConfiguration config = mock(LdapDataLayerConfiguration.class);
    given(config.getTokenStoreRootSuffix()).willReturn(DN.rootDN());
    LDAPDataConversion dataConversion = new LDAPDataConversion();
    LdapTokenAttributeConversion conversion = new LdapTokenAttributeConversion(dataConversion, config);
    // When
    DN dn = conversion.generateTokenDN(tokenId);
    // Then
    verify(config).getTokenStoreRootSuffix();
    assertTrue(dn.toString().contains(tokenId));
}
Also used : LdapDataLayerConfiguration(org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration) DN(org.forgerock.opendj.ldap.DN) Test(org.testng.annotations.Test)

Example 4 with LdapDataLayerConfiguration

use of org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration in project OpenAM by OpenRock.

the class LdapTokenAttributeConversionTest method generateTokenAttributeConversion.

private LdapTokenAttributeConversion generateTokenAttributeConversion() {
    LdapDataLayerConfiguration config = new CTSDataLayerConfiguration("ou=test-case");
    LDAPDataConversion dataConversion = new LDAPDataConversion();
    return new LdapTokenAttributeConversion(dataConversion, config);
}
Also used : LdapDataLayerConfiguration(org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration) CTSDataLayerConfiguration(org.forgerock.openam.cts.impl.CTSDataLayerConfiguration)

Example 5 with LdapDataLayerConfiguration

use of org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration 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

LdapDataLayerConfiguration (org.forgerock.openam.sm.datalayer.impl.ldap.LdapDataLayerConfiguration)5 Test (org.testng.annotations.Test)3 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 Connection (org.forgerock.opendj.ldap.Connection)2 ModifyRequest (org.forgerock.opendj.ldap.requests.ModifyRequest)2 CTSDataLayerConfiguration (org.forgerock.openam.cts.impl.CTSDataLayerConfiguration)1 ConnectionConfig (org.forgerock.openam.sm.ConnectionConfig)1 ConnectionConfigFactory (org.forgerock.openam.sm.ConnectionConfigFactory)1 ConnectionType (org.forgerock.openam.sm.datalayer.api.ConnectionType)1 DN (org.forgerock.opendj.ldap.DN)1 Result (org.forgerock.opendj.ldap.responses.Result)1 BeforeMethod (org.testng.annotations.BeforeMethod)1