diff options
Diffstat (limited to 'tests/test.integration.core/src/main/java/org')
4 files changed, 60 insertions, 8 deletions
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java index cc7896fc7..d9f94e5da 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java @@ -28,8 +28,10 @@ import java.io.File; import org.apache.directory.server.core.api.DirectoryService; import org.apache.directory.server.core.api.partition.Partition; import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory; +import org.apache.directory.server.core.security.CertificateUtil; import org.apache.directory.server.ldap.LdapServer; import org.apache.directory.server.ldap.handlers.extended.PwdModifyHandler; +import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler; import org.apache.directory.server.ldap.handlers.extended.WhoAmIHandler; import org.apache.directory.server.protocol.shared.transport.TcpTransport; import org.apache.directory.server.protocol.shared.transport.Transport; @@ -48,13 +50,15 @@ public class ApacheDirectoryServer extends TestLdapServer private DirectoryService service; private LdapServer server; + private String defaultKeyStoreFile; public static synchronized ApacheDirectoryServer getInstance() { if ( instance == null ) { int port = AvailablePortFinder.getNextAvailable( 1024 ); - instance = new ApacheDirectoryServer( port ); + int portSSL = AvailablePortFinder.getNextAvailable( port + 1 ); + instance = new ApacheDirectoryServer( port, portSSL ); instance.startServer(); } return instance; @@ -77,12 +81,20 @@ public class ApacheDirectoryServer extends TestLdapServer server = new LdapServer(); server.setDirectoryService( service ); - int port = AvailablePortFinder.getNextAvailable( 1024 ); Transport ldap = new TcpTransport( port ); server.addTransports( ldap ); + Transport ldaps = new TcpTransport( portSSL ); + ldaps.setEnableSSL( true ); + server.addTransports( ldaps ); + server.addExtendedOperationHandler( new StartTlsHandler() ); server.addExtendedOperationHandler( new PwdModifyHandler() ); server.addExtendedOperationHandler( new WhoAmIHandler() ); + defaultKeyStoreFile = CertificateUtil.createTempKeyStore( "testStore", "changeit".toCharArray() ) + .getAbsolutePath(); + server.setKeystoreFile( defaultKeyStoreFile ); + server.setCertificatePassword( "changeit" ); + server.start(); } catch ( Exception e ) @@ -92,15 +104,42 @@ public class ApacheDirectoryServer extends TestLdapServer } + @Override + public void prepare() + { + super.prepare(); + + try + { + if ( !defaultKeyStoreFile.equals( server.getKeystoreFile() ) ) + { + server.setKeystoreFile( defaultKeyStoreFile ); + server.reloadSslContext(); + } + } + catch ( Exception e ) + { + throw new RuntimeException( e ); + } + } + + + public void setKeystore( String keystorePath ) throws Exception + { + server.setKeystoreFile( keystorePath ); + server.reloadSslContext(); + } + + public DirectoryService getService() { return service; } - private ApacheDirectoryServer( int port ) + private ApacheDirectoryServer( int port, int portSSL ) { - super( LdapServerType.ApacheDS, LOCALHOST, port, "uid=admin,ou=system", "secret" ); + super( LdapServerType.ApacheDS, LOCALHOST, port, portSSL, "uid=admin,ou=system", "secret" ); } } diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/Fedora389dsLdapServer.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/Fedora389dsLdapServer.java index fedca3c61..b856ee563 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/Fedora389dsLdapServer.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/Fedora389dsLdapServer.java @@ -34,6 +34,8 @@ public class Fedora389dsLdapServer extends TestLdapServer { private static final String FEDORA_389DS_HOST = getEnvOrDefault( "FEDORA_389DS_HOST", LOCALHOST ); private static final int FEDORA_389DS_PORT = Integer.parseInt( getEnvOrDefault( "FEDORA_389DS_PORT", "21389" ) ); + private static final int FEDORA_389DS_PORT_SSL = Integer + .parseInt( getEnvOrDefault( "FEDORA_389DS_PORT_SSL", "21636" ) ); private static final String FEDORA_389DS_ADMIN_DN = getEnvOrDefault( "FEDORA_389DS_ADMIN_DN", "cn=Directory Manager" ); private static final String FEDORA_389DS_ADMIN_PASSWORD = getEnvOrDefault( "FEDORA_389DS_ADMIN_PASSWORD", "admin" ); @@ -46,8 +48,8 @@ public class Fedora389dsLdapServer extends TestLdapServer private Fedora389dsLdapServer() { - super( LdapServerType.Fedora389ds, FEDORA_389DS_HOST, FEDORA_389DS_PORT, FEDORA_389DS_ADMIN_DN, - FEDORA_389DS_ADMIN_PASSWORD ); + super( LdapServerType.Fedora389ds, FEDORA_389DS_HOST, FEDORA_389DS_PORT, FEDORA_389DS_PORT_SSL, + FEDORA_389DS_ADMIN_DN, FEDORA_389DS_ADMIN_PASSWORD ); } } diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/OpenLdapServer.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/OpenLdapServer.java index 0ee22926c..23c64951a 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/OpenLdapServer.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/OpenLdapServer.java @@ -39,6 +39,7 @@ public class OpenLdapServer extends TestLdapServer { private static final String OPENLDAP_HOST = getEnvOrDefault( "OPENLDAP_HOST", LOCALHOST ); private static final int OPENLDAP_PORT = Integer.parseInt( getEnvOrDefault( "OPENLDAP_PORT", "20389" ) ); + private static final int OPENLDAP_PORT_SSL = Integer.parseInt( getEnvOrDefault( "OPENLDAP_PORT_SSL", "20636" ) ); private static final String OPENLDAP_ADMIN_DN = getEnvOrDefault( "OPENLDAP_ADMIN_DN", "cn=admin,dc=example,dc=org" ); private static final String OPENLDAP_ADMIN_PASSWORD = getEnvOrDefault( "OPENLDAP_ADMIN_PASSWORD", "admin" ); @@ -53,7 +54,8 @@ public class OpenLdapServer extends TestLdapServer private OpenLdapServer() { - super( LdapServerType.OpenLdap, OPENLDAP_HOST, OPENLDAP_PORT, OPENLDAP_ADMIN_DN, OPENLDAP_ADMIN_PASSWORD ); + super( LdapServerType.OpenLdap, OPENLDAP_HOST, OPENLDAP_PORT, OPENLDAP_PORT_SSL, OPENLDAP_ADMIN_DN, + OPENLDAP_ADMIN_PASSWORD ); } diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestLdapServer.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestLdapServer.java index 50bc9f620..9caa587f3 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestLdapServer.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestLdapServer.java @@ -44,14 +44,17 @@ public abstract class TestLdapServer protected final LdapServerType type; protected final String host; protected final int port; + protected final int portSSL; protected final String adminDn; protected final String adminPassword; - protected TestLdapServer( LdapServerType type, String host, int port, String adminDn, String adminPassword ) + protected TestLdapServer( LdapServerType type, String host, int port, int portSSL, String adminDn, + String adminPassword ) { this.type = type; this.host = host; this.port = port; + this.portSSL = portSSL; this.adminDn = adminDn; this.adminPassword = adminPassword; } @@ -173,6 +176,12 @@ public abstract class TestLdapServer } + public int getPortSSL() + { + return portSSL; + } + + public String getLdapUrl() { return "ldap://" + host + ":" + port; |