directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r428223 - in /directory/trunks/apacheds/server-unit: pom.xml src/test/java/org/apache/directory/server/IllegalModification.java
Date Thu, 03 Aug 2006 04:05:16 GMT
Author: akarasulu
Date: Wed Aug  2 21:05:15 2006
New Revision: 428223

URL: http://svn.apache.org/viewvc?rev=428223&view=rev
Log:
Adding test case which shows problem has fixed itself: DIRSERVER-630

Added:
    directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/IllegalModification.java
Modified:
    directory/trunks/apacheds/server-unit/pom.xml

Modified: directory/trunks/apacheds/server-unit/pom.xml
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/pom.xml?rev=428223&r1=428222&r2=428223&view=diff
==============================================================================
--- directory/trunks/apacheds/server-unit/pom.xml (original)
+++ directory/trunks/apacheds/server-unit/pom.xml Wed Aug  2 21:05:15 2006
@@ -4,7 +4,7 @@
   <parent>
     <groupId>org.apache.directory.server</groupId>
     <artifactId>build</artifactId>
-    <version>1.1.0-SNAPSHOT</version>
+    <version>1.0-RC4-SNAPSHOT</version>
   </parent>
   <artifactId>apacheds-server-unit</artifactId>
   <name>ApacheDS Server Unit</name>
@@ -22,8 +22,13 @@
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>nlog4j</artifactId>
-      <version>1.2.19</version>
+      <version>1.2.24</version>
       <scope>provided</scope>
+    </dependency>  
+    <dependency>
+      <groupId>ldapsdk</groupId>
+      <artifactId>ldapsdk</artifactId>
+      <version>4.1</version>
     </dependency>  
     <dependency>
       <groupId>org.apache.directory.server</groupId>

Added: directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/IllegalModification.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/IllegalModification.java?rev=428223&view=auto
==============================================================================
--- directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/IllegalModification.java
(added)
+++ directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/IllegalModification.java
Wed Aug  2 21:05:15 2006
@@ -0,0 +1,109 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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;
+
+
+import org.apache.directory.server.unit.AbstractServerTest;
+
+import netscape.ldap.LDAPAttribute;
+import netscape.ldap.LDAPAttributeSet;
+import netscape.ldap.LDAPConnection;
+import netscape.ldap.LDAPEntry;
+import netscape.ldap.LDAPException;
+import netscape.ldap.LDAPModification;
+
+
+/** 
+ * 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: $
+ */
+public class IllegalModification extends AbstractServerTest
+{
+    static final String DN = "cn=Kate Bush,ou=system";
+    static final String USER = "uid=admin,ou=system";
+    static final String PASSWORD = "secret";
+    static final String HOST = "localhost";
+
+    private LDAPConnection con = null;
+
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        con = new LDAPConnection();
+        con.connect( 3, HOST, super.port, USER, PASSWORD );
+
+        // Create a person entry
+        LDAPAttributeSet attrs = new LDAPAttributeSet();
+        attrs.add( new LDAPAttribute( "sn", "Bush" ) );
+        attrs.add( new LDAPAttribute( "cn", "Kate Bush" ) );
+        LDAPAttribute oc = new LDAPAttribute( "objectClass" );
+        oc.addValue( "top" );
+        oc.addValue( "person" );
+        attrs.add( oc );
+        LDAPEntry entry = new LDAPEntry( DN, attrs );
+        con.add( entry );
+    }
+
+
+    protected void tearDown() throws Exception
+    {
+        // Remove the person entry and disconnect
+        con.delete( DN );
+        con.disconnect();
+        super.tearDown();
+    }
+
+
+    public void testIllegalModification() throws LDAPException
+    {
+        LDAPAttribute attr = new LDAPAttribute( "description" );
+        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attr );
+
+        try
+        {
+            con.modify( "cn=Kate Bush,dc=example,dc=com", mod );
+            fail( "error expected due to empty attribute value" );
+        }
+        catch ( LDAPException e )
+        {
+            // expected
+        }
+
+        // Check whether entry is unmodified, i.e. no description
+        LDAPEntry entry = con.read( DN );
+        System.err.println( entry );
+        assertEquals( "description exists?", null, entry.getAttribute( "description" ) );
+    }
+}



Mime
View raw message