Search in sources :

Example 16 with DSConfigMgr

use of com.iplanet.services.ldap.DSConfigMgr in project OpenAM by OpenRock.

the class ServerConfigurationFactoryTest method shouldReturnInstanceBindDN.

@Test
public void shouldReturnInstanceBindDN() throws ConnectionCredentialsNotFound, ServerConfigurationNotFound {
    // Given
    DSConfigMgr configMgr = mock(DSConfigMgr.class);
    ServerGroup serverGroup = mock(ServerGroup.class);
    given(configMgr.getServerGroup(anyString())).willReturn(serverGroup);
    ServerInstance mockInstance = mock(ServerInstance.class);
    given(configMgr.getServerInstance(anyString(), any(LDAPUser.Type.class))).willReturn(mockInstance);
    given(mockInstance.getAuthID()).willReturn("");
    ServerConfigurationFactory parser = new ServerConfigurationFactory(configMgr);
    // When
    String dn = parser.getServerConfiguration("", LDAPUser.Type.AUTH_ADMIN).getBindDN();
    // Then
    verify(mockInstance).getAuthID();
}
Also used : ServerGroup(com.iplanet.services.ldap.ServerGroup) DSConfigMgr(com.iplanet.services.ldap.DSConfigMgr) ServerConfigurationFactory(org.forgerock.openam.sm.ServerConfigurationFactory) Matchers.anyString(org.mockito.Matchers.anyString) ServerInstance(com.iplanet.services.ldap.ServerInstance) Test(org.testng.annotations.Test)

Example 17 with DSConfigMgr

use of com.iplanet.services.ldap.DSConfigMgr in project OpenAM by OpenRock.

the class ServerConfigurationFactoryTest method shouldIndicateInvalidIfServerInstanceIsNull.

@Test(expectedExceptions = ConnectionCredentialsNotFound.class)
public void shouldIndicateInvalidIfServerInstanceIsNull() throws ConnectionCredentialsNotFound, ServerConfigurationNotFound {
    // Given
    ServerGroup mockGroup = mock(ServerGroup.class);
    DSConfigMgr mockConfig = mock(DSConfigMgr.class);
    given(mockConfig.getServerGroup(anyString())).willReturn(mockGroup);
    given(mockConfig.getServerInstance(anyString(), any(LDAPUser.Type.class))).willReturn(null);
    ServerConfigurationFactory parser = new ServerConfigurationFactory(mockConfig);
    // When / Then
    parser.getServerConfiguration("", LDAPUser.Type.AUTH_ADMIN);
}
Also used : ServerGroup(com.iplanet.services.ldap.ServerGroup) DSConfigMgr(com.iplanet.services.ldap.DSConfigMgr) ServerConfigurationFactory(org.forgerock.openam.sm.ServerConfigurationFactory) Test(org.testng.annotations.Test)

Example 18 with DSConfigMgr

use of com.iplanet.services.ldap.DSConfigMgr in project OpenAM by OpenRock.

the class ServerConfigurationFactoryTest method shouldReturnRequestedServerGroup.

@Test
public void shouldReturnRequestedServerGroup() throws ConnectionCredentialsNotFound, ServerConfigurationNotFound {
    // Given
    String test = "badger";
    ServerGroup mockGroup = mock(ServerGroup.class);
    ServerInstance mockInstance = mock(ServerInstance.class);
    DSConfigMgr mockConfig = mock(DSConfigMgr.class);
    given(mockConfig.getServerGroup(test)).willReturn(mockGroup);
    given(mockConfig.getServerInstance(anyString(), any(LDAPUser.Type.class))).willReturn(mockInstance);
    ServerConfigurationFactory parser = new ServerConfigurationFactory(mockConfig);
    // When
    parser.getServerConfiguration(test, LDAPUser.Type.AUTH_ADMIN);
    // Then
    verify(mockConfig).getServerGroup(test);
}
Also used : ServerGroup(com.iplanet.services.ldap.ServerGroup) DSConfigMgr(com.iplanet.services.ldap.DSConfigMgr) ServerConfigurationFactory(org.forgerock.openam.sm.ServerConfigurationFactory) Matchers.anyString(org.mockito.Matchers.anyString) ServerInstance(com.iplanet.services.ldap.ServerInstance) Test(org.testng.annotations.Test)

Aggregations

DSConfigMgr (com.iplanet.services.ldap.DSConfigMgr)18 ServerInstance (com.iplanet.services.ldap.ServerInstance)13 LDAPServiceException (com.iplanet.services.ldap.LDAPServiceException)10 ServerGroup (com.iplanet.services.ldap.ServerGroup)8 LdapException (org.forgerock.opendj.ldap.LdapException)5 Connection (org.forgerock.opendj.ldap.Connection)4 ConnectionFactory (org.forgerock.opendj.ldap.ConnectionFactory)4 ServerConfigurationFactory (org.forgerock.openam.sm.ServerConfigurationFactory)3 Test (org.testng.annotations.Test)3 SystemProperties (com.iplanet.am.util.SystemProperties)2 Server (com.iplanet.services.ldap.Server)2 SSOToken (com.iplanet.sso.SSOToken)2 IOException (java.io.IOException)2 Properties (java.util.Properties)2 MBeanServer (javax.management.MBeanServer)2 LoginException (javax.security.auth.login.LoginException)2 ShutdownListener (org.forgerock.util.thread.listener.ShutdownListener)2 ShutdownManager (org.forgerock.util.thread.listener.ShutdownManager)2 Matchers.anyString (org.mockito.Matchers.anyString)2 EventException (com.iplanet.services.ldap.event.EventException)1