You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/07/23 02:44:44 UTC

svn commit: r678956 - in /directory/apacheds/branches/bigbang: core-integ/src/test/java/org/apache/directory/server/core/jndi/ core/src/main/java/org/apache/directory/server/core/schema/ server-unit/src/test/java/org/apache/directory/server/

Author: elecharny
Date: Tue Jul 22 17:44:44 2008
New Revision: 678956

URL: http://svn.apache.org/viewvc?rev=678956&view=rev
Log:
o Fixed a big bug in SchemaInterceptor : it was possible to inject entries where the RDN attribute were not present as an attribute.
o Modified the rename() method in the SchemaInterceptor to store the "cn=schema" dn in the entry, otherwise the check() was failing
o Fixed the tests to forbid the creation of entries with a RDN but no associated attribute.

Modified:
    directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java

Modified: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java?rev=678956&r1=678955&r2=678956&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java (original)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/jndi/ObjStateFactoryIT.java Tue Jul 22 17:44:44 2008
@@ -88,8 +88,8 @@
 
         sysRoot.addToEnvironment( Context.STATE_FACTORIES, PersonStateFactory.class.getName() );
         Person p = new Person( "Rodriguez", "Mr. Kerberos", "noices", "555-1212", "sn=erodriguez", "committer" );
-        sysRoot.bind( "uid=erodriguez, ou=users", p );
-        Attributes attrs = sysRoot.getAttributes( "uid=erodriguez, ou=users" );
+        sysRoot.bind( "sn=Rodriguez, ou=users", p );
+        Attributes attrs = sysRoot.getAttributes( "sn=Rodriguez, ou=users" );
         assertEquals( "Rodriguez", attrs.get( "sn" ).get() );
         assertEquals( "Mr. Kerberos", attrs.get( "cn" ).get() );
         assertTrue( ArrayUtils.isEquals( attrs.get( "userPassword" ).get(), StringTools.getBytesUtf8( "noices" ) ) );

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=678956&r1=678955&r2=678956&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Tue Jul 22 17:44:44 2008
@@ -1158,12 +1158,20 @@
                     tmpEntry.add( new DefaultServerAttribute( type, value ) );
                 }
             }
+            
+            // Substitute the RDN and check if the new entry is correct
+            LdapDN newDn = (LdapDN)name.clone();
+            newDn.remove( name.size() - 1 );
+            newDn.add( newRdn );
+            
+            tmpEntry.setDn( newDn );
             check( name, tmpEntry );
 
             // Check that no operational attributes are removed
             for ( AttributeTypeAndValue atav : oldRDN )
             {
                 AttributeType attributeType = atRegistry.lookup( atav.getUpType() );
+                
                 if ( !attributeType.isCanUserModify() )
                 {
                     throw new NoPermissionException( "Cannot modify the attribute '" + atav.getUpType() + "'" );
@@ -1192,6 +1200,7 @@
         if ( name.getNormName().equalsIgnoreCase( subschemaSubentryDnNorm ) )
         {
             entry = schemaService.getSubschemaEntry( SCHEMA_SUBENTRY_RETURN_ATTRIBUTES );
+            entry.setDn( name );
         }
         else
         {
@@ -1646,6 +1655,7 @@
         // 3-1) Except if the extensibleObject ObjectClass is used
         // 3-2) or if the AttributeType is COLLECTIVE
         // 4) We also check that for H-R attributes, we have a valid String in the values
+        // 5) We last check that the entry has it's RDN values as attributes  
         EntryAttribute objectClassAttr = entry.get( SchemaConstants.OBJECT_CLASS_AT );
 
         // Protect the server against a null objectClassAttr
@@ -1683,7 +1693,29 @@
 
         // Now check the syntaxes
         assertSyntaxes( entry );
-    }
+        
+        // Last, check that the RDN's values are attributes in the entry
+        Rdn rdn = entry.getDn().getRdn();
+        
+        if ( rdn.getNbAtavs() == 1 )
+        {
+        	// We have only one AVA
+        	AttributeTypeAndValue ava = rdn.getAtav();
+        	String value = (String)ava.getNormValue();
+        	String upId = ava.getUpType();
+        	
+        	if ( !entry.contains( upId, value ) )
+        	{
+        		String message = "The RDN '" + upId + "=" + value + "' is not present in the entry";
+        		LOG.error( message );
+                throw new LdapInvalidAttributeValueException( message, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+        	}
+        }
+        else
+        {
+        	// TODO deal with multi AVAs
+        }
+    } 
 
 
     /**

Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java?rev=678956&r1=678955&r2=678956&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyAddTest.java Tue Jul 22 17:44:44 2008
@@ -105,7 +105,7 @@
         ctx.createSubcontext( RDN_TORI_AMOS, attributes );
 
         // Create Debbie Harry ( I feel like being God when creating people as good looking as Blondie :)
-        attributes = getPersonAttributes( "Bush", "Kate Bush" );
+        attributes = getPersonAttributes( "Harry", "Debbie Harry" );
         ctx.createSubcontext( RDN_DEBBIE_HARRY, attributes );
 
     }
@@ -475,7 +475,6 @@
             SearchResult sr = enm.next();
             attrs = sr.getAttributes();
             Attribute desc = sr.getAttributes().get("description");
-            assertNotNull(desc);
             assertEquals(1, desc.size());
             assertTrue(desc.contains(descriptions[0]));
         }