You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2019/05/26 21:05:37 UTC
[directory-server] branch master updated: Update to next LDAP API
version. Add/change tests for DIRAPI-342.
This is an automated email from the ASF dual-hosted git repository.
seelmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git
The following commit(s) were added to refs/heads/master by this push:
new e77e2b0 Update to next LDAP API version. Add/change tests for DIRAPI-342.
e77e2b0 is described below
commit e77e2b0a6e0de83b90db0c07999c410660821ec2
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Sun May 26 23:04:42 2019 +0200
Update to next LDAP API version. Add/change tests for DIRAPI-342.
---
.../shared/client/api/LdapConnectionTest.java | 70 +++++++++-------------
.../shared/client/api/LdapSSLConnectionTest.java | 59 +++++++++++++++++-
.../api/operations/bind/SimpleBindRequestTest.java | 24 --------
pom.xml | 2 +-
.../server/operations/bind/SimpleBindIT.java | 14 ++---
.../apache/directory/server/UberJarMainTest.java | 1 +
6 files changed, 93 insertions(+), 77 deletions(-)
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
index f00d6c5..6e75419 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
@@ -56,7 +56,6 @@ import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -115,57 +114,45 @@ public class LdapConnectionTest extends AbstractLdapTestUnit
}
+ /**
+ * Test for DIRAPI-342: Unbind breaks connection
+ */
@Test
- @Ignore
- public void testRebindNoPool() throws Exception
+ public void testBindAndUnbindLoop() throws Exception
{
- LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
- connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
-
- for ( int i = 0; i < 10000; i++ )
+ try ( LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME,
+ getLdapServer().getPort() ) )
{
- if ( i % 100 == 0 )
- {
- System.out.println( "Iteration # " + i );
- }
- // First, unbind
- try
+ for ( int i = 0; i < 1000; i++ )
{
+ connection.bind( "uid=admin,ou=system", "secret" );
+ assertTrue( connection.isAuthenticated() );
+
connection.unBind();
+ assertFalse( connection.isAuthenticated() );
}
- catch ( Exception e )
- {
- e.printStackTrace();
- throw e;
- }
+ }
+ }
- //Thread.sleep( 5 );
- // Don't close the connection, we want to reuse it
- // Then bind again
- try
- {
- connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
- }
- catch ( Exception e )
+ /**
+ * Test for DIRAPI-342: Unbind breaks connection
+ */
+ @Test
+ public void testBindAndCloseLoop() throws Exception
+ {
+ try ( LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME,
+ getLdapServer().getPort() ) )
+ {
+ for ( int i = 0; i < 1000; i++ )
{
- System.out.println( "Failure after " + i + " iterations" );
- e.printStackTrace();
- throw e;
- }
- }
+ connection.bind( "uid=admin,ou=system", "secret" );
+ assertTrue( connection.isAuthenticated() );
- // terminate with an unbind
- try
- {
- connection.unBind();
- }
- catch ( Exception e )
- {
- e.printStackTrace();
+ connection.close();
+ assertFalse( connection.isAuthenticated() );
+ }
}
-
- connection.close();
}
@@ -376,4 +363,5 @@ public void testLookup() throws Exception
connection.close();
}
+
}
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
index a6a1c5a..3843128 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
@@ -127,7 +127,6 @@ public class LdapSSLConnectionTest extends AbstractLdapTestUnit
@Test
public void testBindRequestSSLConfig() throws Exception
{
- System.out.println( sslConfig.getLdapPort() );
try ( LdapNetworkConnection connection = new LdapNetworkConnection( sslConfig ) )
{
connection.bind( "uid=admin,ou=system", "secret" );
@@ -198,6 +197,35 @@ public class LdapSSLConnectionTest extends AbstractLdapTestUnit
/**
+ * Test for DIRAPI-342: Unbind breaks connection
+ */
+ @Test
+ public void testSSLConnectAndBindAndUnbindLoop() throws Exception
+ {
+ try ( LdapNetworkConnection connection = new LdapNetworkConnection( sslConfig ) )
+ {
+ for ( int i = 0; i < 100; i++ )
+ {
+ connection.connect();
+ assertTrue( connection.isConnected() );
+ assertTrue( connection.isSecured() );
+ assertFalse( connection.isAuthenticated() );
+
+ connection.bind( "uid=admin,ou=system", "secret" );
+ assertTrue( connection.isConnected() );
+ assertTrue( connection.isSecured() );
+ assertTrue( connection.isAuthenticated() );
+
+ connection.unBind();
+ assertFalse( connection.isSecured() );
+ assertFalse( connection.isConnected() );
+ assertFalse( connection.isAuthenticated() );
+ }
+ }
+ }
+
+
+ /**
* Test a successful bind request after setting up TLS
*
* @throws IOException
@@ -335,6 +363,35 @@ public class LdapSSLConnectionTest extends AbstractLdapTestUnit
}
+ /**
+ * Test for DIRAPI-342: Unbind breaks connection
+ */
+ @Test
+ public void testStartTLSConnectAndBindAndUnbindLoop() throws Exception
+ {
+ try ( LdapNetworkConnection connection = new LdapNetworkConnection( tlsConfig ) )
+ {
+ for ( int i = 0; i < 100; i++ )
+ {
+ connection.startTls();
+ assertTrue( connection.isConnected() );
+ assertTrue( connection.isSecured() );
+ assertFalse( connection.isAuthenticated() );
+
+ connection.bind( "uid=admin,ou=system", "secret" );
+ assertTrue( connection.isConnected() );
+ assertTrue( connection.isSecured() );
+ assertTrue( connection.isAuthenticated() );
+
+ connection.unBind();
+ assertFalse( connection.isConnected() );
+ assertFalse( connection.isSecured() );
+ assertFalse( connection.isAuthenticated() );
+ }
+ }
+ }
+
+
@Test
public void testGetSupportedControlsWithStartTLS() throws Exception
{
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
index 102e4c7..711cf55 100644
--- a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
@@ -651,28 +651,4 @@ public class SimpleBindRequestTest extends AbstractLdapTestUnit
cursor3.next();
}
-
- /**
- * Test simple bind and unbind in a loop.
- */
- @Test
- public void testSimpleBindAndUnbindLoop() throws Exception
- {
- for ( int i = 0; i < 1000; i++ )
- {
- if ( i % 100 == 0 )
- {
- System.out.println( i );
- }
-
- connection.bind( "uid=admin,ou=system", "secret" );
- assertTrue( connection.isAuthenticated() );
-
- connection.unBind();
- assertFalse( connection.isAuthenticated() );
-
- // Thread.sleep( 10L );
- }
- }
-
}
diff --git a/pom.xml b/pom.xml
index bcf3c47..e0699f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,7 @@
<!--additionalparam>-Xdoclint:none</additionalparam-->
<!-- Set versions for depending projects -->
- <org.apache.directory.api.version>2.0.0.AM3</org.apache.directory.api.version>
+ <org.apache.directory.api.version>2.0.0.AM4-SNAPSHOT</org.apache.directory.api.version>
<org.apache.directory.mavibot.version>1.0.0-M8</org.apache.directory.mavibot.version>
<org.apache.directory.checkstyle-configuration.version>2.0.1-SNAPSHOT</org.apache.directory.checkstyle-configuration.version>
<org.apache.directory.junit.junit-addons.version>2.0.0</org.apache.directory.junit.junit-addons.version>
diff --git a/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
index 30a3ad8..a8b8d99 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
@@ -520,32 +520,26 @@ public class SimpleBindIT extends AbstractLdapTestUnit
}
+ /**
+ * Test for DIRAPI-342: Unbind breaks connection
+ */
@Test
public void testSimpleBindAndUnbindLoop() throws Exception
{
- long t0 = System.currentTimeMillis();
try ( LdapNetworkConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME,
getLdapServer().getPort() ) )
{
for ( int i = 0; i < 1000; i++ )
{
- if ( i % 100 == 0 )
- {
- System.out.println( i );
- }
-
connection.bind( "uid=admin,ou=system", "secret" );
assertTrue( connection.isAuthenticated() );
connection.unBind();
assertFalse( connection.isAuthenticated() );
- // Thread.sleep( 2L );
+ Thread.sleep( 2L );
}
}
- long t1 = System.currentTimeMillis();
-
- System.out.println( "Delta = " + ( t1 - t0 ) );
}
}
diff --git a/service/src/test/java/org/apache/directory/server/UberJarMainTest.java b/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
index ce83a09..a793853 100644
--- a/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
+++ b/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
@@ -150,6 +150,7 @@ public class UberJarMainTest
configuration.setCredentials( PartitionNexus.ADMIN_PASSWORD_STRING );
configuration.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector( null ) );
LdapConnection connection = new LdapNetworkConnection( configuration );
+ connection.connect();
connection.loadSchema();
// Binding on the connection