directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r956033 - in /directory: apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ apacheds/trunk/jdbm-partition/src/test/ja...
Date Fri, 18 Jun 2010 15:59:51 GMT
Author: elecharny
Date: Fri Jun 18 15:59:51 2010
New Revision: 956033

URL: http://svn.apache.org/viewvc?rev=956033&view=rev
Log:
o Added a test for DIRSERVER-1330
o Fixed the problem by catching the exception got if the AttribiteType does not exist in the
filter

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java?rev=956033&r1=956032&r2=956033&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
Fri Jun 18 15:59:51 2010
@@ -1863,7 +1863,7 @@ public class SearchIT extends AbstractLd
 
 
    @Test
-   public void testSearchFilterBadAttributeType() throws Exception
+   public void testSearchFilterWithBadAttributeType() throws Exception
    {
        SearchControls controls = new SearchControls();
        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
@@ -1884,4 +1884,26 @@ public class SearchIT extends AbstractLd
        assertEquals( "Expected number of results returned was incorrect!", 1, map.size()
);
        assertTrue( map.containsKey( "ou=testing01,ou=system" ) );
    }
+
+
+   @Test
+   public void testSearchFilterBadAttributeType() throws Exception
+   {
+       SearchControls controls = new SearchControls();
+       controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+       controls.setDerefLinkFlag( false );
+       sysRoot.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES,
+               AliasDerefMode.NEVER_DEREF_ALIASES.getJndiValue() );
+       HashMap<String, Attributes> map = new HashMap<String, Attributes>();
+
+       NamingEnumeration<SearchResult> list = sysRoot.search( "", "(badAttr=*)", controls
);
+       
+       while ( list.hasMore() )
+       {
+           SearchResult result = list.next();
+           map.put( result.getName(), result.getAttributes() );
+       }
+
+       assertEquals( "Expected number of results returned was incorrect!", 0, map.size()
);
+   }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java?rev=956033&r1=956032&r2=956033&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java
Fri Jun 18 15:59:51 2010
@@ -26,6 +26,7 @@ import java.util.List;
 import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapNoSuchAttributeException;
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -167,7 +168,15 @@ public class FilterNormalizingVisitor im
      */
     private ExprNode visitPresenceNode( PresenceNode node ) throws LdapException
     {
-        node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute()
) );
+        try
+        { 
+            node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute()
) );
+        }
+        catch ( LdapNoSuchAttributeException lnsae )
+        {
+            return null;
+        }
+        
         return node;
     }
 
@@ -192,6 +201,16 @@ public class FilterNormalizingVisitor im
             return null;
         }
 
+        // Check that the AttributeType is valid
+        try
+        {
+            node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute()
) );
+        }
+        catch ( LdapNoSuchAttributeException lnsae )
+        {
+            return null;
+        }
+
         Value<?> normalized = normalizeValue( node.getAttribute(), node.getValue()
);
 
         if ( normalized == null )
@@ -199,7 +218,6 @@ public class FilterNormalizingVisitor im
             return null;
         }
 
-        node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute()
) );
         node.setValue( normalized );
 
         return node;
@@ -307,7 +325,15 @@ public class FilterNormalizingVisitor im
      */
     private ExprNode visitExtensibleNode( ExtensibleNode node ) throws LdapException
     {
-        node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute()
) );
+        // Check that the AttributeType is valid
+        try
+        {
+            node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute()
) );
+        }
+        catch ( LdapNoSuchAttributeException lnsae )
+        {
+            return null;
+        }
 
         return node;
     }

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java?rev=956033&r1=956032&r2=956033&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
Fri Jun 18 15:59:51 2010
@@ -42,7 +42,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.shared.ldap.util.LdapExceptionUtils;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -53,7 +52,7 @@ import org.junit.Test;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@Ignore ( "Ignore this test until we get the LDIF partition in place." )
+//@Ignore ( "Ignore this test until we get the LDIF partition in place." )
 public class PartitionSchemaLoaderTest
 {
     private static SchemaManager schemaManager;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java?rev=956033&r1=956032&r2=956033&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableAttributeTypeRegistry.java
Fri Jun 18 15:59:51 2010
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapNoSuchAttributeException;
 import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -205,7 +206,14 @@ public class ImmutableAttributeTypeRegis
      */
     public String getOidByName( String name ) throws LdapException
     {
-        return immutableAttributeTypeRegistry.getOidByName( name );
+        try
+        { 
+            return immutableAttributeTypeRegistry.getOidByName( name );
+        }
+        catch ( LdapException le )
+        {
+            throw new LdapNoSuchAttributeException( le.getMessage() );
+        }
     }
 
 



Mime
View raw message