directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1135502 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/exception/ i18n/src/main/java/org/apache/directory/server/i18n/ i18n/src/main/resources/org/apache/directory/server/i18n/ server-integ/src/test/jav...
Date Tue, 14 Jun 2011 11:52:55 GMT
Author: elecharny
Date: Tue Jun 14 11:52:55 2011
New Revision: 1135502

URL: http://svn.apache.org/viewvc?rev=1135502&view=rev
Log:
o Added a test to check that we can't add an entry under an Alias
o Improved the associated error message

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
    directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=1135502&r1=1135501&r2=1135502&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
Tue Jun 14 11:52:55 2011
@@ -175,7 +175,7 @@ public class ExceptionInterceptor extend
 
             if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
             {
-                String msg = I18n.err( I18n.ERR_252, name.getName() );
+                String msg = I18n.err( I18n.ERR_252_ALIAS_WITH_CHILD_NOT_ALLOWED, name.getName(),
parentDn.getName() );
                 LdapAliasException e = new LdapAliasException( msg );
                 //e.setResolvedName( DNFactory.create( parentDn.getName() ) );
                 throw e;

Modified: directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java?rev=1135502&r1=1135501&r2=1135502&view=diff
==============================================================================
--- directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
(original)
+++ directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
Tue Jun 14 11:52:55 2011
@@ -285,7 +285,7 @@ public enum I18n
     ERR_249("ERR_249"),
     ERR_250_ENTRY_ALREADY_EXISTS("ERR_250_ENTRY_ALREADY_EXISTS"),
     ERR_251_PARENT_NOT_FOUND("ERR_251_PARENT_NOT_FOUND"),
-    ERR_252("ERR_252"),
+    ERR_252_ALIAS_WITH_CHILD_NOT_ALLOWED("ERR_252_ALIAS_WITH_CHILD_NOT_ALLOWED"),
     ERR_253("ERR_253"),
     ERR_254_ADD_EXISTING_VALUE("ERR_254_ADD_EXISTING_VALUE"),
     ERR_255("ERR_255"),

Modified: directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties?rev=1135502&r1=1135501&r2=1135502&view=diff
==============================================================================
--- directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
(original)
+++ directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
Tue Jun 14 11:52:55 2011
@@ -273,7 +273,7 @@ ERR_248=SubstringNode ''{0}'' had incorr
 ERR_249=The global schema subentry cannot be added since it exists by default.
 ERR_250_ENTRY_ALREADY_EXISTS={0} already exists!
 ERR_251_PARENT_NOT_FOUND=Parent {0} not found
-ERR_252=Attempt to add entry to alias ''{0}'' not allowed.
+ERR_252_ALIAS_WITH_CHILD_NOT_ALLOWED=Attempt to add entry ''{0}'' under alias ''{1}'' not
allowed.
 ERR_253=Can not allow the deletion of the subschemaSubentry ({0}) for the global schema.
 ERR_254_ADD_EXISTING_VALUE=Trying to add existing value ''{0}'' to attribute {1}
 ERR_255=Can not allow the renaming of the subschemaSubentry ({0}) for the global schema:
it is fixed at {1}

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java?rev=1135502&r1=1135501&r2=1135502&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java
Tue Jun 14 11:52:55 2011
@@ -22,6 +22,9 @@ package org.apache.directory.server.oper
 
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getClientApiConnection;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -52,27 +55,95 @@ public class AddAliasIT extends Abstract
     @Test
     public void testAddAliasOnParent() throws Exception
     {
-        conn = getClientApiConnection( getLdapServer() );
-        conn.setTimeOut( -1L );
-        
-        conn.add( new DefaultEntry( 
-            "cn=foo,ou=system", 
-            "objectClass: person",
-            "objectClass: top",
-            "cn: foo",
-            "sn: Foo" ) );
-
-        assertNotNull( conn.lookup( "cn=foo,ou=system" ) );
-
-        conn.add( new DefaultEntry( 
-            "ou=alias,cn=foo,ou=system", 
-            "objectClass: top",
-            "objectClass: extensibleObject",
-            "objectClass: alias",
-            "ou: alias" ,
-            "aliasedObjectName: cn=foo,ou=system",
-            "description: alias to father (branch)" ) );
+        try
+        {
+            conn = getClientApiConnection( getLdapServer() );
+            conn.setTimeOut( -1L );
+            
+            conn.add( new DefaultEntry( 
+                "cn=foo,ou=system", 
+                "objectClass: person",
+                "objectClass: top",
+                "cn: foo",
+                "sn: Foo" ) );
+    
+            assertNotNull( conn.lookup( "cn=foo,ou=system" ) );
+    
+            conn.add( new DefaultEntry( 
+                "ou=alias,cn=foo,ou=system", 
+                "objectClass: top",
+                "objectClass: extensibleObject",
+                "objectClass: alias",
+                "ou: alias" ,
+                "aliasedObjectName: cn=foo,ou=system",
+                "description: alias to father (branch)" ) );
+    
+            assertNotNull( conn.lookup( "ou=alias,cn=foo,ou=system" ) );
+        }
+        finally
+        {
+            // Cleanup entries now
+            conn.delete( "ou=alias,cn=foo,ou=system" );
+            conn.delete( "cn=foo,ou=system" );
+        }
+    }
+    
+    
 
-        assertNotNull( conn.lookup( "ou=alias,cn=foo,ou=system" ) );
+    @Test
+    public void testAddAliasWithSubordinate() throws Exception
+    {
+        try
+        {
+            conn = getClientApiConnection( getLdapServer() );
+            conn.setTimeOut( -1L );
+            
+            conn.add( new DefaultEntry( 
+                "cn=foo,ou=system", 
+                "objectClass: person",
+                "objectClass: top",
+                "cn: foo",
+                "sn: Foo" ) );
+    
+            assertNotNull( conn.lookup( "cn=foo,ou=system" ) );
+    
+            conn.add( new DefaultEntry( 
+                "ou=alias,cn=foo,ou=system", 
+                "objectClass: top",
+                "objectClass: extensibleObject",
+                "objectClass: alias",
+                "ou: alias" ,
+                "aliasedObjectName: cn=foo,ou=system",
+                "description: alias to father (branch)" ) );
+    
+            assertNotNull( conn.lookup( "ou=alias,cn=foo,ou=system" ) );
+    
+            try
+            {
+                conn.add( new DefaultEntry( 
+                    "ou=aliasChild,ou=alias,cn=foo,ou=system", 
+                    "objectClass: top",
+                    "objectClass: extensibleObject",
+                    "objectClass: alias",
+                    "ou: aliasChild" ,
+                    "aliasedObjectName: cn=foo,ou=system" ) );
+                
+                fail();
+            }
+            catch ( Exception e )
+            {
+                e.printStackTrace();
+                assertTrue( true );
+            }
+    
+            assertNotNull( conn.lookup( "ou=alias,cn=foo,ou=system" ) );
+            assertNull( conn.lookup( "ou=aliasChild,ou=alias,cn=foo,ou=system" ) );
+        }
+        finally
+        {
+            // Cleanup entries now
+            conn.delete( "ou=alias,cn=foo,ou=system" );
+            conn.delete( "cn=foo,ou=system" );
+        }
     }
 }



Mime
View raw message