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/07 20:50:31 UTC

[directory-server] branch master updated: DIRAPI-342: Add tests to demostrate the problem

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 770a8ab  DIRAPI-342: Add tests to demostrate the problem
770a8ab is described below

commit 770a8ab20fb9c9a5a1d4a3d8c5ac3349252c915a
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Tue May 7 22:49:12 2019 +0200

    DIRAPI-342: Add tests to demostrate the problem
---
 .../api/operations/bind/SimpleBindRequestTest.java | 22 +++++++++++++++++++++
 .../server/operations/bind/DelegatedAuthIT.java    |  7 +++++++
 .../server/operations/bind/SimpleBindIT.java       | 23 ++++++++++++++++++++++
 3 files changed, 52 insertions(+)

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 6b53575..f2a6bce 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
@@ -650,4 +650,26 @@ public class SimpleBindRequestTest extends AbstractLdapTestUnit
         cursor2.next();
         cursor3.next();
     }
+
+
+    /**
+     * Test simple bind and unbind in a loop.
+     */
+    @Test
+    public void testSimpleBindAndUnbindLoop() throws Exception
+    {
+        for ( int i = 0; i < 10000; i++ )
+        {
+            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/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java b/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
index b179a70..91f67ac 100644
--- a/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
 
 import org.apache.directory.api.ldap.model.exception.LdapAuthenticationException;
 import org.apache.directory.api.util.Network;
+import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -36,6 +37,7 @@ import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.authn.DelegatingAuthenticator;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -74,6 +76,11 @@ import org.junit.runner.RunWith;
     allowAnonymousAccess = true)
 public class DelegatedAuthIT extends AbstractLdapTestUnit
 {
+
+    @Rule
+    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( 1, 1000 );
+
+
     /**
      * Test with bindDn which is not even found under any namingContext of the
      * server.
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 188e450..cdc3ad8 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
@@ -518,4 +518,27 @@ public class SimpleBindIT extends AbstractLdapTestUnit
                 new SimpleAuthenticator( Dn.ROOT_DSE ),
                 new AnonymousAuthenticator( Dn.ROOT_DSE ) } );
     }
+
+
+    @Test
+    public void testSimpleBindAndUnbindLoop() throws Exception
+    {
+        try ( LdapNetworkConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME,
+            getLdapServer().getPort() ) )
+        {
+            for ( int i = 0; i < 10000; i++ )
+            {
+                System.out.println( i );
+
+                connection.bind( "uid=admin,ou=system", "secret" );
+                assertTrue( connection.isAuthenticated() );
+
+                connection.unBind();
+                assertFalse( connection.isAuthenticated() );
+
+                // Thread.sleep( 10L );
+            }
+        }
+    }
+
 }