You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/11/13 17:13:30 UTC
cvs commit: cocoon-lenya/src/test/org/apache/lenya/cms/workflow WorkflowTest.java
andreas 2003/11/13 08:13:30
Modified: src/test/org/apache/lenya/cms lenya.xtest
src/test/org/apache/lenya/cms/workflow WorkflowTest.java
Added: src/test/org/apache/lenya/ac/impl PolicyManagerTest.java
GroupManagerTest.java UserManagerTest.java
AccreditableManagerTest.java PolicyTest.java
LDAPUserTest.java IdentityTestCase.xtest
RoleManagerTest.java AccessControlTest.java
IdentityTest.java AccessControllerTest.java
src/test/org/apache/lenya/ac/file FileUserTest.java
FileGroupTest.java FileRoleTest.java
Removed: src/test/org/apache/lenya/cms/ac FileUserTest.java
AccessControlTest.java IdentityTestCase.java
RoleManagerTest.java FileRoleTest.java
LDAPUserTest.java IdentityTestCase.xtest
FileGroupTest.java UserManagerTest.java
GroupManagerTest.java
src/test/org/apache/lenya/cms/ac2 AccessControlTest.java
AccessControllerTest.java PolicyTest.java
PolicyManagerTest.java AccreditableManagerTest.java
IdentityTest.java
Log:
refactoring access control package structure
Revision Changes Path
1.4 +3 -2 cocoon-lenya/src/test/org/apache/lenya/cms/lenya.xtest
Index: lenya.xtest
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/test/org/apache/lenya/cms/lenya.xtest,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- lenya.xtest 5 Nov 2003 16:29:39 -0000 1.3
+++ lenya.xtest 13 Nov 2003 16:13:29 -0000 1.4
@@ -102,9 +102,10 @@
</logkit>
<context>
- <entry name="foo" value="bar"/>
+ <entry name="container.rootDir" value="/d:/development/build/tomcat-4.1.27/webapps/lenya/"/>
+ <entry name="context-root" value="/d:/development/build/tomcat-4.1.27/webapps/lenya/"/>
</context>
-
+
<roles>
<role name="org.apache.excalibur.source.SourceFactorySelector"
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/PolicyManagerTest.java
Index: PolicyManagerTest.java
===================================================================
/*
$Id: PolicyManagerTest.java,v 1.1 2003/11/13 16:13:29 andreas Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import junit.textui.TestRunner;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.PolicyManager;
import org.apache.lenya.cms.PublicationHelper;
/**
* @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
*/
public class PolicyManagerTest extends AccessControlTest {
/**
* Create an instance of PolicyManagerTest
*
* @param test a test
*/
public PolicyManagerTest(String test) {
super(test);
}
/**
* The main method.
* @param args The command-line arguments.
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
TestRunner.run(AccessControllerTest.class);
}
private static String[] URLS = { "/test/authoring/index.html" };
/**
* The test.
* @throws AccessControlException when something went wrong.
*/
public void testAccessController() throws AccessControlException {
DefaultAccessController controller = getAccessController();
PolicyManager policyManager = controller.getPolicyManager();
assertNotNull(policyManager);
for (int i = 0; i < URLS.length; i++) {
Policy policy = policyManager.getPolicy(controller.getAccreditableManager(), URLS[i]);
assertNotNull(policy);
assertTrue(policy.getRoles(getIdentity()).length > 0);
}
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/GroupManagerTest.java
Index: GroupManagerTest.java
===================================================================
/*
$Id: GroupManagerTest.java,v 1.1 2003/11/13 16:13:29 andreas Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.file.FileGroupManager;
import org.apache.lenya.cms.PublicationHelper;
import java.io.File;
/**
* @author egli
*
*
*/
public class GroupManagerTest extends AccessControlTest {
/**
* Constructor for GroupManagerTest.
* @param arg0 command line args
*/
public GroupManagerTest(String arg0) {
super(arg0);
}
/**
* DOCUMENT ME!
*
* @param args DOCUMENT ME!
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
junit.textui.TestRunner.run(GroupManagerTest.class);
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
*/
public final void testInstance() throws AccessControlException {
FileGroupManager manager = null;
File configDir = getAccreditablesDirectory();
manager = FileGroupManager.instance(configDir);
assertNotNull(manager);
FileGroupManager anotherManager = null;
anotherManager = FileGroupManager.instance(configDir);
assertNotNull(anotherManager);
assertEquals(manager, anotherManager);
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/UserManagerTest.java
Index: UserManagerTest.java
===================================================================
/*
$Id: UserManagerTest.java,v 1.1 2003/11/13 16:13:29 andreas Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Group;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.file.FileGroup;
import org.apache.lenya.ac.file.FileGroupManager;
import org.apache.lenya.ac.file.FileRole;
import org.apache.lenya.ac.file.FileUser;
import org.apache.lenya.ac.file.FileUserManager;
import org.apache.lenya.cms.PublicationHelper;
import java.io.File;
/**
* @author egli
*
*
*/
public class UserManagerTest extends AccessControlTest {
/**
* Constructor for UserManagerTest.
* @param arg0 command line args
*/
public UserManagerTest(String arg0) {
super(arg0);
}
/**
* DOCUMENT ME!
*
* @param args DOCUMENT ME!
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
junit.textui.TestRunner.run(UserManagerTest.class);
}
/**
* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
*/
final public void testInstance() throws AccessControlException {
File configDir = getAccreditablesDirectory();
FileUserManager manager = FileUserManager.instance(configDir);
assertNotNull(manager);
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
*/
final public void testLoadConfig() throws AccessControlException {
File configDir = getAccreditablesDirectory();
String userName = "alice";
String editorGroupId = "editorGroup";
String adminGroupId = "adminGroup";
String editorRoleId = "editorRole";
String adminRoleId = "adminRole";
FileRole editorRole = new FileRole(configDir, editorRoleId);
FileRole adminRole = new FileRole(configDir, adminRoleId);
User user =
new FileUser(configDir, userName, "Alice in Wonderland", "alice@test.com", "secret");
editorRole.save();
adminRole.save();
Group editorGroup = new FileGroup(configDir, editorGroupId);
// editorGroup.addRole(editorRole);
editorGroup.add(user);
FileGroup adminGroup = new FileGroup(configDir, adminGroupId);
// adminGroup.addRole(editorRole);
// adminGroup.addRole(adminRole);
editorGroup.save();
adminGroup.save();
adminGroup.add(user);
user.save();
FileUserManager userManager = null;
FileGroupManager groupManager = null;
userManager = FileUserManager.instance(configDir);
assertNotNull(userManager);
groupManager = FileGroupManager.instance(configDir);
assertNotNull(groupManager);
Group fetchedGroup = groupManager.getGroup(editorGroupId);
assertTrue(editorGroup.equals(fetchedGroup));
fetchedGroup = groupManager.getGroup(adminGroupId);
assertTrue(adminGroup.equals(fetchedGroup));
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
*/
final public void testGetUser() throws AccessControlException {
File configDir = getAccreditablesDirectory();
FileUserManager manager = null;
String userName = "testuser";
FileUser user =
new FileUser(
configDir,
userName,
"Alice in Wonderland",
"alice@wonderland.com",
"secret");
manager = FileUserManager.instance(configDir);
assertNotNull(manager);
manager.add(user);
User otherUser = manager.getUser(userName);
assertEquals(user, otherUser);
assertEquals(user.getDescription(), otherUser.getDescription());
assertEquals(user.getEmail(), otherUser.getEmail());
assertEquals(user.getEncryptedPassword(), ((AbstractUser) otherUser).getEncryptedPassword());
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/AccreditableManagerTest.java
Index: AccreditableManagerTest.java
===================================================================
/**
* @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
*/
package org.apache.lenya.ac.impl;
import junit.textui.TestRunner;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccreditableManager;
import org.apache.lenya.cms.ExcaliburTest;
import org.apache.lenya.cms.PublicationHelper;
/**
* @author andreas
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class AccreditableManagerTest extends ExcaliburTest {
/**
* @param test The test to execute.
*/
public AccreditableManagerTest(String test) {
super(test);
}
/**
* The main program.
* The parameters are set from the command line arguments.
*
* @param args The command line arguments.
*/
public static void main(String[] args) {
args = PublicationHelper.extractPublicationArguments(args);
TestRunner.run(AccreditableManagerTest.class);
}
private AccreditableManager accreditableManager;
private ComponentSelector selector;
protected static final String HINT = "file";
/**
* The JUnit setup method. Lookup the resolver role.
*
* @exception Exception Description of Exception
* @since
*/
public void setUp() throws Exception {
super.setUp();
String role = AccreditableManager.ROLE + "Selector";
selector = (ComponentSelector) manager.lookup(role);
accreditableManager = (AccreditableManager) selector.select(HINT);
assertNotNull("AccreditableManager is null", accreditableManager);
}
/**
* The test.
* @throws AccessControlException when something went wrong.
*/
public void testAccreditableManager() throws AccessControlException {
assertNotNull(accreditableManager.getUserManager());
assertNotNull(accreditableManager.getGroupManager());
assertNotNull(accreditableManager.getRoleManager());
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/PolicyTest.java
Index: PolicyTest.java
===================================================================
/*
$Id
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import junit.textui.TestRunner;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Policy;
import org.apache.lenya.ac.Role;
import org.apache.lenya.cms.PublicationHelper;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* @author andreas
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class PolicyTest extends AccessControlTest {
/**
* Executes this test.
* @param test The test.
*/
public PolicyTest(String test) {
super(test);
}
/**
* The main method.
* @param args The command-line arguments.
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
TestRunner.run(PolicyTest.class);
}
protected static final String URL = "/test/authoring/index.html";
protected static final String SAVE_URL = "/test/authoring/tutorial.html";
/**
* A test.
* @throws AccessControlException when something went wrong.
*/
public void testLoadPolicy() throws AccessControlException {
String url = "/" + PublicationHelper.getPublication().getId() + URL;
Policy policy = getPolicy(url);
Role[] roles = policy.getRoles(getIdentity());
System.out.print("Roles: ");
for (int i = 0; i < roles.length; i++) {
System.out.print(roles[i]);
}
System.out.println();
}
/**
* Returns the policy for a URL.
* @param url The URL.
* @return The policy.
* @throws AccessControlException when something went wrong.
*/
protected Policy getPolicy(String url) throws AccessControlException {
Policy policy =
getPolicyManager().getPolicy(getAccessController().getAccreditableManager(), url);
return policy;
}
/**
* A test.
* @throws AccessControlException when something went wrong.
*/
public void testSavePolicy() throws AccessControlException {
DefaultPolicy urlPolicy =
getPolicyManager().buildURLPolicy(getAccessController().getAccreditableManager(), URL);
DefaultPolicy newPolicy = new DefaultPolicy();
Credential[] credentials = urlPolicy.getCredentials();
for (int i = 0; i < credentials.length; i++) {
Credential credential = new Credential(credentials[i].getAccreditable());
Role[] roles = credentials[i].getRoles();
for (int j = 0; j < roles.length; j++) {
credential.addRole(roles[j]);
}
newPolicy.addCredential(credential);
}
assertEquals(urlPolicy.getCredentials().length, newPolicy.getCredentials().length);
getPolicyManager().saveURLPolicy(SAVE_URL, newPolicy);
newPolicy =
getPolicyManager().buildURLPolicy(
getAccessController().getAccreditableManager(),
SAVE_URL);
assertEquals(urlPolicy.getCredentials().length, newPolicy.getCredentials().length);
Credential[] newCredentials = newPolicy.getCredentials();
for (int i = 0; i < credentials.length; i++) {
Credential credential = new Credential(credentials[i].getAccreditable());
Credential newCredential = null;
for (int k = 0; k < newCredentials.length; k++) {
if (newCredentials[k].getAccreditable().equals(credential.getAccreditable())) {
newCredential = newCredentials[k];
}
}
System.out.println("Accreditable: [" + credential.getAccreditable() + "]");
assertNotNull(newCredential);
Set oldRoles = new HashSet(Arrays.asList(credential.getRoles()));
Set newRoles = new HashSet(Arrays.asList(newCredential.getRoles()));
assertEquals(oldRoles, newRoles);
/*
for (int j = 0; j < roles.length; j++) {
assertEquals(roles[j], newRoles[j]);
System.out.println(" Role: [" + roles[j] + "]");
}
*/
}
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/LDAPUserTest.java
Index: LDAPUserTest.java
===================================================================
/*
$Id
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.file.FileGroup;
import org.apache.lenya.ac.file.FileRole;
import org.apache.lenya.ac.file.FileUserManager;
import org.apache.lenya.ac.ldap.LDAPUser;
import org.apache.lenya.cms.PublicationHelper;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.PublicationFactory;
import java.io.File;
/**
* @author egli
*
*
*/
public class LDAPUserTest extends AccessControlTest {
/**
* Constructor for LDAPUserTest.
* @param arg0 a <code>String</code>
*/
public LDAPUserTest(String arg0) {
super(arg0);
}
/**
*
* @param args an array of <code>String</code>
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
junit.textui.TestRunner.run(LDAPUserTest.class);
}
/**
* @see TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}
/**
* @see TestCase#tearDown()
*/
public void tearDown() throws Exception {
super.tearDown();
}
/**
* get a publication
*
* @return a <code>Publication</code>
*
* @throws PublicationException if an error occurs
*/
final public Publication getPublication() throws PublicationException {
String publicationId = "default";
String servletContextPath =
"/home/egli/build/jakarta-tomcat-4.1.21-LE-jdk14/webapps/lenya/";
return PublicationFactory.getPublication(
publicationId,
servletContextPath);
}
/**
* Create and save an ldap user
*
* @param userName name of the user
* @param email of the user
* @param ldapId ldap id of the user
* @throws AccessControlException if the creating or the saving fails
* @throws ConfigurationException if the creating or the saving fails
*/
final public void createAndSaveUser(
String userName,
String email,
String ldapId)
throws AccessControlException, ConfigurationException {
String editorGroupName = "editorGroup";
String adminGroupName = "adminGroup";
String editorRoleName = "editorRole";
String adminRoleName = "adminRole";
File configDir = getAccreditablesDirectory();
FileRole editorRole = new FileRole();
editorRole.setName(editorRoleName);
editorRole.setConfigurationDirectory(configDir);
FileRole adminRole = new FileRole();
adminRole.setName(adminRoleName);
adminRole.setConfigurationDirectory(configDir);
FileGroup editorGroup = new FileGroup(configDir, editorGroupName);
FileGroup adminGroup = new FileGroup(configDir, adminGroupName);
LDAPUser user = new LDAPUser(configDir, userName, email, ldapId);
editorRole.save();
adminRole.save();
/*
editorGroup.addRole(editorRole);
user.addGroup(editorGroup);
adminGroup.addRole(editorRole);
adminGroup.addRole(adminRole);
*/
editorGroup.save();
adminGroup.save();
adminGroup.add(user);
user.save();
}
/**
* Test loading an LDAPUser
*
* @param userName the name of the user
* @return an <code>LDAPUser</code>
* @throws AccessControlException of the loading fails
*/
final public LDAPUser loadUser(String userName)
throws AccessControlException {
FileUserManager manager = FileUserManager.instance(getAccreditablesDirectory());
return (LDAPUser)manager.getUser(userName);
}
// final public void testGetFullName() throws AccessControlException {
// String userName = "felix";
// createAndSaveUser(userName, "felix@wyona.com", "m400032");
// LDAPUser user = null;
// user = loadUser(userName);
// assertNotNull(user);
// String fullName = user.getFullName();
// assertTrue(fullName.equals(" Felix Maeder - Wayona"));
// }
/**
* Test the setter of the full name
*/
final public void testSetFullName() {
// the setFullName method is supposed to do nothing
}
// final public void testAuthenticate() throws AccessControlException {
// String userName = "felix";
// createAndSaveUser(userName, "felix@wyona.com", "m400032");
// User user = null;
// user = loadUser(userName);
// assertNotNull(user);
// assertTrue(user.authenticate("sekret"));
// }
/**
* Test the ldap id getter
*
* @throws AccessControlException if the test fails
* @throws ConfigurationException if the creating or the saving fails
*/
final public void testGetLdapId()
throws ConfigurationException, AccessControlException {
String userName = "felix";
String ldapId = "m400032";
createAndSaveUser(userName, "felix@wyona.com", ldapId);
LDAPUser user = null;
user = loadUser(userName);
assertNotNull(user);
assertEquals(ldapId, user.getLdapId());
}
/**
* Test settinf the ldap id
*
* @throws AccessControlException if the test fails
* @throws ConfigurationException if the creating or the saving fails
*/
final public void testSetLdapId()
throws ConfigurationException, AccessControlException {
String userName = "felix";
String newLdapId = "foo";
createAndSaveUser(userName, "felix@wyona.com", "bar");
LDAPUser user = null;
user = loadUser(userName);
assertNotNull(user);
user.setLdapId(newLdapId);
user.save();
user = null;
user = loadUser(userName);
assertNotNull(user);
assertEquals(newLdapId, user.getLdapId());
}
/**
* Test save
*
* @throws AccessControlException if the test fails
* @throws ConfigurationException if the creating or the saving fails
*/
final public void testSave()
throws ConfigurationException, AccessControlException {
String userName = "felix";
createAndSaveUser(userName, "felix@wyona.com", "m400032");
User user = null;
user = loadUser(userName);
assertNotNull(user);
}
/**
* Test the deletion of a ldap user
*
*/
final public void testDelete() {
//TODO Implement delete().
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/IdentityTestCase.xtest
Index: IdentityTestCase.xtest
===================================================================
<?xml version="1.0" ?>
<!DOCTYPE testcase [
<!ELEMENT testcase (annotation?,logkit,context?,roles,components)>
<!-- annotation describes the testcase
-->
<!ELEMENT annotation (#PCDATA)>
<!-- logkit define the logkit in use
-->
<!ELEMENT logkit (factories, targets, categories)>
<!ELEMENT factories (factory+)>
<!ELEMENT factory EMPTY>
<!ATTLIST factory
type CDATA #REQUIRED
class CDATA #REQUIRED
>
<!ELEMENT targets ANY>
<!ELEMENT file ANY>
<!ATTLIST file
id ID #REQUIRED>
<!ELEMENT filename (#PCDATA)>
<!ELEMENT format (#PCDATA)>
<!ATTLIST format
type (extended|raw) "extended"
>
<!ELEMENT categories (category+)>
<!ELEMENT category ANY>
<!ATTLIST category
name CDATA #REQUIRED
log-level (DEBUG|INFO|WARN|ERROR) "INFO"
>
<!ELEMENT log-target EMPTY>
<!ATTLIST log-target
id-ref CDATA #REQUIRED
>
<!-- the context used by the components
-->
<!ELEMENT context (entry*)>
<!ELEMENT entry EMPTY>
<!ATTLIST entry
name CDATA #REQUIRED
value CDATA #REQUIRED
>
<!-- the roles of the components
-->
<!ELEMENT roles (role+)>
<!ELEMENT role (hint*)>
<!ATTLIST role
name CDATA #IMPLIED
class CDATA #IMPLIED
shorthand CDATA #REQUIRED
default-class CDATA #REQUIRED
>
<!ELEMENT hint EMPTY>
<!ATTLIST hint
shorthand CDATA #REQUIRED
class CDATA #REQUIRED
>
<!-- define components element, attributes, and its children
-->
<!ELEMENT components (resolver)>
<!ATTLIST components
logger CDATA #IMPLIED
>
<!ELEMENT resolver (parameter*)>
<!ATTLIST resolver
logger CDATA #IMPLIED
>
<!ELEMENT parameter EMPTY>
<!ATTLIST parameter
name CDATA #REQUIRED
value CDATA #REQUIRED
>
]>
<testcase>
<annotation>
Test Cases: Identity
</annotation>
<logkit>
<factories>
<factory type="file" class="org.apache.avalon.excalibur.logger.factory.FileTargetFactory"/>
</factories>
<targets>
<file id="root">
<filename>resolver-test.log</filename>
<format type="extended">
%7.7{priority} %5.5{time} [%8.8{category}] (%{context}): %{message}\n%{throwable}
</format>
</file>
</targets>
<categories>
<category name="test" log-level="DEBUG">
<log-target id-ref="root"/>
</category>
</categories>
</logkit>
<context>
<entry name="foo" value="bar"/>
</context>
<roles>
<role name="org.apache.excalibur.xml.EntityResolver"
shorthand="entity-resolver"
default-class="org.apache.lenya.cms.ac.Identity">
</role>
</roles>
<!--
-->
<components>
<entity-resolver>
<parameter name="verbosity" value="10"/>
<parameter name="catalog" value="/catalog"/>
</entity-resolver>
</components>
</testcase>
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/RoleManagerTest.java
Index: RoleManagerTest.java
===================================================================
/*
$Id: RoleManagerTest.java,v 1.1 2003/11/13 16:13:29 andreas Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Role;
import org.apache.lenya.ac.file.FileRole;
import org.apache.lenya.ac.file.FileRoleManager;
import org.apache.lenya.cms.PublicationHelper;
import java.io.File;
/**
* @author egli
*
*
*/
public class RoleManagerTest extends AccessControlTest {
/**
* Constructor for RoleManagerTest.
* @param arg0 command line args
*/
public RoleManagerTest(String arg0) {
super(arg0);
}
/**
* DOCUMENT ME!
*
* @param args DOCUMENT ME!
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
junit.textui.TestRunner.run(RoleManagerTest.class);
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
*/
final public void testInstance() throws AccessControlException {
File configDir = getAccreditablesDirectory();
FileRoleManager manager = FileRoleManager.instance(configDir);
assertNotNull(manager);
FileRoleManager anotherManager = FileRoleManager.instance(configDir);
assertNotNull(anotherManager);
assertEquals(manager, anotherManager);
}
/**
* DOCUMENT ME!
*/
final public void testGetRoles() {
}
/**
* Test add(Role)
*
* @throws AccessControlException if an error occurs
*/
final public void testAddRole() throws AccessControlException {
File configDir = getAccreditablesDirectory();
String name = "test";
FileRoleManager manager = null;
manager = FileRoleManager.instance(configDir);
assertNotNull(manager);
Role role = new FileRole(manager.getConfigurationDirectory(), name);
manager.add(role);
assertTrue(manager.getRoles().length > 0);
}
/**
* Test for void remove(Role)
*
*/
final public void testRemoveRole() throws AccessControlException {
File configDir = getAccreditablesDirectory();
String name = "test2";
Role role = new FileRole(configDir, name);
FileRoleManager manager = null;
try {
manager = FileRoleManager.instance(configDir);
} catch (AccessControlException e) {
e.printStackTrace();
}
assertNotNull(manager);
Role[] roles = manager.getRoles();
int roleCountBefore = roles.length;
manager.add(role);
manager.remove(role);
roles = manager.getRoles();
int roleCountAfter = roles.length;
assertEquals(roleCountBefore, roleCountAfter);
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/AccessControlTest.java
Index: AccessControlTest.java
===================================================================
/*
$Id
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import java.io.File;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.AccessControllerResolver;
import org.apache.lenya.ac.AccreditableManager;
import org.apache.lenya.ac.Identity;
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.ExcaliburTest;
import org.apache.lenya.cms.PublicationHelper;
import org.apache.lenya.cms.ac.PublicationAccessControllerResolver;
import org.apache.lenya.ac.file.FileAccreditableManager;
import org.apache.lenya.ac.file.FilePolicyManager;
/**
* @author andreas
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class AccessControlTest extends ExcaliburTest {
private ComponentSelector accessControllerResolverSelector;
private AccessControllerResolver accessControllerResolver;
private DefaultAccessController accessController;
private File accreditablesDirectory;
/**
* @param test The test.
*/
public AccessControlTest(String test) {
super(test);
}
/**
* Returns the access controller.
* @return An access controller.
*/
public DefaultAccessController getAccessController() {
return accessController;
}
protected static final String URL = "/test/authoring/index.html";
/** @see junit.framework.TestCase#setUp() */
protected void setUp() throws Exception {
if (PublicationHelper.getPublication() == null) {
String[] args = { "D:\\Development\\build\\tomcat-4.1.24\\webapps\\lenya", "test" };
PublicationHelper.extractPublicationArguments(args);
}
super.setUp();
accessControllerResolverSelector =
(ComponentSelector) manager.lookup(AccessControllerResolver.ROLE + "Selector");
assertNotNull(accessControllerResolverSelector);
accessControllerResolver =
(AccessControllerResolver) accessControllerResolverSelector.select(
AccessControllerResolver.DEFAULT_RESOLVER);
assertNotNull(accessControllerResolver);
getLogger().info(
"Using access controller resolver: [" + accessControllerResolver.getClass() + "]");
accessController =
(DefaultAccessController)
(
(
PublicationAccessControllerResolver) accessControllerResolver)
.resolveAccessController(
URL);
assertNotNull(accessController);
getLogger().info("Resolved access controller: [" + accessController.getClass() + "]");
File servletContext = PublicationHelper.getPublication().getServletContext();
((FilePolicyManager) accessController.getPolicyManager()).setPoliciesDirectory(
servletContext);
accreditablesDirectory =
new File(
PublicationHelper.getPublication().getDirectory(),
"config/ac/passwd".replace('/', File.separatorChar));
(
(FileAccreditableManager) accessController
.getAccreditableManager())
.setConfigurationDirectory(
accreditablesDirectory);
}
/**
* The teardown method for JUnit
*
* @exception Exception Description of Exception
* @since
*/
public void tearDown() throws Exception {
super.tearDown();
if (accessControllerResolverSelector != null) {
if (accessControllerResolver != null) {
if (accessController != null) {
accessControllerResolver.release(accessController);
}
accessControllerResolverSelector.release(accessControllerResolver);
}
manager.release(accessControllerResolver);
}
}
protected static final String USERNAME = "lenya";
/**
* Returns the identity.
* @return The identity.
* @throws AccessControlException when something went wrong.
*/
protected Identity getIdentity() throws AccessControlException {
DefaultAccessController controller = getAccessController();
User user = controller.getAccreditableManager().getUserManager().getUser(USERNAME);
assertNotNull(user);
Identity identity = new Identity();
identity.addIdentifiable(user);
return identity;
}
/**
* Returns the policy manager.
* @return A policy manager.
*/
protected FilePolicyManager getPolicyManager() {
return (FilePolicyManager) getAccessController().getPolicyManager();
}
/**
* Returns the accreditable manager.
* @return An accreditable manager.
*/
protected AccreditableManager getAccreditableManager() {
return getAccessController().getAccreditableManager();
}
/**
* Returns the directories where accreditables are stored.
* @return A file.
*/
protected File getAccreditablesDirectory() {
return accreditablesDirectory;
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/IdentityTest.java
Index: IdentityTest.java
===================================================================
/**
* @author <a href="mailto:andreas@apache.org">Andreas Hartmann</a>
*/
package org.apache.lenya.ac.impl;
import junit.textui.TestRunner;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Identity;
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.PublicationHelper;
/**
* @author andreas
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class IdentityTest extends AccessControlTest {
/**
* Ctor.
* @param test The test.
*/
public IdentityTest(String test) {
super(test);
}
/**
* The main method.
* @param args The command-line arguments.
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
TestRunner.run(IdentityTest.class);
}
public static final String USER_ID = "lenya";
/**
* Tests the identity.
*
* @throws AccessControlException if an error occurs
*/
public void testIdentity() throws AccessControlException {
Identity identity = new Identity();
User user = getAccessController().getAccreditableManager().getUserManager().getUser(USER_ID);
System.out.println("Adding user to identity: [" + user + "]");
identity.addIdentifiable(user);
assertSame(user, identity.getUser());
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/impl/AccessControllerTest.java
Index: AccessControllerTest.java
===================================================================
/*
$Id
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.impl;
import junit.textui.TestRunner;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.cms.PublicationHelper;
/**
* @author andreas
*
*/
public class AccessControllerTest extends AccessControlTest {
/**
* @param test A test.
*/
public AccessControllerTest(String test) {
super(test);
}
/**
* The main method.
* @param args The command-line arguments.
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
TestRunner.run(AccessControllerTest.class);
}
/**
* The test.
* @throws AccessControlException when something went wrong.
*/
public void testAccessController() throws AccessControlException {
assertNotNull(getAccessController());
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/file/FileUserTest.java
Index: FileUserTest.java
===================================================================
/*
$Id: FileUserTest.java,v 1.1 2003/11/13 16:13:30 andreas Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.file;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Group;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.file.FileGroup;
import org.apache.lenya.ac.file.FileUser;
import org.apache.lenya.ac.file.FileUserManager;
import org.apache.lenya.ac.impl.AccessControlTest;
import org.apache.lenya.cms.PublicationHelper;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* @author egli
*
*
*/
public class FileUserTest extends AccessControlTest {
private HashMap groups = new HashMap();
/**
* Constructor for FileUserTest.
* @param arg0 command line args
*/
public FileUserTest(String arg0) {
super(arg0);
}
/**
* DOCUMENT ME!
*
* @param args DOCUMENT ME!
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
junit.textui.TestRunner.run(FileUserTest.class);
}
/**
* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
final public Map getGroups() {
return groups;
}
/**
* Create and save a user
*
* @param userName DOCUMENT ME!
* @param fullName DOCUMENT ME!
* @param email DOCUMENT ME!
* @param password DOCUMENT ME!
*
* @return a <code>FileUser</code>
*
* @throws AccessControlException if an error occurs
*/
final public FileUser createAndSaveUser(String userName, String fullName, String email,
String password) throws AccessControlException {
File configDir = getAccreditablesDirectory();
String editorGroupName = "editorGroup";
String adminGroupName = "adminGroup";
FileGroup editorGroup = new FileGroup(configDir, editorGroupName);
FileGroup adminGroup = new FileGroup(configDir, adminGroupName);
this.groups.put(editorGroupName, editorGroup);
this.groups.put(adminGroupName, adminGroup);
FileUser user = new FileUser(configDir, userName, fullName, email, password);
editorGroup.add(user);
adminGroup.add(user);
editorGroup.save();
adminGroup.save();
user.save();
FileUserManager manager = FileUserManager.instance(configDir);
manager.add(user);
return user;
}
/**
* Load a user.
*
* @param userName the name of the user
*
* @return a <code>FileUser</code>
*
* @throws AccessControlException if an error occurs
*/
final public FileUser loadUser(String userName) throws AccessControlException {
File configDir = getAccreditablesDirectory();
FileUserManager manager = FileUserManager.instance(configDir);
return (FileUser) manager.getUser(userName);
}
/**
* Test save
*
* @throws AccessControlException if an error occurs
*/
final public void testSave() throws AccessControlException {
String userName = "alice";
createAndSaveUser(userName, "Alice Wonderland", "alice@wonderland.org", "secret");
File configDir = getAccreditablesDirectory();
File xmlFile = new File(configDir, userName + ".iml");
assertTrue(xmlFile.exists());
}
/**
* Test getEmail
*
* @throws AccessControlException if an error occurs
*/
final public void testGetEmail() throws AccessControlException {
String userID = "alice";
String email = "alice@wonderland.org";
User user = createAndSaveUser(userID, "Alice Wonderland", email, "secret");
assertTrue(user.getEmail().equals(email));
user = loadUser(userID);
assertTrue(user.getEmail().equals(email));
}
/**
* Test getFullName
*
* @throws AccessControlException if an error occurs
*/
final public void testGetFullName() throws AccessControlException {
String userID = "alice";
String userName = "Alice Wonderland";
FileUser user = createAndSaveUser(userID, userName, "alice@wonderland.org", "secret");
assertTrue(user.getName().equals(userName));
user = loadUser(userID);
assertTrue(user.getName().equals(userName));
}
/**
* Test getGroups
*
* @throws AccessControlException if an error occurs
*/
final public void testGetGroups() throws AccessControlException {
FileUser user = createAndSaveUser("alice", "Alice Wonderland", "alice@wonderland.org",
"secret");
for (Iterator i = getGroups().values().iterator(); i.hasNext(); ) {
Group group = (Group) i.next();
assertTrue(group.contains(user));
}
}
/**
* Test getId
*
* @throws AccessControlException if an error occurs
*/
final public void testGetId() throws AccessControlException {
String id = "alice";
FileUser user = createAndSaveUser(id, "Alice Wonderland", "alice@wonderland.org", "secret");
assertTrue(user.getId().equals(id));
}
/**
* Test delete
*
* @throws AccessControlException if an error occurs
*/
final public void testDelete() throws AccessControlException {
String id = "albert";
FileUser user = createAndSaveUser(id, "Albert Einstein", "albert@physics.org", "secret");
File configDir = getAccreditablesDirectory();
FileUserManager manager = null;
manager = FileUserManager.instance(configDir);
assertNotNull(manager);
assertNotNull(manager.getUser(id));
user.delete();
manager.remove(user);
assertNull(manager.getUser(id));
}
/**
* Test authenticate
*
* @throws AccessControlException if an error occurs
*/
final public void testAuthenticate() throws AccessControlException {
String password = "daisy";
FileUser user = createAndSaveUser("mickey", "Mickey Mouse", "mickey@mouse.com", password);
assertTrue(user.authenticate(password));
File configDir = getAccreditablesDirectory();
FileUserManager manager = null;
manager = FileUserManager.instance(configDir);
assertNotNull(manager);
User lenya = manager.getUser("lenya");
assertNotNull(lenya);
assertTrue(lenya.authenticate("levi"));
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/file/FileGroupTest.java
Index: FileGroupTest.java
===================================================================
/*
$Id
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.file;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Group;
import org.apache.lenya.ac.Groupable;
import org.apache.lenya.ac.file.FileGroup;
import org.apache.lenya.ac.file.FileGroupManager;
import org.apache.lenya.ac.impl.AccessControlTest;
import org.apache.lenya.cms.PublicationHelper;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
/**
* @author egli
*
*
*/
public class FileGroupTest extends AccessControlTest {
/**
* Constructor for FileGroupTest.
* @param arg0 command line args
*/
public FileGroupTest(String arg0) {
super(arg0);
}
/**
* DOCUMENT ME!
*
* @param args DOCUMENT ME!
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
junit.textui.TestRunner.run(FileGroupTest.class);
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
* @throws ConfigurationException DOCUMENT ME!
* @throws SAXException DOCUMENT ME!
* @throws IOException DOCUMENT ME!
*/
final public void testFileGroup()
throws AccessControlException, ConfigurationException, SAXException, IOException {
FileGroup group = getGroup();
group.save();
File groupFile = new File(getAccreditablesDirectory(), GROUP_ID + FileGroupManager.SUFFIX);
assertNotNull(groupFile);
assertTrue(groupFile.exists());
Configuration config = null;
config = new DefaultConfigurationBuilder().buildFromFile(groupFile);
assertNotNull(config);
FileGroup newGroup = null;
newGroup = new FileGroup();
newGroup.setConfigurationDirectory(getAccreditablesDirectory());
newGroup.configure(config);
assertNotNull(newGroup);
assertTrue(newGroup.getId().equals(GROUP_ID));
}
public static final String GROUP_ID = "testGroup";
/**
* Test getGroup
*
* @return a <code>FileGroup</code>
*/
protected FileGroup getGroup() {
File configurationDirectory = getAccreditablesDirectory();
System.out.println("Configuration directory: " + configurationDirectory);
FileGroup group = new FileGroup(configurationDirectory, GROUP_ID);
return group;
}
/**
* Tests the removeAllMembers() method.
*/
public void testRemoveAllMembers() {
Group group = getGroup();
Groupable members[] = group.getMembers();
group.removeAllMembers();
for (int i = 0; i < members.length; i++) {
assertFalse(group.contains(members[i]));
}
}
}
1.1 cocoon-lenya/src/test/org/apache/lenya/ac/file/FileRoleTest.java
Index: FileRoleTest.java
===================================================================
/*
$Id: FileRoleTest.java,v 1.1 2003/11/13 16:13:30 andreas Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.ac.file;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.file.FileRole;
import org.apache.lenya.ac.file.FileRoleManager;
import org.apache.lenya.ac.impl.AccessControlTest;
import org.apache.lenya.cms.PublicationHelper;
import java.io.File;
/**
* @author egli
*
*
*/
public class FileRoleTest extends AccessControlTest {
/**
* Constructor for FileRoleTest.
* @param arg0 The test to execute.
*/
public FileRoleTest(String arg0) {
super(arg0);
}
/**
* DOCUMENT ME!
*
* @param args DOCUMENT ME!
*/
public static void main(String[] args) {
PublicationHelper.extractPublicationArguments(args);
junit.textui.TestRunner.run(FileRoleTest.class);
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
*/
final public void testFileRole() throws AccessControlException {
String name = "test";
File configDir = getAccreditablesDirectory();
FileRole role = new FileRole(configDir, name);
role.save();
File path = null;
path = FileRoleManager.instance(configDir).getConfigurationDirectory();
File roleFile = new File(path, name + FileRoleManager.SUFFIX);
assertNotNull(roleFile);
assertTrue(roleFile.exists());
}
/**
* DOCUMENT ME!
*
* @throws AccessControlException DOCUMENT ME!
*/
final public void testSave() throws AccessControlException {
File configDir = getAccreditablesDirectory();
String name = "test";
FileRole role = new FileRole(configDir, name);
role.save();
File path = null;
path = FileRoleManager.instance(configDir).getConfigurationDirectory();
File roleFile = new File(path, name + FileRoleManager.SUFFIX);
assertNotNull(roleFile);
assertTrue(roleFile.exists());
}
/**
* DOCUMENT ME!
*/
final public void testGetId() {
String id = "test";
File configDir = getAccreditablesDirectory();
FileRole role = new FileRole(configDir, id);
assertTrue(role.getId().equals(id));
}
/**
* Test for boolean equals(Object)
*/
final public void testEqualsObject() {
String name = "test";
File configDir = getAccreditablesDirectory();
FileRole role1 = new FileRole(configDir, name);
FileRole role2 = new FileRole(configDir, name);
assertEquals(role1, role2);
}
}
1.21 +12 -11 cocoon-lenya/src/test/org/apache/lenya/cms/workflow/WorkflowTest.java
Index: WorkflowTest.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/test/org/apache/lenya/cms/workflow/WorkflowTest.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- WorkflowTest.java 21 Oct 2003 16:35:18 -0000 1.20
+++ WorkflowTest.java 13 Nov 2003 16:13:30 -0000 1.21
@@ -60,14 +60,14 @@
import junit.textui.TestRunner;
+import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.Policy;
+import org.apache.lenya.ac.Role;
+import org.apache.lenya.ac.User;
+import org.apache.lenya.ac.file.FileItemManager;
+import org.apache.lenya.ac.impl.AccessControlTest;
import org.apache.lenya.cms.PublicationHelper;
-import org.apache.lenya.cms.ac.AccessControlException;
-import org.apache.lenya.cms.ac.ItemManager;
-import org.apache.lenya.cms.ac.Role;
-import org.apache.lenya.cms.ac.User;
-import org.apache.lenya.cms.ac2.AccessControlTest;
-import org.apache.lenya.cms.ac2.Identity;
-import org.apache.lenya.cms.ac2.Policy;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentType;
@@ -138,19 +138,20 @@
String url = "/" + publication.getId() + URL;
Document document = publication.getDocumentBuilder().buildDocument(publication, url);
- File configDir = new File(publication.getDirectory(), ItemManager.PATH);
+ File configDir = new File(publication.getDirectory(), FileItemManager.PATH);
assertTrue(configDir.exists());
Policy policy = getPolicyManager().getPolicy(getAccreditableManager(), url);
DocumentType type = DocumentTypeBuilder.buildDocumentType(documentTypeName, publication);
String workflowId = type.getWorkflowFileName();
-
+
WorkflowFactory factory = WorkflowFactory.newInstance();
- String[] emptyRoles = {};
+ String[] emptyRoles = {
+ };
Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");
-
+
WorkflowFactory.initHistory(document, workflowId, situation);
for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org