You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/08/07 04:17:10 UTC
svn commit: r683478 - in
/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server:
operations/modifydn/ModifyDnReferralIT.java operations/modifydn/MoveIT.java
suites/StockServerISuite.java
Author: akarasulu
Date: Wed Aug 6 19:17:10 2008
New Revision: 683478
URL: http://svn.apache.org/viewvc?rev=683478&view=rev
Log:
added some tests for the move and moveAndRename operations and added tests for newSuperior referral handling in 3296 section 5.6.2.
Added:
directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java
Modified:
directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java
directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java
Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java?rev=683478&r1=683477&r2=683478&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java Wed Aug 6 19:17:10 2008
@@ -27,6 +27,7 @@
import netscape.ldap.LDAPConstraints;
import netscape.ldap.LDAPControl;
import netscape.ldap.LDAPEntry;
+import netscape.ldap.LDAPException;
import netscape.ldap.LDAPResponse;
import netscape.ldap.LDAPResponseListener;
import netscape.ldap.LDAPSearchConstraints;
@@ -81,7 +82,15 @@
"uid: akarasuluref\n" +
"ref: ldap://localhost:10389/uid=akarasulu,ou=users,ou=system\n" +
"ref: ldap://foo:10389/uid=akarasulu,ou=users,ou=system\n" +
- "ref: ldap://bar:10389/uid=akarasulu,ou=users,ou=system\n\n"
+ "ref: ldap://bar:10389/uid=akarasulu,ou=users,ou=system\n\n" +
+ // Entry # 4
+ "dn: uid=elecharny,ou=users,ou=system\n" +
+ "objectClass: uidObject\n" +
+ "objectClass: person\n" +
+ "objectClass: top\n" +
+ "uid: elecharny\n" +
+ "cn: Emmanuel Lecharny\n" +
+ "sn: lecharny\n\n"
}
)
public class ModifyDnReferralIT
@@ -114,6 +123,31 @@
/**
+ * Tests ModifyDN operation with newSuperior on referral entry with the
+ * ManageDsaIT control.
+ */
+ @Test
+ public void testNewSuperiorOnReferralWithManageDsaITControl() throws Exception
+ {
+ LDAPConnection conn = getWiredConnection( ldapServer );
+ LDAPConstraints constraints = new LDAPSearchConstraints();
+ constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+ constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
+ conn.setConstraints( constraints );
+
+ // ModifyDN success
+ conn.rename( "uid=elecharny,ou=users,ou=system", "uid=newuser",
+ "uid=akarasuluref,ou=users,ou=system", true, constraints );
+ LDAPEntry entry = conn.read( "uid=newuser,uid=akarasuluref,ou=users,ou=system",
+ ( LDAPSearchConstraints ) constraints );
+ assertNotNull( entry );
+ assertEquals( "uid=newuser,uid=akarasuluref,ou=users,ou=system", entry.getDN() );
+
+ conn.disconnect();
+ }
+
+
+ /**
* Tests ModifyDN operation on normal and referral entries without the
* ManageDsaIT control. Referrals are sent back to the client with a
* non-success result code.
@@ -144,6 +178,34 @@
/**
* Tests ModifyDN operation on normal and referral entries without the
+ * ManageDsaIT control. Referrals are sent back to the client with a
+ * non-success result code.
+ */
+ @Test
+ public void testNewSupierorOnReferral() throws Exception
+ {
+ LDAPConnection conn = getWiredConnection( ldapServer );
+ LDAPConstraints constraints = new LDAPConstraints();
+ constraints.setReferrals( false );
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ try
+ {
+ conn.rename( "uid=elecharny,ou=users,ou=system", "uid=ref",
+ "uid=akarasuluref,ou=users,ou=system", true, constraints );
+ }
+ catch ( LDAPException e )
+ {
+ assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
+ }
+
+ conn.disconnect();
+ }
+
+
+ /**
+ * Tests ModifyDN operation on normal and referral entries without the
* ManageDsaIT control using JNDI instead of the Netscape API. Referrals
* are sent back to the client with a non-success result code.
*/
@@ -194,4 +256,32 @@
conn.disconnect();
}
+
+
+ /**
+ * Tests referral handling when an ancestor is a referral.
+ */
+ @Test
+ public void testNewSuperiorAncestorReferral() throws Exception
+ {
+ LOG.debug( "" );
+
+ LDAPConnection conn = getWiredConnection( ldapServer );
+ LDAPConstraints constraints = new LDAPConstraints();
+ conn.setConstraints( constraints );
+
+ // referrals failure
+ try
+ {
+ conn.rename( "uid=elecharny,ou=users,ou=system", "ou=Machines",
+ "ou=Computers,uid=akarasuluref,ou=users,ou=system", true, constraints );
+ fail( "Should never get here to affectsMultipleDSA error result code" );
+ }
+ catch ( LDAPException e )
+ {
+ assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
+ }
+
+ conn.disconnect();
+ }
}
Added: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java?rev=683478&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/MoveIT.java Wed Aug 6 19:17:10 2008
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.server.operations.modifydn;
+
+
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import org.apache.directory.server.newldap.LdapServer;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+
+/**
+ * Test case with different modify DN operations which move the entry under a
+ * new superior.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 679049 $
+ */
+@RunWith ( SiRunner.class )
+@CleanupLevel ( Level.SUITE )
+@ApplyLdifs( {
+ // Entry # 1
+ "dn: uid=akarasulu,ou=users,ou=system\n" +
+ "objectClass: uidObject\n" +
+ "objectClass: person\n" +
+ "objectClass: top\n" +
+ "uid: akarasulu\n" +
+ "cn: Alex Karasulu\n" +
+ "sn: karasulu\n\n" +
+ // Entry # 2
+ "dn: ou=NewSuperior,ou=system\n" +
+ "objectClass: organizationalUnit\n" +
+ "objectClass: top\n" +
+ "ou: NewSuperior\n\n"
+ }
+)
+public class MoveIT
+{
+ private static final String DN = "uid=akarasulu,ou=users,ou=system";
+ private static final String NEW_DN = "uid=akarasulu,ou=NewSuperior,ou=system";
+ private static final String NEW_DN2 = "uid=elecharny,ou=NewSuperior,ou=system";
+
+ public static LdapServer ldapServer;
+
+
+ @Test
+ public void testMoveNoRdnChange() throws Exception
+ {
+ LdapContext ctx = getWiredContext( ldapServer );
+ ctx.rename( DN, NEW_DN );
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ NamingEnumeration<SearchResult> results =
+ ctx.search( NEW_DN, "(objectClass=*)", controls );
+ assertNotNull( results );
+ assertTrue( "Could not find entry after move.", results.hasMore() );
+ SearchResult result = results.next();
+ assertNotNull( result );
+ assertEquals( NEW_DN, result.getNameInNamespace() );
+
+ results.close();
+ ctx.close();
+ }
+
+
+ @Test
+ public void testMoveAndRdnChange() throws Exception
+ {
+ LdapContext ctx = getWiredContext( ldapServer );
+ ctx.rename( DN, NEW_DN2 );
+
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+ NamingEnumeration<SearchResult> results =
+ ctx.search( NEW_DN2, "(objectClass=*)", controls );
+ assertNotNull( results );
+ assertTrue( "Could not find entry after move.", results.hasMore() );
+ SearchResult result = results.next();
+ assertNotNull( result );
+ assertEquals( NEW_DN2, result.getNameInNamespace() );
+
+ results.close();
+ ctx.close();
+ }
+
+ @Test
+ public void testDummy()
+ {
+
+ }
+}
Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java?rev=683478&r1=683477&r2=683478&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java Wed Aug 6 19:17:10 2008
@@ -39,6 +39,7 @@
import org.apache.directory.server.operations.modify.ModifyReplaceIT;
import org.apache.directory.server.operations.modifydn.ModifyDnReferralIT;
import org.apache.directory.server.operations.modifydn.ModifyRdnIT;
+import org.apache.directory.server.operations.modifydn.MoveIT;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -62,9 +63,10 @@
ModifyRemoveIT.class,
ModifyReplaceIT.class,
ModifyRdnIT.class,
- ModifyDnReferralIT.class,
BindIT.class,
- SimpleBindIT.class
+ SimpleBindIT.class,
+ MoveIT.class,
+ ModifyDnReferralIT.class
} )
@CleanupLevel ( Level.SUITE )
@Mode ( SetupMode.ROLLBACK )