directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r643127 - in /directory/apacheds/branches/bigbang/server-unit/src: main/java/org/apache/directory/server/unit/ test/java/org/apache/directory/server/ test/resources/org/apache/directory/server/
Date Mon, 31 Mar 2008 20:21:35 GMT
Author: akarasulu
Date: Mon Mar 31 13:21:30 2008
New Revision: 643127

URL: http://svn.apache.org/viewvc?rev=643127&view=rev
Log:
DIRSERVER-1083: demonstration where having matchingRules make it so you can search on the
attribute

Added:
    directory/apacheds/branches/bigbang/server-unit/src/test/resources/org/apache/directory/server/active-directory.ldif
Modified:
    directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
    directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/SchemaSearchITest.java

Modified: directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?rev=643127&r1=643126&r2=643127&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
(original)
+++ directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
Mon Mar 31 13:21:30 2008
@@ -105,7 +105,23 @@
      */
     protected List<LdifEntry> loadTestLdif( boolean verifyEntries ) throws NamingException
     {
-        InputStream in = getClass().getResourceAsStream( getClass().getSimpleName() + ".ldif"
);
+        return loadLdif( getClass().getResourceAsStream( getClass().getSimpleName() + ".ldif"
), verifyEntries );
+    }
+
+
+    /**
+     * Loads an LDIF from an input stream and adds the entries it contains to 
+     * the server.  It appears as though the administrator added these entries
+     * to the server.
+     *
+     * @param in the input stream containing the LDIF entries to load
+     * @param verifyEntries whether or not all entry additions are checked
+     * to see if they were in fact correctly added to the server
+     * @return a list of entries added to the server in the order they were added
+     * @throws NamingException of the load fails
+     */
+    protected List<LdifEntry> loadLdif( InputStream in, boolean verifyEntries ) throws
NamingException
+    {
         if ( in == null )
         {
             return EMPTY_LIST;

Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/SchemaSearchITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/SchemaSearchITest.java?rev=643127&r1=643126&r2=643127&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/SchemaSearchITest.java
(original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/SchemaSearchITest.java
Mon Mar 31 13:21:30 2008
@@ -25,12 +25,14 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
 import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
 
 
 /**
@@ -148,4 +150,48 @@
         result.close();
     }
 
+    
+    /**
+     * Test case for DIRSERVER-1083: Search on an custom attribute added to 
+     * the dynamic schema fails when no result is found. 
+     */
+    public void testSearchingNewSchemaElements() throws Exception
+    {
+        // load the bogus active directory schema from the issue
+        super.loadLdif( getClass().getResourceAsStream( "active-directory.ldif" ), false
);
+        
+        // create an entry with the schema objectClass personActiveDirectory
+        AttributesImpl person = new AttributesImpl( "objectClass", "top", true );
+        person.get( "objectClass" ).add( "person" );
+        person.get( "objectClass" ).add( "personActiveDirectory" );
+        person.put( "cn", "foobar" );
+        person.put( "sn", "bar" );
+        person.put( "pwdLastSet", "3" );
+        person.put( "SourceAD", "blah" );
+        person.put( "useraccountcontrol", "7" );
+        person.put( "sAMAccountName", "foobar" );
+        ctx.createSubcontext( "cn=foobar,ou=system", person );
+        
+        // Confirm creation with a lookup
+        Attributes read = ctx.getAttributes( "cn=foobar,ou=system" );
+        assertNotNull( read );
+        assertEquals( "3", read.get( "pwdLastSet" ).get() );
+        
+        // Now search for foobar with pwdLastSet value of 3
+        SearchControls searchControls = new SearchControls();
+        searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        NamingEnumeration results = ctx.search( "ou=system", "(pwdLastSet=3)", searchControls
);
+        assertTrue( results.hasMore() );
+        SearchResult result = ( SearchResult ) results.next();
+        assertNotNull( result );
+        assertEquals( "cn=foobar", result.getName() );
+        Attributes attributes = result.getAttributes();
+        assertEquals( "3", attributes.get( "pwdLastSet" ).get() );
+        results.close();
+        
+        // Now search with bogus value for pwdLastSet
+        results = ctx.search( "ou=system", "(pwdLastSet=300)", searchControls );
+        assertFalse( results.hasMore() );
+        results.close();
+    }
 }

Added: directory/apacheds/branches/bigbang/server-unit/src/test/resources/org/apache/directory/server/active-directory.ldif
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/resources/org/apache/directory/server/active-directory.ldif?rev=643127&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/resources/org/apache/directory/server/active-directory.ldif
(added)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/resources/org/apache/directory/server/active-directory.ldif
Mon Mar 31 13:21:30 2008
@@ -0,0 +1,111 @@
+# Generated by Apache Directory Studio on October 5, 2007 2:13:05 PM
+
+# SCHEMA 'ACTIVE-DIRECTORY'
+dn: cn=active-directory, ou=schema
+objectclass: metaSchema
+objectclass: top
+cn: active-directory
+m-dependencies: core
+
+dn: ou=attributeTypes, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: attributeTypes
+
+dn: m-oid=1.1, ou=attributeTypes, cn=active-directory, ou=schema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.1
+m-name: sAMAccountName
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
+
+dn: m-oid=1.2, ou=attributeTypes, cn=active-directory, ou=schema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.2
+m-name: pwdLastSet
+m-equality: integerMatch
+m-ordering: integerMatch
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.27
+
+dn: m-oid=1.4, ou=attributeTypes, cn=active-directory, ou=schema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.4
+m-name: useraccountcontrol
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.27
+
+dn: m-oid=1.5, ou=attributeTypes, cn=active-directory, ou=schema
+objectclass: metaAttributeType
+objectclass: metaTop
+objectclass: top
+m-oid: 1.5
+m-name: SourceAD
+m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
+m-length: 0
+
+dn: ou=comparators, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: comparators
+
+dn: ou=ditContentRules, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: ditContentRules
+
+dn: ou=ditStructureRules, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: ditStructureRules
+
+dn: ou=matchingRules, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: matchingRules
+
+dn: ou=matchingRuleUse, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: matchingRuleUse
+
+dn: ou=nameForms, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: nameForms
+
+dn: ou=normalizers, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: normalizers
+
+dn: ou=objectClasses, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: objectClasses
+
+dn: m-oid=1.3, ou=objectClasses, cn=active-directory, ou=schema
+objectclass: metaObjectClass
+objectclass: metaTop
+objectclass: top
+m-oid: 1.3
+m-name: personActiveDirectory
+m-supObjectClass: person
+m-must: pwdLastSet
+m-must: sAMAccountName
+m-must: useraccountcontrol
+m-must: SourceAD
+
+dn: ou=syntaxCheckers, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: syntaxCheckers
+
+dn: ou=syntaxes, cn=active-directory, ou=schema
+objectclass: organizationalUnit
+objectclass: top
+ou: syntaxes
+



Mime
View raw message