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 2010/09/22 23:17:53 UTC
svn commit: r1000236 - in /directory/apacheds/trunk:
core/src/main/java/org/apache/directory/server/core/admin/
server-integ/src/test/java/org/apache/directory/server/admin/
Author: elecharny
Date: Wed Sep 22 21:17:53 2010
New Revision: 1000236
URL: http://svn.apache.org/viewvc?rev=1000236&view=rev
Log:
o Added some class to test the deletion of AP (no tests yet)
o Fixed the AP cache
o Fixed some tests for the AP add operation
Added:
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointDelIT.java
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java?rev=1000236&r1=1000235&r2=1000236&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java Wed Sep 22 21:17:53 2010
@@ -70,6 +70,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.message.AliasDerefMode;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.name.RDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.SchemaManager;
import org.apache.directory.shared.ldap.subtree.AdministrativeRole;
@@ -762,23 +763,40 @@ public class AdministrativePointIntercep
boolean parentFound = false;
DnNode<List<AdministrativePoint>> apNodes = directoryService.getAdministrativePoints();
- while ( ( apNodes != null ) && apNodes.hasParent( dn ) )
+ if ( !apNodes.hasParent( dn ) )
{
- // The IAP has a parent, but it may not be the wanted parent
- List<AdministrativePoint> parentAps = apNodes.getElement( dn );
+ // No parents, this is an error
+ String message = "Cannot add an IAP with no parent : " + adminPoint;
+ LOG.error( message );
+ throw new LdapUnwillingToPerformException( message );
+ }
- if ( parentAps == null )
+ for ( int i = 0; i < dn.size(); i++ )
+ {
+ RDN rdn = dn.getRdn( i );
+
+ // The IAP has a parent, but it may not be the wanted parent
+ DnNode<List<AdministrativePoint>> node = apNodes.getChild( rdn );
+
+ if ( node == null )
{
// No parents, this is an error
String message = "Cannot add an IAP with no parent : " + adminPoint;
LOG.error( message );
throw new LdapUnwillingToPerformException( message );
+ }
+
+ List<AdministrativePoint> adminPoints = node.getElement();
+ if ( adminPoints == null )
+ {
+ apNodes = node;
+ continue;
}
// Check that the parent is either an AA, or contains an IAP
// or a SAP with the same role
- for ( AdministrativePoint parentRole : parentAps )
+ for ( AdministrativePoint parentRole : adminPoints )
{
if ( parentRole.isAutonomous() )
{
@@ -824,7 +842,7 @@ public class AdministrativePointIntercep
}
// recurse now
- apNodes = apNodes.getNode( dn );
+ apNodes = node;
}
if ( !parentFound )
@@ -898,6 +916,8 @@ public class AdministrativePointIntercep
LOG.debug( "Entering into the Administrative Interceptor, addRequest" );
Entry entry = addContext.getEntry();
+ System.out.println( entry );
+
// Check if we are adding an Administrative Point
EntryAttribute adminPoint = entry.get( ADMINISTRATIVE_ROLE_AT );
Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java?rev=1000236&r1=1000235&r2=1000236&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java Wed Sep 22 21:17:53 2010
@@ -266,7 +266,7 @@ public class AdministrativePointAddIT ex
// It should succeed
assertNotNull( response );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+ assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
// Add the entry under an SAP with the same role which has a parent AAP
entry = LdifUtils.createEntry(
@@ -294,9 +294,9 @@ public class AdministrativePointAddIT ex
response = connection.add( entry );
- // It should fail
+ // It should succeed
assertNotNull( response );
- assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+ assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
}
Added: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointDelIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointDelIT.java?rev=1000236&view=auto
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointDelIT.java (added)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointDelIT.java Wed Sep 22 21:17:53 2010
@@ -0,0 +1,314 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.server.admin;
+
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test cases for the AdministrativePoint Delete operation
+ *
+ * We will create the following data structure :
+ * <pre>
+ * ou=system
+ * |
+ * +-ou=SAP-AC
+ * | |
+ * | +-ou=SAP-CA
+ * | | |
+ * | | +-ou=AAP --> to be deleted
+ * | | |
+ * | | +-ou=IAP-CA : OK
+ * | | |
+ * | | +-ou=IAP-AC : OK
+ * | | |
+ * | | +-ou=IAP-SS : KO
+ * | |
+ * | +-ou=AAP --> to be deleted
+ * | |
+ * | +-ou=AAP : OK
+ * | |
+ * | +-ou=SAP-AC : OK
+ * | |
+ * | +-ou=SAP-CA : OK
+ * | |
+ * | +-ou=IAC-AC : OK
+ * | |
+ * | +-ou=IAC-CA : KO
+ * |
+ * +-ou=AAP
+ * | |
+ * | +-ou=AAP --> to be deleted
+ * | |
+ * | +-ou=AAP : OK
+ * | |
+ * | +-ou=SAP-CA : OK
+ * | |
+ * | +-ou=IAP-CA : OK
+ * |
+ * +-ou=AAP1 --> to be deleted
+ * |
+ * +-ou=AAP : OK
+ * |
+ * +-ou=SAP-CA : OK
+ * |
+ * +-ou=IAP-CA : KO
+ * </pre>
+ *
+ * and check that removing entries from this data structure does not break the server
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(transports =
+ { @CreateTransport(protocol = "LDAP") })
+@ApplyLdifs(
+ {
+ // Entry # 1
+ "dn: ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: SAP-AC",
+ "administrativeRole: accessControlSpecificArea",
+ "",
+ // Entry # 2
+ "dn: ou=SAP-CA,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: SAP-CA",
+ "administrativeRole: collectiveAttributeSpecificArea",
+ "",
+ // Entry # 3
+ "dn: ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 4
+ "dn: ou=IAP-CA,ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: IAP-CA",
+ "administrativeRole: collectiveAttributeInnerArea",
+ "",
+ // Entry # 5
+ "dn: ou=IAP-AC,ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: IAP-AC",
+ "administrativeRole: accessControlInnerArea",
+ "",
+ // Entry # 6
+ "dn: ou=IAP-TE,ou=AAP,ou=SAP-CA,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: IAP-TE",
+ "administrativeRole: triggerExecutionInnerArea",
+ "",
+ // Entry # 7
+ "dn: ou=AAP,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 8
+ "dn: ou=AAP,ou=AAP,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 9
+ "dn: ou=SAP-AC,ou=AAP,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: SAP-AC",
+ "administrativeRole: accessControlSpecificArea",
+ "",
+ // Entry # 10
+ "dn: ou=SAP-CA,ou=AAP,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: SAP-CA",
+ "administrativeRole: collectiveAttributeSpecificArea",
+ "",
+ // Entry # 11
+ "dn: ou=IAP-AC,ou=AAP,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: IAP-AC",
+ "administrativeRole: accessControlInnerArea",
+ "",
+ // Entry # 12
+ "dn: ou=IAP-CA,ou=AAP,ou=SAP-AC,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: IAP-CA",
+ "administrativeRole: collectiveAttributeInnerArea",
+ "",
+ // Entry # 13
+ "dn: ou=AAP,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 14
+ "dn: ou=AAP,ou=AAP,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 15
+ "dn: ou=AAP,ou=AAP,ou=AAP,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 16
+ "dn: ou=SAP-CA,ou=AAP,ou=AAP,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: SAP-CA",
+ "administrativeRole: collectiveAttributeSpecificArea",
+ "",
+ // Entry # 17
+ "dn: ou=IAP-CA,ou=AAP,ou=AAP,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: IAP-CA",
+ "administrativeRole: collectiveAttributeInnerArea",
+ "",
+ // Entry # 18
+ "dn: ou=AAP1,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP1",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 19
+ "dn: ou=AAP,ou=AAP1,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: AAP",
+ "administrativeRole: autonomousArea",
+ "",
+ // Entry # 20
+ "dn: ou=SAP-CA,ou=AAP1,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: SAP-CA",
+ "administrativeRole: collectiveAttributeSpecificArea",
+ "",
+ "",
+ // Entry # 21
+ "dn: ou=IAP-CA,ou=AAP1,ou=system",
+ "ObjectClass: top",
+ "ObjectClass: organizationalUnit",
+ "ou: IAP-CA",
+ "administrativeRole: collectiveAttributeInnerArea",
+ ""
+ })
+public class AdministrativePointDelIT extends AbstractLdapTestUnit
+{
+ // The shared LDAP connection
+ private static LdapConnection connection;
+
+ // A reference to the schema manager
+ private static SchemaManager schemaManager;
+
+ @Before
+ public void init() throws Exception
+ {
+ connection = IntegrationUtils.getAdminConnection( service );
+ schemaManager = ldapServer.getDirectoryService().getSchemaManager();
+ }
+
+
+ @After
+ public void shutdown() throws Exception
+ {
+ connection.close();
+ }
+
+
+ private EntryAttribute getAdminRole( String dn ) throws Exception
+ {
+ Entry lookup = connection.lookup( dn, "administrativeRole" );
+
+ assertNotNull( lookup );
+
+ return lookup.get( "administrativeRole" );
+ }
+
+
+ // -------------------------------------------------------------------
+ // Test the Delete operation
+ // -------------------------------------------------------------------
+ /**
+ * Test the deletion of AAPs
+ */
+ @Test
+ public void testDeleteAAP() throws Exception
+ {
+ assertTrue( ldapServer.isStarted() );
+ }
+
+
+ /**
+ * Test the addition of SAPs
+ */
+ @Test
+ public void testDeleteSAP() throws Exception
+ {
+ assertTrue( ldapServer.isStarted() );
+ }
+
+
+ /**
+ * Test the deletion of IAPs
+ */
+ @Test
+ public void testDeleteIAP() throws Exception
+ {
+ assertTrue( ldapServer.isStarted() );
+ }
+}