You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by tv...@apache.org on 2008/10/07 18:40:51 UTC
svn commit: r702539 [2/2] - in /turbine/fulcrum/trunk/security/ldap: ./ src/
src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/fulcrum/
src/java/org/apache/fulcrum/security/
src/java/org/apache/fulcrum/security/authenticator/ src/java/or...
Added: turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadComponentConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadComponentConfig.xml?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadComponentConfig.xml (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadComponentConfig.xml Tue Oct 7 09:40:50 2008
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<my-system>
+ <securityService/>
+ <userManager>
+ <className>org.apache.fulcrum.security.ldap.basic.LDAPBasicUser</className>
+ <ldap>
+ <provider>com.sun.jndi.ldap.LdapCtxFactory</provider>
+ <securityAuthentication>simple</securityAuthentication>
+ <port>389</port>
+ <host>localhost</host>
+ <adminUsername>CN=Manager,DC=apache,DC=org</adminUsername>
+ <adminPassword>secret</adminPassword>
+ <basesearch>DC=apache,DC=org</basesearch>
+ <userAttributes>
+ <!-- OpenLDAP Directory settings -->
+ <objectClass>pilotPerson</objectClass>
+ <userid>uid</userid>
+ <username>sn</username>
+ <firstname>givenName</firstname>
+ <lastname>sn</lastname>
+ <email>mail</email>
+ <password>userPassword</password>
+ </userAttributes>
+ </ldap>
+ </userManager>
+ <groupManager>
+ <className>org.apache.fulcrum.security.model.basic.entity.impl.BasicGroupImpl</className>
+ </groupManager>
+</my-system>
Added: turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadRoleConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadRoleConfig.xml?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadRoleConfig.xml (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/LazyLoadRoleConfig.xml Tue Oct 7 09:40:50 2008
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- This configuration file for Avalon components is used for testing the TestComponent -->
+<role-list>
+ <role
+ name="org.apache.fulcrum.security.SecurityService"
+ shorthand="securityService"
+ default-class="org.apache.fulcrum.security.BaseSecurityService"/>
+ <role
+ name="org.apache.fulcrum.security.UserManager"
+ shorthand="userManager"
+ early-init="true"
+ default-class="org.apache.fulcrum.security.ldap.LDAPUserManagerImpl"/>
+ <role
+ name="org.apache.fulcrum.security.GroupManager"
+ shorthand="groupManager"
+ default-class="org.apache.fulcrum.security.memory.MemoryGroupManagerImpl"/>
+
+</role-list>
+
Added: turbine/fulcrum/trunk/security/ldap/src/test/Log4j.properties
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/Log4j.properties?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/Log4j.properties (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/Log4j.properties Tue Oct 7 09:40:50 2008
@@ -0,0 +1,106 @@
+# 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.
+# ------------------------------------------------------------------------
+#
+# Logging Configuration
+#
+# Mix of Turbine logging configuration and Hibernate configuration
+#
+# ------------------------------------------------------------------------
+
+#
+# If we don't know the logging facility, put it into the
+# turbine.log
+#
+log4j.rootLogger = INFO, turbine
+
+#
+# Turbine goes into Turbine Log
+#
+log4j.category.org.apache.turbine = INFO, turbine
+log4j.additivity.org.apache.turbine = false
+
+#
+# Avalon Logfile
+#
+log4j.category.avalon = INFO, avalon
+log4j.additivity.avalon = false
+
+# #######################################################################
+#
+# Logfile definitions
+#
+# #######################################################################
+
+#
+# turbine.log
+#
+log4j.appender.turbine = org.apache.log4j.FileAppender
+log4j.appender.turbine.file = turbine.log
+log4j.appender.turbine.layout = org.apache.log4j.PatternLayout
+log4j.appender.turbine.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.turbine.append = false
+
+#
+# torque.log
+#
+log4j.appender.torque = org.apache.log4j.FileAppender
+log4j.appender.torque.file = target/torque.log
+log4j.appender.torque.layout = org.apache.log4j.PatternLayout
+log4j.appender.torque.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.torque.append = false
+
+#
+# Avalon gets configured to write its output onto the avalon
+# category.
+#
+log4j.appender.avalon = org.apache.log4j.FileAppender
+log4j.appender.avalon.file = target/avalon.log
+log4j.appender.avalon.layout = org.apache.log4j.PatternLayout
+log4j.appender.avalon.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.avalon.append = false
+
+
+# BEGIN HIBERNATE SECTION
+# ## direct log messages to stdout ###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+# ## direct messages to file hibernate.log ###
+# log4j.appender.file=org.apache.log4j.FileAppender
+# log4j.appender.file.File=hibernate.log
+# log4j.appender.file.layout=org.apache.log4j.PatternLayout
+# log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+# ## set log levels - for more verbose logging change 'info' to 'debug' ##
+
+log4j.rootLogger=warn, stdout
+
+log4j.logger.net.sf.hibernate=warn
+
+# ## enable the following line if you want to track down connection ###
+# ## leakages when using DriverManagerConnectionProvider ###
+# log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace
+
+# ## log JDBC bind parameters ###
+log4j.logger.net.sf.hibernate.type=info
+
+# ## log prepared statement cache activity ###
+log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=info
+
Added: turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPComponentConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPComponentConfig.xml?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPComponentConfig.xml (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPComponentConfig.xml Tue Oct 7 09:40:50 2008
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<my-system>
+ <securityService/>
+ <authenticator/>
+ <modelManager/>
+ <aclFactory/>
+ <userManager>
+ <className>org.apache.fulcrum.security.ldap.turbine.LDAPTurbineUser</className>
+ <ldap>
+ <provider>com.sun.jndi.ldap.LdapCtxFactory</provider>
+ <securityAuthentication>simple</securityAuthentication>
+ <port>389</port>
+ <host>localhost</host>
+ <adminUsername>CN=Manager,DC=apache,DC=org</adminUsername>
+ <adminPassword>secret</adminPassword>
+ <basesearch>DC=apache,DC=org</basesearch>
+ <userAttributes>
+ <!-- OpenLDAP Directory settings -->
+ <objectClass>pilotPerson</objectClass>
+ <userid>uid</userid>
+ <username>sn</username>
+ <firstname>givenName</firstname>
+ <lastname>sn</lastname>
+ <email>mail</email>
+ <password>userPassword</password>
+ </userAttributes>
+ </ldap>
+ </userManager>
+ <groupManager>
+ <className>org.apache.fulcrum.security.model.turbine.entity.impl.TurbineGroupImpl</className>
+ </groupManager>
+ <roleManager>
+ <className>org.apache.fulcrum.security.model.turbine.entity.impl.TurbineRoleImpl</className>
+ </roleManager>
+ <permissionManager>
+ <className>org.apache.fulcrum.security.model.turbine.entity.impl.TurbinePermissionImpl</className>
+ </permissionManager>
+</my-system>
Added: turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPRoleConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPRoleConfig.xml?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPRoleConfig.xml (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/TurbineLDAPRoleConfig.xml Tue Oct 7 09:40:50 2008
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- This configuration file for Avalon components is used for testing the TestComponent -->
+<role-list>
+ <role
+ name="org.apache.fulcrum.security.SecurityService"
+ shorthand="securityService"
+ default-class="org.apache.fulcrum.security.BaseSecurityService"/>
+ <role
+ name="org.apache.fulcrum.security.UserManager"
+ shorthand="userManager"
+ early-init="true"
+ default-class="org.apache.fulcrum.security.ldap.turbine.LDAPTurbineUserManagerImpl"/>
+ <role
+ name="org.apache.fulcrum.security.GroupManager"
+ shorthand="groupManager"
+ default-class="org.apache.fulcrum.security.memory.MemoryGroupManagerImpl"/>
+ <role
+ name="org.apache.fulcrum.security.RoleManager"
+ shorthand="roleManager"
+ default-class="org.apache.fulcrum.security.memory.MemoryRoleManagerImpl"/>
+ <role
+ name="org.apache.fulcrum.security.PermissionManager"
+ shorthand="permissionManager"
+ default-class="org.apache.fulcrum.security.memory.MemoryPermissionManagerImpl"/>
+ <role
+ name="org.apache.fulcrum.security.ModelManager"
+ shorthand="modelManager"
+ default-class="org.apache.fulcrum.security.memory.turbine.MemoryTurbineModelManagerImpl"/>
+ <role
+ name="org.apache.fulcrum.security.authenticator.Authenticator"
+ shorthand="authenticator"
+ default-class="org.apache.fulcrum.security.authenticator.LDAPAuthenticator"/>
+ <role
+ name="org.apache.fulcrum.security.model.ACLFactory"
+ shorthand="aclFactory"
+ default-class="org.apache.fulcrum.security.model.dynamic.DynamicACLFactory"/>
+</role-list>
+
Added: turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/StartingSecurityServicesTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/StartingSecurityServicesTest.java?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/StartingSecurityServicesTest.java (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/StartingSecurityServicesTest.java Tue Oct 7 09:40:50 2008
@@ -0,0 +1,95 @@
+package org.apache.fulcrum.security.ldap;
+/*
+ * 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.
+ */
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.fulcrum.security.SecurityService;
+import org.apache.fulcrum.security.ldap.LDAPUserManagerImpl;
+import org.apache.fulcrum.security.model.basic.BasicModelManager;
+import org.apache.fulcrum.security.model.dynamic.DynamicModelManager;
+import org.apache.fulcrum.security.model.turbine.TurbineModelManager;
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+
+/**
+ * @author <a href="mailto:marco@intermeta.de">Marco Knüttel</a>
+ * @version $Id:StartingSecurityServicesTest.java 535465 2007-05-05 06:58:06Z tv $
+ */
+
+public class StartingSecurityServicesTest extends BaseUnitTest
+{
+ private SecurityService securityService = null;
+ public StartingSecurityServicesTest(String name)
+ {
+ super(name);
+ }
+ public void testStartingDynamicModel() throws Exception
+ {
+ this.setRoleFileName("src/test/DynamicLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/DynamicLDAPComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ assertTrue(securityService.getClass().getName(),
+ securityService.getUserManager() instanceof LDAPUserManagerImpl);
+ assertTrue(
+ securityService.getModelManager() instanceof DynamicModelManager);
+ }
+
+ public void testStartingTurbineModel() throws Exception
+ {
+ this.setRoleFileName("src/test/TurbineLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/TurbineLDAPComponentConfig.xml");
+
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ assertTrue(
+ securityService.getUserManager()
+ instanceof org.apache.fulcrum.security.ldap.turbine
+ .LDAPTurbineUserManagerImpl);
+ assertTrue(
+ securityService.getModelManager() instanceof TurbineModelManager);
+ }
+
+ public void testStartingBasicModel() throws Exception
+ {
+ this.setRoleFileName("src/test/BasicLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/BasicLDAPComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ assertTrue(
+ securityService.getUserManager() instanceof LDAPUserManagerImpl);
+ assertTrue(
+ securityService.getModelManager() instanceof BasicModelManager);
+ }
+
+ public void testLazyLoadingOfServices() throws Exception
+ {
+ this.setRoleFileName("src/test/LazyLoadRoleConfig.xml");
+ this.setConfigurationFileName("src/test/LazyLoadComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ assertTrue(
+ securityService.getUserManager() instanceof LDAPUserManagerImpl);
+ try
+ {
+ securityService.getModelManager();
+ fail("Should have throw runtime error");
+ }
+ catch (RuntimeException re)
+ {
+ assertTrue(
+ "Type was " + re.getCause().getClass().getName(),
+ re.getCause() instanceof ServiceException);
+ }
+ }
+}
Added: turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/acl/AccessControlListTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/acl/AccessControlListTest.java?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/acl/AccessControlListTest.java (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/acl/AccessControlListTest.java Tue Oct 7 09:40:50 2008
@@ -0,0 +1,490 @@
+package org.apache.fulcrum.security.ldap.acl;
+/*
+ * 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.
+ */
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.fulcrum.security.GroupManager;
+import org.apache.fulcrum.security.PermissionManager;
+import org.apache.fulcrum.security.RoleManager;
+import org.apache.fulcrum.security.SecurityService;
+import org.apache.fulcrum.security.UserManager;
+import org.apache.fulcrum.security.acl.AccessControlList;
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.entity.Permission;
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.dynamic.DynamicAccessControlList;
+import org.apache.fulcrum.security.model.dynamic.DynamicAccessControlListImpl;
+import org.apache.fulcrum.security.model.dynamic.DynamicModelManager;
+import org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup;
+import org.apache.fulcrum.security.model.dynamic.entity.DynamicRole;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.GroupSet;
+import org.apache.fulcrum.security.util.PermissionSet;
+import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.fulcrum.security.util.UserSet;
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+
+/**
+ * Test that we can generate AccessControlLists from the Factory
+ *
+ * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
+ * @version $Id:AccessControlListTest.java 535465 2007-05-05 06:58:06Z tv $
+ */
+public class AccessControlListTest extends BaseUnitTest
+{
+
+ private UserManager userManager;
+ private GroupManager groupManager;
+ private RoleManager roleManager;
+ private DynamicModelManager modelManager;
+ private PermissionManager permissionManager;
+ private DynamicAccessControlList acl;
+ private static int counter = 1;
+ private User user;
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public AccessControlListTest(String name)
+ {
+ super(name);
+ }
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(AccessControlListTest.class);
+ }
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ this.setRoleFileName("src/test/DynamicLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/DynamicLDAPComponentConfig.xml");
+
+ SecurityService securityService =
+ (SecurityService) lookup(SecurityService.ROLE);
+ userManager = securityService.getUserManager();
+ groupManager = securityService.getGroupManager();
+ roleManager = securityService.getRoleManager();
+ permissionManager = securityService.getPermissionManager();
+ modelManager = (DynamicModelManager) securityService.getModelManager();
+
+ }
+
+ /**
+ * Clean up after us
+ *
+ * @see org.apache.fulcrum.testcontainer.BaseUnitTest#tearDown()
+ */
+ protected void tearDown()
+ {
+ try
+ {
+ UserSet users = userManager.getAllUsers();
+
+ for (Iterator i = users.iterator(); i.hasNext();)
+ {
+ User user = (User)i.next();
+ userManager.removeUser(user);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ super.tearDown();
+ }
+
+ public void testCreatingDefaultAccessControlListViaFactory()
+ throws Exception
+ {
+ Group group = getGroup();
+ Role role = getRole();
+ Permission permission = getPermission();
+ user = userManager.getUserInstance("User 1");
+ userManager.addUser(user, "secretpassword");
+ modelManager.grant(user, group);
+ modelManager.grant(group, role);
+ modelManager.grant(role, permission);
+ RoleSet roleSet = new RoleSet();
+ PermissionSet permissionSet = new PermissionSet();
+ roleSet.add(role);
+ permissionSet.add(permission);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, roleSet);
+ permissionSets.put(role, permissionSet);
+ AccessControlList acl = userManager.getACL(user);
+ assertTrue(acl instanceof DynamicAccessControlList);
+ DynamicAccessControlList dacl = (DynamicAccessControlList) acl;
+ assertTrue(dacl.hasRole(role));
+ assertTrue(dacl.hasPermission(permission));
+
+ }
+ public void testGetRolesGroup() throws Exception
+ {
+ Group group = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ RoleSet resultRoleSet = acl.getRoles(group);
+ assertTrue(resultRoleSet.contains(role));
+ assertTrue(resultRoleSet.contains(role2));
+ assertFalse(resultRoleSet.contains(role3));
+ }
+ /*
+ * Class to test for RoleSet getRoles()
+ */
+ public void testGetRoles() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role2);
+ modelManager.grant(group2, role3);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ RoleSet resultRoleSet = acl.getRoles();
+ assertTrue(resultRoleSet.contains(role));
+ assertTrue(resultRoleSet.contains(role2));
+ assertTrue(resultRoleSet.contains(role3));
+ assertEquals(3, resultRoleSet.size());
+ }
+ /*
+ * Class to test for PermissionSet getPermissions(Group)
+ */
+ public void testGetPermissionsGroup() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ Permission permission = getPermission();
+ Permission permission2 = getPermission();
+ Permission permission3 = getPermission();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role3);
+ modelManager.grant(role, permission);
+ modelManager.grant(role, permission2);
+ modelManager.grant(role, permission3);
+ modelManager.grant(role2, permission2);
+ modelManager.grant(role2, permission3);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ permissionSets.put(role, ((DynamicRole) role).getPermissions());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ PermissionSet resultPermissionSet = acl.getPermissions(group);
+ assertEquals(3, resultPermissionSet.size());
+ assertTrue(resultPermissionSet.contains(permission));
+ assertTrue(resultPermissionSet.contains(permission2));
+ assertTrue(resultPermissionSet.contains(permission3));
+ resultPermissionSet = acl.getPermissions(group2);
+ assertEquals(0, resultPermissionSet.size());
+ }
+ /*
+ * Class to test for PermissionSet getPermissions()
+ */
+ public void testGetPermissions() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ Permission permission = getPermission();
+ Permission permission2 = getPermission();
+ Permission permission3 = getPermission();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role3);
+ modelManager.grant(role, permission);
+ modelManager.grant(role, permission2);
+ modelManager.grant(role, permission3);
+ modelManager.grant(role2, permission2);
+ modelManager.grant(role2, permission3);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ permissionSets.put(role, ((DynamicRole) role).getPermissions());
+ permissionSets.put(role2, ((DynamicRole) role2).getPermissions());
+ permissionSets.put(role3, ((DynamicRole) role3).getPermissions());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ PermissionSet resultPermissionSet = acl.getPermissions();
+ assertEquals(3, resultPermissionSet.size());
+ }
+ /*
+ * Class to test for boolean hasRole(Role, Group)
+ */
+ public void testHasRoleRoleGroup() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role);
+ modelManager.grant(group2, role3);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ assertTrue(acl.hasRole(role, group));
+ assertTrue(acl.hasRole(role, group2));
+ assertTrue(acl.hasRole(role2, group));
+ assertFalse(acl.hasRole(role2, group2));
+ assertTrue(acl.hasRole(role, group2));
+ assertFalse(acl.hasRole(role2, group2));
+ assertTrue(acl.hasRole(role3, group2));
+ }
+ /*
+ * Class to test for boolean hasRole(Role, GroupSet)
+ */
+ public void testHasRoleRoleGroupSet() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role);
+ modelManager.grant(group2, role3);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ GroupSet groupSet = new GroupSet();
+ groupSet.add(group);
+ assertTrue(acl.hasRole(role, groupSet));
+ assertTrue(acl.hasRole(role2, groupSet));
+ assertFalse(acl.hasRole(role3, groupSet));
+ groupSet.add(group2);
+ assertTrue(acl.hasRole(role, groupSet));
+ assertTrue(acl.hasRole(role2, groupSet));
+ assertTrue(acl.hasRole(role3, groupSet));
+ groupSet.add(group2);
+ }
+ /*
+ * Class to test for boolean hasRole(String, String)
+ */
+ public void testHasRoleStringString() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role);
+ modelManager.grant(group2, role3);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ assertTrue(acl.hasRole(role.getName(), group.getName()));
+ assertTrue(acl.hasRole(role.getName(), group2.getName()));
+ assertTrue(acl.hasRole(role2.getName(), group.getName()));
+ assertFalse(acl.hasRole(role2.getName(), group2.getName()));
+ assertTrue(acl.hasRole(role.getName(), group2.getName()));
+ assertFalse(acl.hasRole(role2.getName(), group2.getName()));
+ assertTrue(acl.hasRole(role3.getName(), group2.getName()));
+ }
+ /*
+ * Class to test for boolean hasPermission(Permission, Group)
+ */
+ public void testHasPermissionPermissionGroup() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ Permission permission = getPermission();
+ Permission permission2 = getPermission();
+ Permission permission3 = getPermission();
+ Permission permission4 = getPermission();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role3);
+ modelManager.grant(role, permission);
+ modelManager.grant(role, permission2);
+ modelManager.grant(role, permission3);
+ modelManager.grant(role2, permission2);
+ modelManager.grant(role2, permission3);
+ modelManager.grant(role3, permission4);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ permissionSets.put(role, ((DynamicRole) role).getPermissions());
+ permissionSets.put(role2, ((DynamicRole) role2).getPermissions());
+ permissionSets.put(role3, ((DynamicRole) role3).getPermissions());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ assertTrue(acl.hasPermission(permission, group));
+ assertTrue(acl.hasPermission(permission2, group));
+ assertTrue(acl.hasPermission(permission3, group));
+ assertFalse(acl.hasPermission(permission4, group));
+ assertTrue(acl.hasPermission(permission4, group2));
+ assertFalse(acl.hasPermission(permission, group2));
+ }
+ /*
+ * Class to test for boolean hasPermission(Permission, GroupSet)
+ */
+ public void testHasPermissionPermissionGroupSet() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Group group3 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ Role role4 = getRole();
+ Permission permission = getPermission();
+ Permission permission2 = getPermission();
+ Permission permission3 = getPermission();
+ Permission permission4 = getPermission();
+ Permission permission5 = getPermission();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role3);
+ modelManager.grant(group3, role4);
+ modelManager.grant(role, permission);
+ modelManager.grant(role, permission2);
+ modelManager.grant(role, permission3);
+ modelManager.grant(role2, permission2);
+ modelManager.grant(role2, permission3);
+ modelManager.grant(role3, permission4);
+ modelManager.grant(role4, permission5);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ roleSets.put(group3, ((DynamicGroup) group3).getRoles());
+ permissionSets.put(role, ((DynamicRole) role).getPermissions());
+ permissionSets.put(role2, ((DynamicRole) role2).getPermissions());
+ permissionSets.put(role3, ((DynamicRole) role3).getPermissions());
+ permissionSets.put(role4, ((DynamicRole) role4).getPermissions());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ GroupSet groupSet = new GroupSet();
+ groupSet.add(group);
+ groupSet.add(group2);
+ assertTrue(acl.hasPermission(permission, groupSet));
+ assertFalse(acl.hasPermission(permission5, groupSet));
+ groupSet.add(group3);
+ assertTrue(acl.hasPermission(permission5, groupSet));
+ }
+ /*
+ * Class to test for boolean hasPermission(Permission)
+ */
+ public void testHasPermissionPermission() throws Exception
+ {
+ Group group = getGroup();
+ Group group2 = getGroup();
+ Group group3 = getGroup();
+ Role role = getRole();
+ Role role2 = getRole();
+ Role role3 = getRole();
+ Role role4 = getRole();
+ Permission permission = getPermission();
+ Permission permission2 = getPermission();
+ Permission permission3 = getPermission();
+ Permission permission4 = getPermission();
+ Permission permission5 = getPermission();
+ modelManager.grant(group, role);
+ modelManager.grant(group, role2);
+ modelManager.grant(group2, role3);
+ modelManager.grant(group3, role4);
+ modelManager.grant(role, permission);
+ modelManager.grant(role, permission2);
+ modelManager.grant(role, permission3);
+ modelManager.grant(role2, permission2);
+ modelManager.grant(role2, permission3);
+ modelManager.grant(role3, permission4);
+ modelManager.grant(role4, permission5);
+ Map roleSets = new HashMap();
+ Map permissionSets = new HashMap();
+ roleSets.put(group, ((DynamicGroup) group).getRoles());
+ roleSets.put(group2, ((DynamicGroup) group2).getRoles());
+ roleSets.put(group3, ((DynamicGroup) group3).getRoles());
+ permissionSets.put(role, ((DynamicRole) role).getPermissions());
+ permissionSets.put(role2, ((DynamicRole) role2).getPermissions());
+ permissionSets.put(role3, ((DynamicRole) role3).getPermissions());
+ permissionSets.put(role4, ((DynamicRole) role4).getPermissions());
+ acl = new DynamicAccessControlListImpl(roleSets, permissionSets);
+ assertTrue(acl.hasPermission(permission));
+ assertTrue(acl.hasPermission(permission2));
+ assertTrue(acl.hasPermission(permission3));
+ assertTrue(acl.hasPermission(permission4));
+ assertTrue(acl.hasPermission(permission5));
+ }
+
+ private int getId()
+ {
+ return ++counter;
+ }
+ private Role getRole() throws Exception
+ {
+ Role role = roleManager.getRoleInstance("Role " + getId());
+ roleManager.addRole(role);
+ return role;
+ }
+ private Group getGroup() throws Exception
+ {
+ Group group = groupManager.getGroupInstance("Group " + getId());
+ groupManager.addGroup(group);
+ return group;
+ }
+ private Permission getPermission() throws Exception
+ {
+ Permission permission =
+ permissionManager.getPermissionInstance("Permission " + getId());
+ permissionManager.addPermission(permission);
+ return permission;
+ }
+}
Added: turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPBasicModelManagerTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPBasicModelManagerTest.java?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPBasicModelManagerTest.java (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPBasicModelManagerTest.java Tue Oct 7 09:40:50 2008
@@ -0,0 +1,80 @@
+package org.apache.fulcrum.security.ldap.basic;
+/*
+ * 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.
+ */
+
+
+
+import java.util.Iterator;
+
+import org.apache.fulcrum.security.SecurityService;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.basic.test.AbstractModelManagerTest;
+import org.apache.fulcrum.security.util.UserSet;
+
+/**
+ * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
+ * @version $Id:LDAPBasicModelManagerTest.java 535465 2007-05-05 06:58:06Z tv $
+ */
+public class LDAPBasicModelManagerTest extends AbstractModelManagerTest
+{
+ /**
+ * @param arg0
+ */
+ public LDAPBasicModelManagerTest(String arg0)
+ {
+ super(arg0);
+ }
+ public void setUp()
+ {
+ try
+ {
+ this.setRoleFileName("src/test/BasicLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/BasicLDAPComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ super.setUp();
+
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+ }
+ public void tearDown()
+ {
+ try
+ {
+ UserSet users = userManager.getAllUsers();
+
+ for (Iterator i = users.iterator(); i.hasNext();)
+ {
+ User user = (User)i.next();
+ userManager.removeUser(user);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ super.tearDown();
+ groupManager=null;
+ securityService = null;
+ }
+}
Added: turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPUserManagerTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPUserManagerTest.java?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPUserManagerTest.java (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/basic/LDAPUserManagerTest.java Tue Oct 7 09:40:50 2008
@@ -0,0 +1,102 @@
+package org.apache.fulcrum.security.ldap.basic;
+/*
+ * 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.
+ */
+
+import java.util.Iterator;
+
+import org.apache.fulcrum.security.SecurityService;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.test.AbstractUserManagerTest;
+import org.apache.fulcrum.security.util.UserSet;
+/**
+ * @author Eric Pugh
+ *
+ * Test the memory implementation of the Simple model..
+ */
+public class LDAPUserManagerTest extends AbstractUserManagerTest
+{
+
+ public void setUp()
+ {
+ try
+ {
+ this.setRoleFileName("src/test/BasicLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/BasicLDAPComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ userManager = securityService.getUserManager();
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+ }
+
+ /**
+ * Clean up after us
+ *
+ * @see org.apache.fulcrum.testcontainer.BaseUnitTest#tearDown()
+ */
+ protected void tearDown()
+ {
+ try
+ {
+ UserSet users = userManager.getAllUsers();
+
+ for (Iterator i = users.iterator(); i.hasNext();)
+ {
+ User user = (User)i.next();
+ userManager.removeUser(user);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ super.tearDown();
+ }
+
+ /**
+ * Constructor for MemoryPermissionManagerTest.
+ * @param arg0
+ */
+ public LDAPUserManagerTest(String arg0)
+ {
+ super(arg0);
+ }
+
+ /**
+ * @see org.apache.fulcrum.security.model.test.AbstractUserManagerTest#testChangePassword()
+ */
+ public void testChangePassword() throws Exception
+ {
+ // Not supported
+ }
+
+ /**
+ * @see org.apache.fulcrum.security.model.test.AbstractUserManagerTest#testForcePassword()
+ */
+ public void testForcePassword() throws Exception
+ {
+ // Not supported
+ }
+
+
+}
Added: turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPDynamicModelManagerTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPDynamicModelManagerTest.java?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPDynamicModelManagerTest.java (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPDynamicModelManagerTest.java Tue Oct 7 09:40:50 2008
@@ -0,0 +1,78 @@
+package org.apache.fulcrum.security.ldap.dynamic;
+/*
+ * 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.
+ */
+
+import java.util.Iterator;
+
+import org.apache.fulcrum.security.SecurityService;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.dynamic.test.AbstractDynamicModelManagerTest;
+import org.apache.fulcrum.security.util.UserSet;
+
+/**
+ * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
+ * @version $Id:LDAPDynamicModelManagerTest.java 535465 2007-05-05 06:58:06Z tv $
+ */
+public class LDAPDynamicModelManagerTest extends AbstractDynamicModelManagerTest
+{
+ /**
+ * @param arg0
+ */
+ public LDAPDynamicModelManagerTest(String arg0)
+ {
+ super(arg0);
+ }
+ public void setUp()
+ {
+ try
+ {
+ this.setRoleFileName("src/test/DynamicLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/DynamicLDAPComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ super.setUp();
+
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+ }
+ public void tearDown()
+ {
+ try
+ {
+ UserSet users = userManager.getAllUsers();
+
+ for (Iterator i = users.iterator(); i.hasNext();)
+ {
+ User user = (User)i.next();
+ userManager.removeUser(user);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ super.tearDown();
+ groupManager=null;
+ securityService = null;
+ }
+}
Added: turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPUserManagerTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPUserManagerTest.java?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPUserManagerTest.java (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/dynamic/LDAPUserManagerTest.java Tue Oct 7 09:40:50 2008
@@ -0,0 +1,79 @@
+package org.apache.fulcrum.security.ldap.dynamic;
+/*
+ * 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.
+ */
+
+import java.util.Iterator;
+
+import org.apache.fulcrum.security.SecurityService;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.test.AbstractUserManagerTest;
+import org.apache.fulcrum.security.util.UserSet;
+/**
+ * @author Eric Pugh
+ *
+ * Test the memory implementation of the Simple model..
+ */
+public class LDAPUserManagerTest extends AbstractUserManagerTest
+{
+
+ public void setUp()
+ {
+ try
+ {
+ this.setRoleFileName("src/test/DynamicLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/DynamicLDAPComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ userManager = securityService.getUserManager();
+ }
+ catch (Exception e)
+ {
+ fail(e.toString());
+ }
+ }
+ public void tearDown()
+ {
+ try
+ {
+ UserSet users = userManager.getAllUsers();
+
+ for (Iterator i = users.iterator(); i.hasNext();)
+ {
+ User user = (User)i.next();
+ userManager.removeUser(user);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ user = null;
+ userManager = null;
+ securityService = null;
+ }
+ /**
+ * Constructor for LDAPPermissionManagerTest.
+ * @param arg0
+ */
+ public LDAPUserManagerTest(String arg0)
+ {
+ super(arg0);
+ }
+}
Added: turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/turbine/LDAPTurbineModelManagerTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/turbine/LDAPTurbineModelManagerTest.java?rev=702539&view=auto
==============================================================================
--- turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/turbine/LDAPTurbineModelManagerTest.java (added)
+++ turbine/fulcrum/trunk/security/ldap/src/test/org/apache/fulcrum/security/ldap/turbine/LDAPTurbineModelManagerTest.java Tue Oct 7 09:40:50 2008
@@ -0,0 +1,83 @@
+package org.apache.fulcrum.security.ldap.turbine;
+/*
+ * 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.
+ */
+
+import java.util.Iterator;
+
+import org.apache.fulcrum.security.SecurityService;
+import org.apache.fulcrum.security.entity.User;
+import org
+ .apache
+ .fulcrum
+ .security
+ .model
+ .turbine
+ .test
+ .AbstractTurbineModelManagerTest;
+import org.apache.fulcrum.security.util.UserSet;
+
+/**
+ * @author Eric Pugh
+ *
+ * Test the memory implementation of the turbine model..
+ */
+public class LDAPTurbineModelManagerTest
+ extends AbstractTurbineModelManagerTest
+{
+
+ public void setUp() throws Exception
+ {
+
+ this.setRoleFileName("src/test/TurbineLDAPRoleConfig.xml");
+ this.setConfigurationFileName("src/test/TurbineLDAPComponentConfig.xml");
+ securityService = (SecurityService) lookup(SecurityService.ROLE);
+ super.setUp();
+
+ }
+ public void tearDown()
+ {
+ try
+ {
+ UserSet users = userManager.getAllUsers();
+
+ for (Iterator i = users.iterator(); i.hasNext();)
+ {
+ User user = (User)i.next();
+ userManager.removeUser(user);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+
+ super.tearDown();
+ modelManager = null;
+ securityService = null;
+ }
+ /**
+ * Constructor for LDAPPermissionManagerTest.
+ * @param arg0
+ */
+ public LDAPTurbineModelManagerTest(String arg0)
+ {
+ super(arg0);
+ }
+}