Skip to content

Commit

Permalink
Fix for DIRSERVER-2408, 2409
Browse files Browse the repository at this point in the history
  • Loading branch information
elecharny committed Aug 13, 2024
1 parent a43ad64 commit 2f220c1
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 87 deletions.
4 changes: 2 additions & 2 deletions i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,8 @@ public enum I18n
ERR_640("ERR_640"),
ERR_641("ERR_641"),
ERR_642("ERR_642"),
// ERR_643( "ERR_643" ),
// ERR_644( "ERR_644" ),
ERR_643( "ERR_643" ),
ERR_644( "ERR_644" ),
// ERR_645( "ERR_645" ),
ERR_646("ERR_646"),
ERR_647("ERR_647"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ ERR_639=Class {0} is not a descendant of DhcpOption
ERR_640=Can''t initialize option field classes
ERR_641=Max data length: 128 bytes.
ERR_642=ASCII encoding unavailable
# ERR_643=
# ERR_644=
ERR_643=Not enough data in the buffer
ERR_644=Negative index in the buffer
# ERR_645=
ERR_646=Record type to objectClass mapping has not been set.
ERR_647=ResourceRecord requires STRUCTURAL objectClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
import org.apache.directory.api.util.exception.Exceptions;
import org.apache.directory.ldap.client.api.DefaultSchemaLoader;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
Expand All @@ -49,13 +49,13 @@
{ @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
public class AdsSchemaLoaderTest extends AbstractLdapTestUnit
{
private LdapConnection connection;
private PooledLdapConnection connection;


@BeforeEach
public void setup() throws Exception
{
connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.LdapConnectionConfig;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.ldap.client.api.exception.InvalidConnectionException;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
Expand All @@ -70,13 +71,13 @@ public class LdapConnectionTest extends AbstractLdapTestUnit
{
private static final String ADMIN_DN = "uid=admin,ou=system";

private LdapConnection connection;
private PooledLdapConnection connection;


@BeforeEach
public void setup() throws Exception
{
connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
}


Expand Down Expand Up @@ -234,7 +235,7 @@ public void testRetrieveBinaryAttibute() throws Exception
assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );

// Now, test using the scerver's schema
( ( LdapNetworkConnection ) connection ).loadSchema();
( ( LdapNetworkConnection ) connection.wrapped() ).loadSchema();
connection.bind( "uid=admin,ou=system", "secret" );

// Use the default list of binary Attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
import org.apache.directory.api.util.exception.Exceptions;
import org.apache.directory.ldap.client.api.DefaultSchemaLoader;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
Expand All @@ -53,13 +53,13 @@
{ @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
public class ServerSchemaLoaderTest extends AbstractLdapTestUnit
{
private LdapConnection connection;
private PooledLdapConnection connection;


@BeforeEach
public void setup() throws Exception
{
connection = LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.ldap.client.api.future.SearchFuture;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
Expand All @@ -64,15 +65,15 @@ public class ClientAbandonRequestTest extends AbstractLdapTestUnit
{
private static final int numEntries = 100;
private DelayInducingInterceptor delayInterceptor;
private LdapNetworkConnection connection;
private PooledLdapConnection connection;


@BeforeEach
public void setup() throws Exception
{
delayInterceptor = new DelayInducingInterceptor();
getLdapServer().getDirectoryService().addFirst( delayInterceptor );
connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );

// injecting some values to keep the
// followed search operation to run for a while
Expand Down Expand Up @@ -113,7 +114,7 @@ public void testCancelSearch() throws Exception
sr.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );

// Launch the search now
SearchFuture searchFuture = connection.searchAsync( sr );
SearchFuture searchFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).searchAsync( sr );

Response searchResponse = null;
int count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.directory.api.util.Strings;
import org.apache.directory.api.util.TimeProvider;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.ldap.client.api.future.AddFuture;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
Expand All @@ -77,14 +78,14 @@
{ @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
public class ClientAddRequestTest extends AbstractLdapTestUnit
{
private LdapNetworkConnection connection;
private PooledLdapConnection connection;
private CoreSession session;


@BeforeEach
public void setup() throws Exception
{
connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ) );
session = getLdapServer().getDirectoryService().getAdminSession();
}

Expand Down Expand Up @@ -182,7 +183,7 @@ public void testAddAsync() throws Exception
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry( entry );

AddFuture addFuture = connection.addAsync( addRequest );
AddFuture addFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).addAsync( addRequest );

AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );

Expand All @@ -207,7 +208,7 @@ public void testAddAsyncLdif() throws Exception
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry( entry );

AddFuture addFuture = connection.addAsync( addRequest );
AddFuture addFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).addAsync( addRequest );

AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );

Expand Down Expand Up @@ -428,7 +429,7 @@ public void testAddNullValueSchemaAware() throws LdapException, IOException
assertTrue( Strings.isEmpty( userPassword ) );
assertTrue( Strings.isEmpty( mail ) );

connection.close();
//connection.close();
}


Expand Down Expand Up @@ -461,6 +462,6 @@ public void testAddUidWithDash() throws LdapException, IOException
assertNotNull( found.get( "userPassword" ) );
assertTrue( found.contains( "uid", "Hi" ) );

connection.close();
//connection.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.ldap.client.api.future.CompareFuture;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
Expand All @@ -57,14 +58,14 @@
{ @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
public class ClientCompareRequestTest extends AbstractLdapTestUnit
{
private LdapNetworkConnection connection;
private PooledLdapConnection connection;
private CoreSession session;


@BeforeEach
public void setup() throws Exception
{
connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
session = getLdapServer().getDirectoryService().getAdminSession();
}

Expand Down Expand Up @@ -105,7 +106,7 @@ public void testCompareAsync() throws Exception

assertTrue( session.exists( dn ) );

CompareFuture compareFuture = connection.compareAsync( compareRequest );
CompareFuture compareFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).compareAsync( compareRequest );

CompareResponse compareResponse = compareFuture.get( 1000, TimeUnit.MILLISECONDS );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.directory.api.ldap.model.message.controls.OpaqueControl;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.ldap.client.api.future.DeleteFuture;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
Expand Down Expand Up @@ -86,14 +87,14 @@
"sn: grand_child12_sn" })
public class ClientDeleteRequestTest extends AbstractLdapTestUnit
{
private LdapNetworkConnection connection;
private PooledLdapConnection connection;
private CoreSession session;


@BeforeEach
public void setup() throws Exception
{
connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
session = getLdapServer().getDirectoryService().getAdminSession();
}

Expand Down Expand Up @@ -142,7 +143,7 @@ public void testDeleteWithCascadeControl() throws Exception

if ( connection.isControlSupported( "1.2.840.113556.1.4.805" ) )
{
connection.deleteTree( "cn=parent,ou=system" );
( ( LdapNetworkConnection ) connection.wrapped() ).deleteTree( "cn=parent,ou=system" );

assertFalse( session.exists( "cn=parent,ou=system" ) );
}
Expand Down Expand Up @@ -193,7 +194,7 @@ public void testDeleteAsyncWithoutCascadeControl() throws Exception

try
{
connection.deleteTree( "cn=parent,ou=system" );
( ( LdapNetworkConnection ) connection.wrapped() ).deleteTree( "cn=parent,ou=system" );
fail();
}
catch ( LdapException le )
Expand All @@ -211,7 +212,7 @@ public void testDeleteAsync() throws Exception
DeleteRequest deleteRequest = new DeleteRequestImpl();
deleteRequest.setName( new Dn( "cn=grand_child12,cn=child1,cn=parent,ou=system" ) );

DeleteFuture deleteFuture = connection.deleteAsync( deleteRequest );
DeleteFuture deleteFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).deleteAsync( deleteRequest );

DeleteResponse deleteResponse = deleteFuture.get( 1000, TimeUnit.MILLISECONDS );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.directory.api.ldap.model.message.ExtendedResponse;
import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.ldap.client.api.future.ExtendedFuture;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
Expand Down Expand Up @@ -61,13 +62,13 @@
{ StartTlsHandler.class })
public class ClientExtendedRequestTest extends AbstractLdapTestUnit
{
private LdapNetworkConnection connection;
private PooledLdapConnection connection;


@BeforeEach
public void setup() throws Exception
{
connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
}


Expand All @@ -81,41 +82,24 @@ public void shutdown() throws Exception
@Test
public void testExtended() throws Exception
{
try
{
ExtendedResponse response = connection.extended( StartTlsRequest.OID );
assertNotNull( response );
assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
}
finally
{
// close connection to stop TLS
connection.close();
}
ExtendedResponse response = connection.extended( StartTlsRequest.OID );
assertNotNull( response );
assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
}


@Test
public void testExtendedAsync() throws Exception
{
try
{
ExtendedRequest extendedRequest = new StartTlsRequestImpl();
extendedRequest.setRequestName( StartTlsRequest.OID );
ExtendedRequest extendedRequest = new StartTlsRequestImpl();
extendedRequest.setRequestName( StartTlsRequest.OID );

ExtendedFuture extendedFuture = connection.extendedAsync( extendedRequest );
ExtendedFuture extendedFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).extendedAsync( extendedRequest );

ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture.get( 1000, TimeUnit.MILLISECONDS );

assertNotNull( extendedResponse );
assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
assertTrue( connection.isAuthenticated() );
}
finally
{
// close connection to stop TLS
connection.close();
}
ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture.get( 1000, TimeUnit.MILLISECONDS );

assertNotNull( extendedResponse );
assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
assertTrue( connection.isAuthenticated() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.name.Rdn;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.ldap.client.api.PooledLdapConnection;
import org.apache.directory.ldap.client.api.future.ModifyDnFuture;
import org.apache.directory.server.annotations.CreateLdapServer;
import org.apache.directory.server.annotations.CreateTransport;
Expand Down Expand Up @@ -83,14 +84,14 @@ public class ClientModifyDnRequestTest extends AbstractLdapTestUnit
private static final String DN = "cn=modDn,ou=system";
private static final String DN_EMPLOYEE = "employeeNumber=test,ou=system";
private static final String DN_CONTAINER = "ou=container,ou=system";
private LdapNetworkConnection connection;
private PooledLdapConnection connection;
private CoreSession session;


@BeforeEach
public void setup() throws Exception
{
connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
connection = ( PooledLdapConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
session = getLdapServer().getDirectoryService().getAdminSession();
}

Expand Down Expand Up @@ -189,7 +190,7 @@ public void testModifyDnAsync() throws Exception
modDnReq.setNewRdn( new Rdn( "cn=modifyDnWithString" ) );
modDnReq.setDeleteOldRdn( true );

ModifyDnFuture modifyDnFuture = connection.modifyDnAsync( modDnReq );
ModifyDnFuture modifyDnFuture = ( ( LdapNetworkConnection ) connection.wrapped() ).modifyDnAsync( modDnReq );

ModifyDnResponse response = modifyDnFuture.get( 1000, TimeUnit.MILLISECONDS );

Expand Down
Loading

0 comments on commit 2f220c1

Please sign in to comment.