Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 9295 invoked from network); 5 Aug 2008 23:52:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Aug 2008 23:52:12 -0000 Received: (qmail 19823 invoked by uid 500); 5 Aug 2008 23:52:11 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 19779 invoked by uid 500); 5 Aug 2008 23:52:11 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 19770 invoked by uid 99); 5 Aug 2008 23:52:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2008 16:52:11 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2008 23:51:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1488C23889BB; Tue, 5 Aug 2008 16:51:21 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r683040 - in /directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server: operations/modifydn/ModifyDnReferralIT.java suites/StockServerISuite.java Date: Tue, 05 Aug 2008 23:51:20 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080805235121.1488C23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: akarasulu Date: Tue Aug 5 16:51:20 2008 New Revision: 683040 URL: http://svn.apache.org/viewvc?rev=683040&view=rev Log: added test cases to tesdt modifyDN operation with referrals and added it to the stock suite Added: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java Added: 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=683040&view=auto ============================================================================== --- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java (added) +++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java Tue Aug 5 16:51:20 2008 @@ -0,0 +1,197 @@ +/* + * 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.ReferralException; +import javax.naming.ldap.LdapContext; + +import netscape.ldap.LDAPConnection; +import netscape.ldap.LDAPConstraints; +import netscape.ldap.LDAPControl; +import netscape.ldap.LDAPEntry; +import netscape.ldap.LDAPResponse; +import netscape.ldap.LDAPResponseListener; +import netscape.ldap.LDAPSearchConstraints; + +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.ResultCodeEnum; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection; +import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContextThrowOnRefferal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + + +/** + * Tests the server to make sure standard compare operations work properly. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +@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=Computers,uid=akarasulu,ou=users,ou=system\n" + + "objectClass: organizationalUnit\n" + + "objectClass: top\n" + + "ou: computers\n" + + "description: Computers for Alex\n" + + "seeAlso: ou=Machines,uid=akarasulu,ou=users,ou=system\n\n" + + // Entry # 3 + "dn: uid=akarasuluref,ou=users,ou=system\n" + + "objectClass: uidObject\n" + + "objectClass: referral\n" + + "objectClass: top\n" + + "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" + } +) +public class ModifyDnReferralIT +{ + private static final Logger LOG = LoggerFactory.getLogger( ModifyDnReferralIT.class ); + + public static LdapServer ldapServer; + + + /** + * Tests ModifyDN operation on referral entry with the ManageDsaIT control. + */ + @Test + public void testOnReferralWithManageDsaITControl() 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=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints ); + LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints ); + assertNotNull( entry ); + assertEquals( "uid=ref,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. + */ + @Test + public void testOnReferral() throws Exception + { + LDAPConnection conn = getWiredConnection( ldapServer ); + LDAPConstraints constraints = new LDAPConstraints(); + constraints.setReferrals( false ); + conn.setConstraints( constraints ); + + // referrals failure + LDAPResponseListener listener = null; + LDAPResponse response = null; + + listener = conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, null, constraints ); + response = listener.getResponse(); + assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() ); + + assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] ); + assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] ); + assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] ); + + 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. + */ + @Test + public void testThrowOnReferralWithJndi() throws Exception + { + LdapContext ctx = getWiredContextThrowOnRefferal( ldapServer ); + + // ModifyDN referrals failure + try + { + ctx.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref,ou=users,ou=system" ); + fail( "Should never get here due to ModifyDN failure on ReferralException" ); + } + catch ( ReferralException e ) + { + // seems JNDI only returns the first referral URL and not all so we test for it + assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", e.getReferralInfo() ); + } + + ctx.close(); + } + + + /** + * Tests referral handling when an ancestor is a referral. + */ + @Test + public void testAncestorReferral() throws Exception + { + LOG.debug( "" ); + + LDAPConnection conn = getWiredConnection( ldapServer ); + LDAPConstraints constraints = new LDAPConstraints(); + conn.setConstraints( constraints ); + + // referrals failure + LDAPResponseListener listener = null; + LDAPResponse response = null; + + listener = conn.rename( "ou=Computers,uid=akarasuluref,ou=users,ou=system", "ou=Machines", true, null, constraints ); + response = listener.getResponse(); + assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() ); + + assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] ); + assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] ); + assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] ); + + conn.disconnect(); + } +} 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=683040&r1=683039&r2=683040&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 Tue Aug 5 16:51:20 2008 @@ -35,6 +35,7 @@ import org.apache.directory.server.operations.modify.ModifyReferralIT; import org.apache.directory.server.operations.modify.ModifyRemoveIT; 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.junit.runner.RunWith; import org.junit.runners.Suite; @@ -58,7 +59,8 @@ ModifyReferralIT.class, ModifyRemoveIT.class, ModifyReplaceIT.class, - ModifyRdnIT.class + ModifyRdnIT.class, + ModifyDnReferralIT.class } ) @CleanupLevel ( Level.SUITE ) @Mode ( SetupMode.ROLLBACK )