You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/09/10 03:24:53 UTC
svn commit: r279929 - in /directory/apacheds/trunk/core/src:
main/java/org/apache/ldap/server/subtree/SubentryService.java
test/org/apache/ldap/server/subtree/SubentryServiceTest.java
Author: akarasulu
Date: Fri Sep 9 18:24:48 2005
New Revision: 279929
URL: http://svn.apache.org/viewcvs?rev=279929&view=rev
Log:
changes ...
o added test cases for intercepting subentry modification operations on the
subtreeSpecification attribute
o found bug while running test cases where old spec was being used to set
attributes on entries - changed code to use new spec to add subentry op
attributes after they are removed using the old spec
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java
directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java?rev=279929&r1=279928&r2=279929&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/subtree/SubentryService.java Fri Sep 9 18:24:48 2005
@@ -840,7 +840,7 @@
Attributes candidate = result.getAttributes();
Name dn = dnParser.parse( result.getName() );
- if ( evaluator.evaluate( ssOld, apName, dn, candidate.get( "objectClass" ) ) )
+ if ( evaluator.evaluate( ssNew, apName, dn, candidate.get( "objectClass" ) ) )
{
nexus.modify( dn, getOperationalModsForAdd( candidate, operational ) );
}
@@ -923,7 +923,7 @@
Attributes candidate = result.getAttributes();
Name dn = dnParser.parse( result.getName() );
- if ( evaluator.evaluate( ssOld, apName, dn, candidate.get( "objectClass" ) ) )
+ if ( evaluator.evaluate( ssNew, apName, dn, candidate.get( "objectClass" ) ) )
{
nexus.modify( dn, getOperationalModsForAdd( candidate, operational ) );
}
Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java?rev=279929&r1=279928&r2=279929&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java (original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java Fri Sep 9 18:24:48 2005
@@ -198,6 +198,254 @@
}
+ public void testSubentryModify() throws NamingException
+ {
+ addAdministrativeRole( "autonomousArea" );
+ super.sysRoot.createSubcontext( "cn=testsubentry", getTestSubentry() );
+ Map results = getAllEntries();
+
+ // --------------------------------------------------------------------
+ // Make sure entries selected by the subentry do have the mark
+ // --------------------------------------------------------------------
+
+ Attributes configuration = ( Attributes ) results.get( "ou=configuration,ou=system" );
+ Attribute autonomousSubentry = configuration.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ Attributes interceptors = ( Attributes ) results.get( "ou=interceptors,ou=configuration,ou=system" );
+ autonomousSubentry = interceptors.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=interceptors,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ Attributes partitions = ( Attributes ) results.get( "ou=partitions,ou=configuration,ou=system" );
+ autonomousSubentry = partitions.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=partitions,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ Attributes services = ( Attributes ) results.get( "ou=services,ou=configuration,ou=system" );
+ autonomousSubentry = services.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=services,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ // --------------------------------------------------------------------
+ // Make sure entries not selected by subentry do not have the mark
+ // --------------------------------------------------------------------
+
+ Attributes system = ( Attributes ) results.get( "ou=system" );
+ assertNull( "ou=system should not be marked",
+ system.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes users = ( Attributes ) results.get( "ou=users,ou=system" );
+ assertNull( "ou=users,ou=system should not be marked",
+ users.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes groups = ( Attributes ) results.get( "ou=groups,ou=system" );
+ assertNull( "ou=groups,ou=system should not be marked",
+ groups.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes admin = ( Attributes ) results.get( "uid=admin,ou=system" );
+ assertNull( "uid=admin,ou=system should not be marked",
+ admin.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes sysPrefRoot = ( Attributes ) results.get( "prefNodeName=sysPrefRoot,ou=system" );
+ assertNull( "prefNode=sysPrefRoot,ou=system should not be marked",
+ sysPrefRoot.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ // --------------------------------------------------------------------
+ // Now modify the subentry by introducing an exclusion
+ // --------------------------------------------------------------------
+
+ Attribute subtreeSpecification = new LockableAttributeImpl( "subtreeSpecification" );
+ subtreeSpecification.add( "{ base \"ou=configuration\", specificExclusions { chopBefore:\"ou=services\" } }" );
+ ModificationItem item = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, subtreeSpecification );
+ super.sysRoot.modifyAttributes( "cn=testsubentry", new ModificationItem[] { item } );
+ results = getAllEntries();
+
+ // --------------------------------------------------------------------
+ // Make sure entries selected by the subentry do have the mark
+ // --------------------------------------------------------------------
+
+ configuration = ( Attributes ) results.get( "ou=configuration,ou=system" );
+ autonomousSubentry = configuration.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ interceptors = ( Attributes ) results.get( "ou=interceptors,ou=configuration,ou=system" );
+ autonomousSubentry = interceptors.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=interceptors,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ partitions = ( Attributes ) results.get( "ou=partitions,ou=configuration,ou=system" );
+ autonomousSubentry = partitions.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=partitions,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ // --------------------------------------------------------------------
+ // Make sure entries not selected by subentry do not have the mark
+ // --------------------------------------------------------------------
+
+ system = ( Attributes ) results.get( "ou=system" );
+ assertNull( "ou=system should not be marked",
+ system.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ users = ( Attributes ) results.get( "ou=users,ou=system" );
+ assertNull( "ou=users,ou=system should not be marked",
+ users.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ groups = ( Attributes ) results.get( "ou=groups,ou=system" );
+ assertNull( "ou=groups,ou=system should not be marked",
+ groups.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ admin = ( Attributes ) results.get( "uid=admin,ou=system" );
+ assertNull( "uid=admin,ou=system should not be marked",
+ admin.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ sysPrefRoot = ( Attributes ) results.get( "prefNodeName=sysPrefRoot,ou=system" );
+ assertNull( "prefNode=sysPrefRoot,ou=system should not be marked",
+ sysPrefRoot.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ services = ( Attributes ) results.get( "ou=services,ou=configuration,ou=system" );
+ autonomousSubentry = services.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ if ( autonomousSubentry != null )
+ {
+ assertEquals( "ou=services,ou=configuration,ou=system should not be marked",
+ 0, autonomousSubentry.size() );
+ }
+ }
+
+
+ public void testSubentryModify2() throws NamingException
+ {
+ addAdministrativeRole( "autonomousArea" );
+ super.sysRoot.createSubcontext( "cn=testsubentry", getTestSubentry() );
+ Map results = getAllEntries();
+
+ // --------------------------------------------------------------------
+ // Make sure entries selected by the subentry do have the mark
+ // --------------------------------------------------------------------
+
+ Attributes configuration = ( Attributes ) results.get( "ou=configuration,ou=system" );
+ Attribute autonomousSubentry = configuration.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ Attributes interceptors = ( Attributes ) results.get( "ou=interceptors,ou=configuration,ou=system" );
+ autonomousSubentry = interceptors.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=interceptors,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ Attributes partitions = ( Attributes ) results.get( "ou=partitions,ou=configuration,ou=system" );
+ autonomousSubentry = partitions.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=partitions,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ Attributes services = ( Attributes ) results.get( "ou=services,ou=configuration,ou=system" );
+ autonomousSubentry = services.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=services,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ // --------------------------------------------------------------------
+ // Make sure entries not selected by subentry do not have the mark
+ // --------------------------------------------------------------------
+
+ Attributes system = ( Attributes ) results.get( "ou=system" );
+ assertNull( "ou=system should not be marked",
+ system.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes users = ( Attributes ) results.get( "ou=users,ou=system" );
+ assertNull( "ou=users,ou=system should not be marked",
+ users.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes groups = ( Attributes ) results.get( "ou=groups,ou=system" );
+ assertNull( "ou=groups,ou=system should not be marked",
+ groups.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes admin = ( Attributes ) results.get( "uid=admin,ou=system" );
+ assertNull( "uid=admin,ou=system should not be marked",
+ admin.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ Attributes sysPrefRoot = ( Attributes ) results.get( "prefNodeName=sysPrefRoot,ou=system" );
+ assertNull( "prefNode=sysPrefRoot,ou=system should not be marked",
+ sysPrefRoot.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ // --------------------------------------------------------------------
+ // Now modify the subentry by introducing an exclusion
+ // --------------------------------------------------------------------
+
+ Attributes changes = new LockableAttributesImpl();
+ changes.put( "subtreeSpecification",
+ "{ base \"ou=configuration\", specificExclusions { chopBefore:\"ou=services\" } }" );
+ super.sysRoot.modifyAttributes( "cn=testsubentry", DirContext.REPLACE_ATTRIBUTE, changes );
+ results = getAllEntries();
+
+ // --------------------------------------------------------------------
+ // Make sure entries selected by the subentry do have the mark
+ // --------------------------------------------------------------------
+
+ configuration = ( Attributes ) results.get( "ou=configuration,ou=system" );
+ autonomousSubentry = configuration.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ interceptors = ( Attributes ) results.get( "ou=interceptors,ou=configuration,ou=system" );
+ autonomousSubentry = interceptors.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=interceptors,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ partitions = ( Attributes ) results.get( "ou=partitions,ou=configuration,ou=system" );
+ autonomousSubentry = partitions.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ assertNotNull( "ou=partitions,ou=configuration,ou=system should be marked", autonomousSubentry );
+ assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+ assertEquals( 1, autonomousSubentry.size() );
+
+ // --------------------------------------------------------------------
+ // Make sure entries not selected by subentry do not have the mark
+ // --------------------------------------------------------------------
+
+ system = ( Attributes ) results.get( "ou=system" );
+ assertNull( "ou=system should not be marked",
+ system.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ users = ( Attributes ) results.get( "ou=users,ou=system" );
+ assertNull( "ou=users,ou=system should not be marked",
+ users.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ groups = ( Attributes ) results.get( "ou=groups,ou=system" );
+ assertNull( "ou=groups,ou=system should not be marked",
+ groups.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ admin = ( Attributes ) results.get( "uid=admin,ou=system" );
+ assertNull( "uid=admin,ou=system should not be marked",
+ admin.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ sysPrefRoot = ( Attributes ) results.get( "prefNodeName=sysPrefRoot,ou=system" );
+ assertNull( "prefNode=sysPrefRoot,ou=system should not be marked",
+ sysPrefRoot.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+ services = ( Attributes ) results.get( "ou=services,ou=configuration,ou=system" );
+ autonomousSubentry = services.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+ if ( autonomousSubentry != null )
+ {
+ assertEquals( "ou=services,ou=configuration,ou=system should not be marked",
+ 0, autonomousSubentry.size() );
+ }
+ }
+
+
public void testSubentryDelete() throws NamingException
{
addAdministrativeRole( "autonomousArea" );