Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/apache/directory-studio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Seelmann <mail@stefan-seelmann.de>2021-06-21 07:41:47 +0300
committerStefan Seelmann <mail@stefan-seelmann.de>2021-06-21 12:04:49 +0300
commit3712a950b9f33664bbd70f19e97d5cbc7e6d0022 (patch)
tree745dbb1815d98cbb0716c3435f582b63730c6662
parentf5a228cfc7c23fadbeaca600768f756311bc5ae6 (diff)
DIRSTUDIO-1279: Enable TLSv1.3 and show protocol and cipher suite
-rw-r--r--eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template2
-rw-r--r--plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapper.java12
-rw-r--r--plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/StudioTrustManager.java8
-rw-r--r--plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java28
-rw-r--r--plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/jobs/CheckNetworkParameterRunnable.java12
-rw-r--r--plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java35
-rw-r--r--tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java45
-rw-r--r--tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/OpenLdapServer.java2
-rw-r--r--tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java5
-rw-r--r--tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestLdapServer.java4
-rw-r--r--tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/OpenLdapConfig.ldif3
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java9
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java70
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java45
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java6
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java6
16 files changed, 204 insertions, 88 deletions
diff --git a/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template b/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template
index b4d55df74..7bee90d5f 100644
--- a/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template
+++ b/eclipse-trgt-platform/template/org.apache.directory.studio.eclipse-trgt-platform.template
@@ -19,7 +19,7 @@
@author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
-->
<?pde version="3.8"?>
-<target name="Apache Directory Studio Platform" sequenceNumber="477">
+<target name="Apache Directory Studio Platform" sequenceNumber="479">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapper.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapper.java
index 7c7d1ffb6..51194dd9c 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapper.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/ConnectionWrapper.java
@@ -20,10 +20,10 @@
package org.apache.directory.studio.connection.core.io;
-import java.security.cert.X509Certificate;
import java.util.Collection;
import javax.naming.directory.SearchControls;
+import javax.net.ssl.SSLSession;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.entry.Modification;
@@ -50,7 +50,7 @@ public interface ConnectionWrapper
*
* @param monitor the progres monitor
*/
- X509Certificate[] connect( StudioProgressMonitor monitor );
+ void connect( StudioProgressMonitor monitor );
/**
@@ -90,6 +90,14 @@ public interface ConnectionWrapper
/**
+ * Gets the {@link SSLSession} associated with the connection.
+ *
+ * @return the {@link SSLSession} associated with the connection or null if the connection is not secured
+ */
+ SSLSession getSslSession();
+
+
+ /**
* Sets the binary attributes.
*
* @param binaryAttributes the binary attributes
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/StudioTrustManager.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/StudioTrustManager.java
index 56fe53089..5edb0e193 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/StudioTrustManager.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/StudioTrustManager.java
@@ -53,8 +53,6 @@ public class StudioTrustManager implements X509TrustManager
{
private X509TrustManager jvmTrustManager;
private String host;
- private X509Certificate[] chain;
-
/**
* Creates a new instance of StudioTrustManager.
@@ -94,8 +92,6 @@ public class StudioTrustManager implements X509TrustManager
*/
public void checkServerTrusted( X509Certificate[] chain, String authType ) throws CertificateException
{
- this.chain = chain;
-
// check permanent trusted certificates, return on success
try
{
@@ -249,8 +245,4 @@ public class StudioTrustManager implements X509TrustManager
return null;
}
- public X509Certificate[] getChain()
- {
- return chain;
- }
}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
index 8c7c694c8..4a8256077 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
@@ -21,7 +21,6 @@ package org.apache.directory.studio.connection.core.io.api;
import java.security.KeyStore;
-import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -29,6 +28,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import javax.naming.directory.SearchControls;
+import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
@@ -137,25 +137,24 @@ public class DirectoryApiConnectionWrapper implements ConnectionWrapper
/**
* {@inheritDoc}
*/
- public X509Certificate[] connect( StudioProgressMonitor monitor )
+ public void connect( StudioProgressMonitor monitor )
{
ldapConnection = null;
jobThread = null;
try
{
- return doConnect( monitor );
+ doConnect( monitor );
}
catch ( Exception e )
{
disconnect();
monitor.reportError( e );
- return null;
}
}
- private X509Certificate[] doConnect( final StudioProgressMonitor monitor ) throws Exception
+ private void doConnect( final StudioProgressMonitor monitor ) throws Exception
{
ldapConnection = null;
@@ -210,8 +209,6 @@ public class DirectoryApiConnectionWrapper implements ConnectionWrapper
}
}
- AtomicReference<X509Certificate[]> serverCertificates = new AtomicReference<>();
-
InnerRunnable runnable = new InnerRunnable()
{
public void run()
@@ -238,12 +235,6 @@ public class DirectoryApiConnectionWrapper implements ConnectionWrapper
ldapConnectionUnderConstruction.startTls();
}
- // Capture the server certificates
- if ( studioTrustmanager.get() != null )
- {
- serverCertificates.set( studioTrustmanager.get().getChain() );
- }
-
// Now set the LDAP connection once the (optional) security layer is in place
ldapConnection = ldapConnectionUnderConstruction;
@@ -255,7 +246,7 @@ public class DirectoryApiConnectionWrapper implements ConnectionWrapper
// DIRSTUDIO-1219: Verify secure connection if ldaps:// or StartTLS is configured
if ( ldapConnectionConfig.isUseTls() || ldapConnectionConfig.isUseSsl() )
{
- if ( !isSecured() || serverCertificates.get() == null )
+ if ( !isSecured() )
{
throw new Exception( Messages.DirectoryApiConnectionWrapper_UnsecuredConnection );
}
@@ -294,8 +285,6 @@ public class DirectoryApiConnectionWrapper implements ConnectionWrapper
{
throw runnable.getException();
}
-
- return serverCertificates.get();
}
@@ -539,6 +528,13 @@ public class DirectoryApiConnectionWrapper implements ConnectionWrapper
}
+ @Override
+ public SSLSession getSslSession()
+ {
+ return isConnected() ? ldapConnection.getSslSession() : null;
+ }
+
+
/**
* {@inheritDoc}
*/
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/jobs/CheckNetworkParameterRunnable.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/jobs/CheckNetworkParameterRunnable.java
index 5b8fce39d..a0ef1588f 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/jobs/CheckNetworkParameterRunnable.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/jobs/CheckNetworkParameterRunnable.java
@@ -21,7 +21,7 @@
package org.apache.directory.studio.connection.core.jobs;
-import java.security.cert.X509Certificate;
+import javax.net.ssl.SSLSession;
import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
import org.apache.directory.studio.connection.core.Connection;
@@ -38,7 +38,7 @@ public class CheckNetworkParameterRunnable implements StudioConnectionRunnableWi
{
private Connection connection;
- private X509Certificate[] serverCertificates;
+ private SSLSession sslSession;
/**
* Creates a new instance of CheckNetworkParameterJob.
@@ -79,7 +79,8 @@ public class CheckNetworkParameterRunnable implements StudioConnectionRunnableWi
monitor.reportProgress( " " ); //$NON-NLS-1$
monitor.worked( 1 );
- this.serverCertificates = connection.getConnectionWrapper().connect( monitor );
+ connection.getConnectionWrapper().connect( monitor );
+ this.sslSession = connection.getConnectionWrapper().getSslSession();
connection.getConnectionWrapper().disconnect();
}
@@ -102,9 +103,8 @@ public class CheckNetworkParameterRunnable implements StudioConnectionRunnableWi
}
- public X509Certificate[] getServerCertificates()
+ public SSLSession getSslSession()
{
- return serverCertificates;
-
+ return sslSession;
}
}
diff --git a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
index fa17ef514..70f3aca63 100644
--- a/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
+++ b/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
@@ -21,10 +21,14 @@
package org.apache.directory.studio.connection.ui.widgets;
+import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.Date;
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSession;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.directory.api.ldap.model.url.LdapUrl;
import org.apache.directory.api.ldap.model.url.LdapUrl.Extension;
@@ -463,10 +467,16 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
if ( status.isOK() )
{
- MessageDialog.openInformation( Display.getDefault().getActiveShell(), Messages
- .getString( "NetworkParameterPage.CheckNetworkParameter" ), //$NON-NLS-1$
- Messages
- .getString( "NetworkParameterPage.ConnectionEstablished" ) ); //$NON-NLS-1$
+ String title = Messages.getString( "NetworkParameterPage.CheckNetworkParameter" ); //$NON-NLS-1$
+ String message = Messages.getString( "NetworkParameterPage.ConnectionEstablished" ); //$NON-NLS-1$
+
+ SSLSession sslSession = runnable.getSslSession();
+ if ( sslSession != null )
+ {
+ message += "\n\nProtocol: " + sslSession.getProtocol();
+ message += "\nCipher Suite: " + sslSession.getCipherSuite();
+ }
+ MessageDialog.openInformation( Display.getDefault().getActiveShell(), title, message );
}
}
} );
@@ -482,8 +492,21 @@ public class NetworkParameterPage extends AbstractConnectionParameterPage
if ( status.isOK() )
{
- X509Certificate[] serverCertificates = runnable.getServerCertificates();
- new CertificateInfoDialog( Display.getDefault().getActiveShell(), serverCertificates ).open();
+ try
+ {
+ SSLSession sslSession = runnable.getSslSession();
+ Certificate[] certificates = sslSession.getPeerCertificates();
+ X509Certificate[] serverCertificates = new X509Certificate[certificates.length];
+ for ( int i = 0; i < certificates.length; i++ )
+ {
+ serverCertificates[i] = ( X509Certificate ) certificates[i];
+ }
+ new CertificateInfoDialog( Display.getDefault().getActiveShell(), serverCertificates ).open();
+ }
+ catch ( SSLPeerUnverifiedException e )
+ {
+ throw new RuntimeException( e );
+ }
}
}
} );
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java
index 2509959f3..6616b9963 100644
--- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java
+++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java
@@ -57,6 +57,8 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import javax.naming.directory.SearchControls;
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSession;
import org.apache.directory.api.ldap.codec.api.LdapApiService;
import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
@@ -168,11 +170,11 @@ public class DirectoryApiConnectionWrapperTest
assertFalse( connectionWrapper.isConnected() );
- X509Certificate[] certificates = connectionWrapper.connect( monitor );
+ connectionWrapper.connect( monitor );
assertTrue( connectionWrapper.isConnected() );
assertFalse( connectionWrapper.isSecured() );
+ assertNull( connectionWrapper.getSslSession() );
assertNull( monitor.getException() );
- assertNull( certificates );
connectionWrapper.disconnect();
assertFalse( connectionWrapper.isConnected() );
@@ -194,11 +196,11 @@ public class DirectoryApiConnectionWrapperTest
assertFalse( connectionWrapper.isConnected() );
- X509Certificate[] certificates = connectionWrapper.connect( monitor );
+ connectionWrapper.connect( monitor );
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
- assertNotNull( certificates );
connectionWrapper.disconnect();
assertFalse( connectionWrapper.isConnected() );
@@ -219,11 +221,11 @@ public class DirectoryApiConnectionWrapperTest
assertFalse( connectionWrapper.isConnected() );
- X509Certificate[] certificates = connectionWrapper.connect( monitor );
+ connectionWrapper.connect( monitor );
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
- assertNotNull( certificates );
connectionWrapper.disconnect();
assertFalse( connectionWrapper.isConnected() );
@@ -268,6 +270,31 @@ public class DirectoryApiConnectionWrapperTest
}
+ private void assertSslSession( TestLdapServer ldapServer )
+ {
+ try
+ {
+ SSLSession sslSession = connectionWrapper.getSslSession();
+ assertNotNull( sslSession );
+ assertNotNull( sslSession.getProtocol() );
+ assertNotNull( sslSession.getCipherSuite() );
+ assertNotNull( sslSession.getPeerCertificates() );
+ if ( ldapServer.getType() == LdapServerType.ApacheDS )
+ {
+ assertEquals( "TLSv1.2", sslSession.getProtocol() );
+ }
+ else
+ {
+ assertEquals( "TLSv1.3", sslSession.getProtocol() );
+ }
+ }
+ catch ( SSLPeerUnverifiedException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+
/**
* Test binding to the server using simple auth and no encryption.
*/
@@ -340,6 +367,7 @@ public class DirectoryApiConnectionWrapperTest
connectionWrapper.bind( monitor );
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
connectionWrapper.unbind();
@@ -368,6 +396,7 @@ public class DirectoryApiConnectionWrapperTest
connectionWrapper.bind( monitor );
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
connectionWrapper.unbind();
@@ -510,6 +539,7 @@ public class DirectoryApiConnectionWrapperTest
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
connectionWrapper.unbind();
@@ -568,6 +598,7 @@ public class DirectoryApiConnectionWrapperTest
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
connectionWrapper.unbind();
@@ -696,6 +727,7 @@ public class DirectoryApiConnectionWrapperTest
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
connectionWrapper.unbind();
@@ -757,6 +789,7 @@ public class DirectoryApiConnectionWrapperTest
assertTrue( connectionWrapper.isConnected() );
assertTrue( connectionWrapper.isSecured() );
+ assertSslSession( ldapServer );
assertNull( monitor.getException() );
connectionWrapper.unbind();
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 0fd4ff6a4..929cfc01f 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
@@ -88,7 +88,7 @@ public class OpenLdapServer extends TestLdapServer
{
if ( confidentialityRequired )
{
- setSecurityProps( 256, 256 );
+ setSecurityProps( 128, 128 );
}
else
{
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java
index eec6da003..6b04ad839 100644
--- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java
+++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java
@@ -22,6 +22,7 @@ package org.apache.directory.studio.test.integration.junit5;
import java.net.InetAddress;
+import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -102,9 +103,9 @@ public class TestFixture
public static void skipIfKdcServerIsNotAvailable()
{
boolean available = false;
- try
+ try(Socket s = new Socket(KDC_HOST, KDC_PORT))
{
- available = InetAddress.getByName( KDC_HOST ).isReachable( 3 );
+ available = true;
}
catch ( Exception e )
{
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 f0fe345e3..bf3290cb2 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
@@ -91,14 +91,14 @@ public abstract class TestLdapServer
}
- public LdapConnection openConnection() throws LdapException
+ public LdapNetworkConnection openConnection() throws LdapException
{
LdapConnectionConfig config = new LdapConnectionConfig();
config.setLdapHost( host );
config.setLdapPort( port );
config.setUseTls( true );
config.setTrustManagers( new NoVerificationTrustManager() );
- LdapConnection connection = new LdapNetworkConnection( config );
+ LdapNetworkConnection connection = new LdapNetworkConnection( config );
connection.connect();
return connection;
}
diff --git a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/OpenLdapConfig.ldif b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/OpenLdapConfig.ldif
index c9cdc8f70..1cf98b3dd 100644
--- a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/OpenLdapConfig.ldif
+++ b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/OpenLdapConfig.ldif
@@ -42,4 +42,7 @@ olcAuthzRegexp: uid=([^,]*),cn=cram-md5,cn=auth uid=$1,ou=users,dc=example,dc=or
replace: olcSaslSecProps
olcSaslSecProps: noplain,noanonymous,minssf=0
-
+replace: olcTLSCipherSuite
+olcTLSCipherSuite: SECURE256:+SECURE128:-VERS-TLS-ALL:+VERS-TLS1.3:+VERS-TLS1.2:-RSA:-DHE-DSS:-CAMELLIA-128-CBC:-CAMELLIA-256-CBC
+-
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java
index 54b555c43..094e25f64 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java
@@ -61,6 +61,7 @@ import org.apache.directory.studio.test.integration.ui.bots.CertificateTrustDial
import org.apache.directory.studio.test.integration.ui.bots.CertificateValidationPreferencePageBot;
import org.apache.directory.studio.test.integration.ui.bots.CertificateViewerDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.CheckAuthenticationDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.DialogBot.CheckResponse;
import org.apache.directory.studio.test.integration.ui.bots.ErrorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.NewConnectionWizardBot;
import org.apache.directory.studio.test.integration.ui.bots.PreferencesBot;
@@ -323,8 +324,8 @@ public class CertificateValidationTest extends AbstractTestBase
wizardBotWithLdaps( server, false );
// check the certificate, should be OK
- String result = wizardBot.clickCheckNetworkParameterButton();
- assertNull( result, "Expected OK, valid and trusted certificate" );
+ CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertFalse( checkResponse.isError(), "Expected OK, valid and trusted certificate" );
// view the certificate
CertificateViewerDialogBot certificateViewerBot = wizardBot.clickViewCertificateButton();
@@ -499,8 +500,8 @@ public class CertificateValidationTest extends AbstractTestBase
wizardBot.selectStartTlsEncryption();
// check the certificate, should be OK
- String result = wizardBot.clickCheckNetworkParameterButton();
- assertNull( result, "Expected OK, valid and trusted certificate" );
+ CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertFalse( checkResponse.isError(), "Expected OK, valid and trusted certificate" );
// view the certificate
CertificateViewerDialogBot certificateViewerBot = wizardBot.clickViewCertificateButton();
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java
index 43f21dfd7..24bb67d98 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewConnectionWizardTest.java
@@ -22,6 +22,7 @@ package org.apache.directory.studio.test.integration.ui;
import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -52,6 +53,7 @@ import org.apache.directory.studio.test.integration.junit5.OpenLdapServer;
import org.apache.directory.studio.test.integration.junit5.TestFixture;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.CertificateTrustDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.DialogBot.CheckResponse;
import org.apache.directory.studio.test.integration.ui.bots.ErrorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.NewConnectionWizardBot;
import org.apache.mina.util.AvailablePortFinder;
@@ -388,15 +390,19 @@ public class NewConnectionWizardTest extends AbstractTestBase
wizardBot.typePort( server.getPort() );
// click "Check Network Parameter" button
- String result = wizardBot.clickCheckNetworkParameterButton();
- assertNull( result, "Expected OK" );
+ CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertFalse( checkResponse.isError(), "Expected OK" );
+ assertThat( checkResponse.getMessage(), not( containsString( "Protocol" ) ) );
+ assertThat( checkResponse.getMessage(), not( containsString( "Cipher Suite" ) ) );
// enter IPv4 address as host
wizardBot.typeHost( InetAddress.getByName( server.getHost() ).getHostAddress() );
// click "Check Network Parameter" button
- result = wizardBot.clickCheckNetworkParameterButton();
- assertNull( result, "Expected OK" );
+ checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertFalse( checkResponse.isError(), "Expected OK" );
+ assertThat( checkResponse.getMessage(), not( containsString( "Protocol" ) ) );
+ assertThat( checkResponse.getMessage(), not( containsString( "Cipher Suite" ) ) );
// enter hostname as host again
wizardBot.typeHost( server.getHost() );
@@ -409,7 +415,7 @@ public class NewConnectionWizardTest extends AbstractTestBase
wizardBot.typePassword( server.getAdminPassword() );
// click "Check Network Parameter" button
- result = wizardBot.clickCheckAuthenticationButton();
+ String result = wizardBot.clickCheckAuthenticationButton();
assertNull( result, "Expected OK" );
finishAndAssertConnection( server, EncryptionMethod.NONE, AuthenticationMethod.SIMPLE,
@@ -1062,15 +1068,18 @@ public class NewConnectionWizardTest extends AbstractTestBase
// Invalid port
wizardBot.typePort( getInvalidPort() );
- String result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
+ CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertTrue( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
// Invalid host
String hostname = getInvalidHostName();
wizardBot.typeHost( hostname );
- result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
- assertThat( "Unknown host name must occur in error message", result, containsString( hostname ) );
+ checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertTrue( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
+ assertThat( "Unknown host name must occur in error message", checkResponse.getMessage(),
+ containsString( hostname ) );
wizardBot.clickCancelButton();
}
@@ -1085,20 +1094,24 @@ public class NewConnectionWizardTest extends AbstractTestBase
// Invalid port
wizardBot.typePort( getInvalidPort() );
- String result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
+ CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertTrue( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
// Non ldaps port
wizardBot.typePort( server.getPort() );
- result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
+ checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertTrue( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
// Invalid host
String hostname = getInvalidHostName();
wizardBot.typeHost( hostname );
- result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
- assertThat( "Unknown host name must occur in error message", result, containsString( hostname ) );
+ checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertTrue( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
+ assertThat( "Unknown host name must occur in error message", checkResponse.getMessage(),
+ containsString( hostname ) );
wizardBot.clickCancelButton();
}
@@ -1113,20 +1126,24 @@ public class NewConnectionWizardTest extends AbstractTestBase
// Invalid port
wizardBot.typePort( getInvalidPort() );
- String result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
+ CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertTrue( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
// Ldaps port
wizardBot.typePort( server.getPortSSL() );
- result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
+ assertTrue( checkResponse.isError() );
+ checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
// Invalid host
String hostname = getInvalidHostName();
wizardBot.typeHost( hostname );
- result = wizardBot.clickCheckNetworkParameterButton();
- assertThat( result, containsString( "The connection failed" ) );
- assertThat( "Unknown host name must occur in error message", result, containsString( hostname ) );
+ checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertTrue( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "The connection failed" ) );
+ assertThat( "Unknown host name must occur in error message", checkResponse.getMessage(),
+ containsString( hostname ) );
wizardBot.clickCancelButton();
}
@@ -1155,6 +1172,11 @@ public class NewConnectionWizardTest extends AbstractTestBase
trustDialog.selectTrustPermanent();
trustDialog.clickOkButton();
bot.button( "OK" ).click();
+
+ CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
+ assertFalse( checkResponse.isError() );
+ assertThat( checkResponse.getMessage(), containsString( "Protocol" ) );
+ assertThat( checkResponse.getMessage(), containsString( "Cipher Suite" ) );
}
wizardBot.clickNextButton();
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
index 00a578197..fda933768 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
@@ -138,7 +138,7 @@ public abstract class DialogBot
}
- protected String clickCheckButton( final String label, final String title )
+ protected CheckResponse clickCheckButton( final String label, final String title )
{
SWTBotShell parentShell = bot.activeShell();
SWTBotShell shell = BotUtils.shell( new Runnable()
@@ -151,21 +151,54 @@ public abstract class DialogBot
String shellText = shell.getText();
// label(0) may be the image
- String labelText = bot.label( 0 ).getText();
- if ( StringUtils.isBlank( labelText ) )
+ String messageText = bot.label( 0 ).getText();
+ if ( StringUtils.isBlank( messageText ) )
{
- labelText = bot.label( 1 ).getText();
+ messageText = bot.label( 1 ).getText();
}
bot.button( "OK" ).click();
parentShell.activate();
if ( shellText.equals( title ) )
{
- return null;
+ return new CheckResponse( false, shellText, messageText );
}
else
{
- return labelText;
+ return new CheckResponse( true, shellText, messageText );
}
}
+
+ public static class CheckResponse
+ {
+ boolean isError;
+ String title;
+ String message;
+
+ public CheckResponse( boolean isError, String title, String message )
+ {
+ this.isError = isError;
+ this.title = title;
+ this.message = message;
+ }
+
+
+ public boolean isError()
+ {
+ return isError;
+ }
+
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ }
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
index 029b6c10a..1591c4a64 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
@@ -434,8 +434,9 @@ public class NewConnectionWizardBot extends WizardBot
*
* @return null if the OK dialog pops up, the error message if the error dialog pops up
*/
- public String clickCheckNetworkParameterButton()
+ public CheckResponse clickCheckNetworkParameterButton()
{
+ activate();
return clickCheckButton( CHECK_NETWORK_PARAMETER, CHECK_NETWORK_PARAMETER );
}
@@ -458,7 +459,8 @@ public class NewConnectionWizardBot extends WizardBot
*/
public String clickCheckAuthenticationButton()
{
- return clickCheckButton( CHECK_AUTHENTICATION, CHECK_AUTHENTICATION );
+ CheckResponse checkResponse = clickCheckButton( CHECK_AUTHENTICATION, CHECK_AUTHENTICATION );
+ return checkResponse.isError() ? checkResponse.getMessage() : null;
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
index acc246448..0a0e3d0f4 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
@@ -103,13 +103,15 @@ public class PasswordEditorDialogBot extends DialogBot
public String clickVerifyButton()
{
- return clickCheckButton( "Verify", "Password Verification" );
+ CheckResponse checkResponse = clickCheckButton( "Verify", "Password Verification" );
+ return checkResponse.isError() ? checkResponse.getMessage() : null;
}
public String clickBindButton()
{
- return clickCheckButton( "Bind", "Check Authentication" );
+ CheckResponse checkResponse = clickCheckButton( "Bind", "Check Authentication" );
+ return checkResponse.isError() ? checkResponse.getMessage() : null;
}
}