directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r682609 - in /directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations: compare/ modify/
Date Tue, 05 Aug 2008 07:17:44 GMT
Author: akarasulu
Date: Tue Aug  5 00:17:44 2008
New Revision: 682609

URL: http://svn.apache.org/viewvc?rev=682609&view=rev
Log:
renaming some tests to use IT suffix and adding new ModifyReferral test class: modify is done

Added:
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java
      - copied, changed from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java
      - copied, changed from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
      - copied, changed from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
      - copied, changed from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
      - copied, changed from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java
Removed:
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java
(from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java&p1=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareTest.java&r1=682586&r2=682609&rev=682609&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareTest.java
(original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/compare/MatchingRuleCompareIT.java
Tue Aug  5 00:17:44 2008
@@ -65,7 +65,7 @@
     "member: cn=Tori Amos,ou=system\n\n"
     }
 )
-public class MatchingRuleCompareTest
+public class MatchingRuleCompareIT
 {
     public static LdapServer ldapServer;
 

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java
(from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java&p1=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java&r1=682586&r2=682609&rev=682609&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationITest.java
(original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java
Tue Aug  5 00:17:44 2008
@@ -71,7 +71,7 @@
     "sn: Bush\n\n" 
     }
 )
-public class IllegalModificationITest 
+public class IllegalModificationIT 
 {
     private static final String DN = "cn=Kate Bush,ou=system";
 

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
(from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java&p1=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java&r1=682586&r2=682609&rev=682609&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddTest.java
(original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
Tue Aug  5 00:17:44 2008
@@ -88,7 +88,7 @@
     "sn: Harry\n\n" 
     }
 )
-public class ModifyAddTest 
+public class ModifyAddIT 
 {
     private static final String BASE = "ou=system";
     private static final String RDN_TORI_AMOS = "cn=Tori Amos";

Added: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java?rev=682609&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java
(added)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java
Tue Aug  5 00:17:44 2008
@@ -0,0 +1,223 @@
+/*
+ *  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.modify;
+
+
+import javax.naming.ReferralException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+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 static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContextThrowOnRefferal;
+
+import org.apache.directory.server.newldap.LdapServer;
+import org.apache.directory.server.operations.compare.CompareIT;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+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.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+import netscape.ldap.LDAPAttribute;
+import netscape.ldap.LDAPConnection;
+import netscape.ldap.LDAPConstraints;
+import netscape.ldap.LDAPControl;
+import netscape.ldap.LDAPModification;
+import netscape.ldap.LDAPResponse;
+import netscape.ldap.LDAPResponseListener;
+
+
+/** 
+ * A test taken from DIRSERVER-630: If one tries to add an attribute to an 
+ * entry, and does not provide a value, it is assumed that the server does 
+ * not modify the entry. We have a situation here using Sun ONE Directory 
+ * SDK for Java, where adding a description attribute without value to a 
+ * person entry like this,
+ * <code>
+ * dn: cn=Kate Bush,dc=example,dc=com
+ * objectclass: person
+ * objectclass: top
+ * sn: Bush
+ * cn: Kate Bush
+ * </code> 
+ * does not fail (modify call does not result in an exception). Instead, a 
+ * description attribute is created within the entry. At least the new 
+ * attribute is readable with Netscape SDK (it is not visible to most UIs, 
+ * because it is invalid ...). 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: $
+ */
+@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: extensibleObject\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 ModifyReferralIT 
+{
+    private static final Logger LOG = LoggerFactory.getLogger( CompareIT.class );
+    
+    public static LdapServer ldapServer;
+    
+
+    /**
+     * Tests modify operation on referral entry with the ManageDsaIT control.
+     */
+    @Test
+    public void testOnReferralWithManageDsaITControl() throws Exception
+    {
+        LDAPConnection conn = getWiredConnection( ldapServer );
+        LDAPConstraints constraints = new LDAPConstraints();
+        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new
byte[0] ) );
+        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new
byte[0] ) );
+        conn.setConstraints( constraints );
+        
+        // modify success
+        LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu"
);
+        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+        conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, constraints );
+        
+        assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints
) );
+        
+        conn.disconnect();
+    }
+    
+    
+    /**
+     * Tests modify operation on 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
+        // modify success
+        LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu"
);
+        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+        LDAPResponseListener listener = conn.modify( "uid=akarasuluref,ou=users,ou=system",
mod, null, constraints );
+        LDAPResponse 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 modify 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 );
+        
+        // modify failure
+        Attribute attr = new AttributeImpl( "description", "referral to akarasulu" );
+        ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr );
+        
+        try
+        {
+            ctx.modifyAttributes( "uid=akarasuluref,ou=users,ou=system", new ModificationItem[]
{ mod } );
+        }
+        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
+        LDAPAttribute attribute = new LDAPAttribute( "ou", "Machines" );
+        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
+        LDAPResponseListener listener = null;
+        LDAPResponse response = null;
+
+        listener = conn.modify( "ou=Computers,uid=akarasuluref,ou=users,ou=system", mod,
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();
+    }
+}

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
(from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java&p1=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java&r1=682586&r2=682609&rev=682609&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveTest.java
(original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyRemoveIT.java
Tue Aug  5 00:17:44 2008
@@ -71,7 +71,7 @@
     "sn: Amos\n\n"
     }
 )
-public class ModifyRemoveTest
+public class ModifyRemoveIT
 {
     private static final String BASE = "ou=system";
     private static final String RDN = "cn=Tori Amos";

Copied: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
(from r682586, directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java?p2=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java&p1=directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java&r1=682586&r2=682609&rev=682609&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceITest.java
(original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
Tue Aug  5 00:17:44 2008
@@ -50,7 +50,7 @@
  */
 @RunWith ( SiRunner.class ) 
 @CleanupLevel ( Level.SUITE )
-public class ModifyReplaceITest 
+public class ModifyReplaceIT 
 {
     private static final String BASE = "ou=system";
 



Mime
View raw message