Author: tmortagne Date: 2008-02-15 15:17:23 +0100 (Fri, 15 Feb 2008) New Revision: 7753
Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/pom.xml xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/AllTests.java xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/LDAPAuthTest.java xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPConnectionTest.java xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPUtilsTest.java xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/framework/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/framework/XWikiLDAPTestSetup.java xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/xwiki/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/xwiki/it/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/xwiki/it/framework/ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/xwiki/it/framework/init.ldif Modified: xwiki-products/xwiki-enterprise/trunk/distribution-test/pom.xml Log: XE-194: Add LDAP integration/functional tests * create the project with apacheds runner/stopper * add connection test on XWikiLDAPConnection * add some tests on XWikiLDAPUtils Property changes on: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests ___________________________________________________________________ Name: svn:ignore + target .classpath .project Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/pom.xml =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/pom.xml (rev 0) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/pom.xml 2008-02-15 14:17:23 UTC (rev 7753) @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + * + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + * +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>com.xpn.xwiki.products</groupId> + <artifactId>xwiki-enterprise-test</artifactId> + <version>1.3-SNAPSHOT</version> + </parent> + <artifactId>xwiki-enterprise-test-ldap</artifactId> + <name>XWiki Products - Enterprise - LDAP Functional Tests</name> + <packaging>pom</packaging> + <description>XWiki Products - Enterprise - LDAP Functional Tests</description> + <dependencies> + <dependency> + <groupId>com.xpn.xwiki.platform</groupId> + <artifactId>xwiki-core</artifactId> + <version>${platform.core.version}</version> + <scope>test</scope> + </dependency> + + <!-- Needed at test time. Some versions of Maven don't inherit provided dependencies. --> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> + <scope>test</scope> + </dependency> + + <!-- Dependencies for LDAP unit tests --> + <dependency> + <groupId>org.apache.directory.server</groupId> + <artifactId>apacheds-server-unit</artifactId> + <version>1.0.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.3</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <!-- Step 1: Compile the JUnit LDAP Tests and copy test resources files --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + </plugin> + <!-- Step 2: Create jar containing integration tests which will be installed --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <!-- Step 3: Unpack the application --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + <!-- Step 4: Start XWiki, Execute the tests and Stop XWiki --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <!-- Display report on screen when all tests are completed --> + <useFile>false</useFile> + <reportFormat>plain</reportFormat> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Property changes on: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/pom.xml ___________________________________________________________________ Name: svn:eol-style + native Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/AllTests.java =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/AllTests.java (rev 0) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/AllTests.java 2008-02-15 14:17:23 UTC (rev 7753) @@ -0,0 +1,70 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package com.xpn.xwiki.it; + +import com.xpn.xwiki.it.framework.XWikiLDAPTestSetup; +import com.xpn.xwiki.test.XWikiTestSetup; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * A class listing all the Functional tests to execute. We need such a class (rather than + * letting the JUnit Runner discover the different TestCases classes by itself) because we want to + * start/stop XWiki before and after the tests start (but only once). + * + * @version $Id: $ + */ +public class AllTests extends TestCase +{ + private static final String PATTERN = ".*" + System.getProperty("pattern", ""); + + public static Test suite() throws Exception + { + TestSuite suite = new TestSuite(); + + // TODO: I don't like listing tests here as it means we can add a new TestCase class and + // forget to add it here and the tests won't be run but we'll not know about it and we'll + // think the tests are all running fine. I haven't found a simple solution to this yet + // (there are complex solutions like searching for all tests by parsing the source tree). + // I think there are TestSuite that do this out there but I haven't looked for them yet. + + addTestCase(suite, LDAPAuthTest.class); + addTestCase(suite, XWikiLDAPUtilsTest.class); + addTestCase(suite, XWikiLDAPConnectionTest.class); + + return new XWikiLDAPTestSetup(suite); + } + + private static void addTestCase(TestSuite suite, Class testClass) throws Exception + { + if (testClass.getName().matches(PATTERN)) { + suite.addTest(new TestSuite(testClass)); + } + } + + private static void addTest(TestSuite suite, Test test, Class testClass) throws Exception + { + if (testClass.getName().matches(PATTERN)) { + suite.addTest(test); + } + } +} Property changes on: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/AllTests.java ___________________________________________________________________ Name: svn:eol-style + native Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/LDAPAuthTest.java =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/LDAPAuthTest.java (rev 0) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/LDAPAuthTest.java 2008-02-15 14:17:23 UTC (rev 7753) @@ -0,0 +1,27 @@ +package com.xpn.xwiki.it; + +import junit.framework.TestCase; + +public class LDAPAuthTest extends TestCase +{ + /** + * Initialize the server. + */ + public void setUp() throws Exception + { + + } + + public void test() + { + // + } + + /** + * Shutdown the server. + */ + public void tearDown() throws Exception + { + + } +} Property changes on: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/LDAPAuthTest.java ___________________________________________________________________ Name: svn:eol-style + native Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPConnectionTest.java =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPConnectionTest.java (rev 0) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPConnectionTest.java 2008-02-15 14:17:23 UTC (rev 7753) @@ -0,0 +1,42 @@ +package com.xpn.xwiki.it; + +import junit.framework.TestCase; + +import com.xpn.xwiki.it.framework.XWikiLDAPTestSetup; +import com.xpn.xwiki.plugin.ldap.XWikiLDAPConnection; + +/** + * Tests [EMAIL PROTECTED] XWikiLDAPConnectionTest}; + * + * @version $Id: $ + */ +public class XWikiLDAPConnectionTest extends TestCase +{ + /** + * Initialize the server. + */ + public void setUp() throws Exception + { + + } + + public void testOpenClose() + { + int port = XWikiLDAPTestSetup.getLDAPPort(); + + XWikiLDAPConnection connection = new XWikiLDAPConnection(); + + assertTrue("LDAP connection failed", connection.open("localhost", port, + "cn=Horatio Hornblower,ou=people,o=sevenSeas", "pass", null, false)); + + connection.close(); + } + + /** + * Shutdown the server. + */ + public void tearDown() throws Exception + { + super.tearDown(); + } +} Property changes on: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPConnectionTest.java ___________________________________________________________________ Name: svn:eol-style + native Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPUtilsTest.java =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPUtilsTest.java (rev 0) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPUtilsTest.java 2008-02-15 14:17:23 UTC (rev 7753) @@ -0,0 +1,123 @@ +package com.xpn.xwiki.it; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import junit.framework.TestCase; + +import com.xpn.xwiki.XWiki; +import com.xpn.xwiki.XWikiConfig; +import com.xpn.xwiki.XWikiContext; +import com.xpn.xwiki.XWikiException; +import com.xpn.xwiki.cache.api.XWikiCacheService; +import com.xpn.xwiki.cache.impl.OSCacheService; +import com.xpn.xwiki.it.framework.XWikiLDAPTestSetup; +import com.xpn.xwiki.plugin.ldap.XWikiLDAPConnection; +import com.xpn.xwiki.plugin.ldap.XWikiLDAPUtils; +import com.xpn.xwiki.web.XWikiEngineContext; + +/** + * Tests [EMAIL PROTECTED] XWikiLDAPUtilsTest}; + * + * @version $Id: $ + */ +public class XWikiLDAPUtilsTest extends TestCase +{ + private XWikiLDAPConnection connection = new XWikiLDAPConnection(); + + private XWikiLDAPUtils ldapUtils = new XWikiLDAPUtils(connection); + + private XWikiContext context; + + private static Set HMSLYDIA_MEMBERS = new HashSet(); + + static { + HMSLYDIA_MEMBERS.add("cn=Horatio Hornblower,ou=people,o=sevenSeas"); + HMSLYDIA_MEMBERS.add("cn=William Bush,ou=people,o=sevenSeas"); + HMSLYDIA_MEMBERS.add("cn=Thomas Quist,ou=people,o=sevenSeas"); + HMSLYDIA_MEMBERS.add("cn=Moultrie Crystal,ou=people,o=sevenSeas"); + } + + /** + * Initialize the server. + */ + public void setUp() throws Exception + { + this.context = new XWikiContext(); + + new XWiki(new XWikiConfig(), this.context) + { + private XWikiCacheService cacheService; + + public void initXWiki(XWikiConfig config, XWikiContext context, + XWikiEngineContext engine_context, boolean noupdate) throws XWikiException + { + context.setWiki(this); + setConfig(config); + } + + public XWikiCacheService getCacheService() + { + if (this.cacheService == null) { + cacheService = new OSCacheService(); + + cacheService.init(this); + } + + return cacheService; + } + }; + + this.ldapUtils.setUidAttributeName(XWikiLDAPTestSetup.LDAP_USERUID_FIELD); + + int port = XWikiLDAPTestSetup.getLDAPPort(); + + this.connection.open("localhost", port, + "cn=Horatio Hornblower,ou=people,o=sevenSeas", "pass", null, false); + } + + public void testGetUidAttributeName() + { + assertSame("Wrong uid attribute name", XWikiLDAPTestSetup.LDAP_USERUID_FIELD, + this.ldapUtils.getUidAttributeName()); + } + + public void testGetCache() throws XWikiException + { + assertTrue("Cache is recreated", + this.ldapUtils.getCache("cache_name", this.context) == this.ldapUtils.getCache( + "cache_name", this.context)); + } + + public void testGetGroupMembers() + { + List subGroups = new ArrayList(); + Map members = new HashMap(); + + assertTrue("Fail to get members", this.ldapUtils.getGroupMembers( + "cn=HMS Lydia,ou=crews,ou=groups,o=sevenSeas", members, subGroups, this.context)); + + assertFalse("No member was found", members.isEmpty()); + + assertTrue("Wrong members was found", HMSLYDIA_MEMBERS.equals(members.keySet())); + } + + public void testIsUserInGroup() + { + + } + + /** + * Shutdown the server. + */ + public void tearDown() throws Exception + { + this.connection.close(); + + super.tearDown(); + } +} Property changes on: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/XWikiLDAPUtilsTest.java ___________________________________________________________________ Name: svn:eol-style + native Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/framework/XWikiLDAPTestSetup.java =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/framework/XWikiLDAPTestSetup.java (rev 0) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/framework/XWikiLDAPTestSetup.java 2008-02-15 14:17:23 UTC (rev 7753) @@ -0,0 +1,211 @@ +package com.xpn.xwiki.it.framework; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; + +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; + +import org.apache.directory.server.core.configuration.MutablePartitionConfiguration; +import org.apache.directory.server.unit.AbstractServerTest; + +import junit.framework.Test; + +import com.xpn.xwiki.plugin.ldap.XWikiLDAPConnection; +import com.xpn.xwiki.test.XWikiTestSetup; + +/** + * JUnit TestSetup extension that starts/stops embedded LDAP server and modify xwiki.cfg file to use + * LDAP as authentication system. This class is meant to wrap a JUnit TestSuite. For example: + * + * <pre><code> + * public static Test suite() + * { + * // Create some TestSuite object here + * return new LDAPXWikiTestSetup(suite); + * } + * </code></pre> + * + * @version $Id: $ + */ +public class XWikiLDAPTestSetup extends XWikiTestSetup +{ + public static final String LDAP_USERUID_FIELD = "uid"; + + public static final String PROPNAME_LDAPPORT = "ldap_port"; + + public static final String EXECUTION_DIRECTORY = + System.getProperty("xwikiExecutionDirectory"); + + public static final String XWIKI_CFG_FILE = + EXECUTION_DIRECTORY + "/webapps/xwiki/WEB-INF/xwiki.cfg"; + + private LDAPRunner ldap = new LDAPRunner(); + + private Properties initialXWikiConf; + + private Properties currentXWikiConf; + + public static int getLDAPPort() + { + return Integer.parseInt(System.getProperty(PROPNAME_LDAPPORT)); + } + + public XWikiLDAPTestSetup(Test test) throws IOException + { + super(test); + + FileInputStream fis = new FileInputStream(XWIKI_CFG_FILE); + + // Read properties file. + this.initialXWikiConf = new Properties(); + this.initialXWikiConf.load(fis); + + // Read properties file. + this.currentXWikiConf = new Properties(); + this.currentXWikiConf.load(fis); + + fis.close(); + + this.currentXWikiConf.setProperty("xwiki.authentication.ldap", "1"); + this.currentXWikiConf.setProperty("xwiki.authentication.ldap.authclass", + "com.xpn.xwiki.user.impl.LDAP.LDAPAuthServiceImpl"); + this.currentXWikiConf.setProperty("xwiki.authentication.ldap.server", "localhost"); + // currentXWikiConf.setProperty("xwiki.authentication.ldap.check_level", "1"); + this.currentXWikiConf.setProperty("xwiki.authentication.ldap.base_DN", "o=sevenSeas"); + this.currentXWikiConf.setProperty("xwiki.authentication.ldap.bind_DN", + "cn={0},ou=people,o=sevenSeas"); + // currentXWikiConf.setProperty("xwiki.authentication.ldap.bind_pass", "{1}"); + this.currentXWikiConf.setProperty("xwiki.authentication.ldap.UID_attr", + LDAP_USERUID_FIELD); + this.currentXWikiConf + .setProperty("xwiki.authentication.ldap.fields_mapping", + "name=uid,last_name=sn,first_name=givenname,fullname=description,email=mail,ldap_dn=dn"); + this.currentXWikiConf.setProperty("xwiki.authentication.ldap.group_mapping_1", + "XWiki.XWikiAdminGroup=cn=HMS Lydia,ou=crews,ou=groups,o=sevenSeas"); + // ldap_groupcache_expiration + // ldap_user_group + // ldap_validate_password + // ldap_update_user + // ldap_trylocal + // ldap_mode_group_sync (create,always) + } + + /** + * [EMAIL PROTECTED] + * + * @see com.xpn.xwiki.test.XWikiTestSetup#setUp() + */ + protected void setUp() throws Exception + { + this.ldap.start(); + + System.setProperty(PROPNAME_LDAPPORT, "" + ldap.getPort()); + this.currentXWikiConf.setProperty("xwiki.authentication.ldap.port", "" + ldap.getPort()); + + FileOutputStream fos = new FileOutputStream(XWIKI_CFG_FILE); + this.currentXWikiConf.store(fos, null); + fos.close(); + + super.setUp(); + } + + /** + * [EMAIL PROTECTED] + * + * @see com.xpn.xwiki.test.XWikiTestSetup#tearDown() + */ + protected void tearDown() throws Exception + { + super.tearDown(); + + FileOutputStream fos = new FileOutputStream(XWIKI_CFG_FILE); + initialXWikiConf.store(fos, null); + fos.close(); + + this.ldap.stop(); + } +} + +class LDAPRunner extends AbstractServerTest +{ + /** + * Start the server. + */ + public void start() throws Exception + { + // Add partition 'sevenSeas' + MutablePartitionConfiguration pcfg = new MutablePartitionConfiguration(); + pcfg.setName("sevenSeas"); + pcfg.setSuffix("o=sevenseas"); + + // Create some indices + Set indexedAttrs = new HashSet(); + indexedAttrs.add("objectClass"); + indexedAttrs.add("o"); + pcfg.setIndexedAttributes(indexedAttrs); + + // Create a first entry associated to the partition + Attributes attrs = new BasicAttributes(true); + + // First, the objectClass attribute + Attribute attr = new BasicAttribute("objectClass"); + attr.add("top"); + attr.add("organization"); + attrs.put(attr); + + // The the 'Organization' attribute + attr = new BasicAttribute("o"); + attr.add("sevenseas"); + attrs.put(attr); + + // Associate this entry to the partition + pcfg.setContextEntry(attrs); + + // As we can create more than one partition, we must store + // each created partition in a Set before initialization + Set pcfgs = new HashSet(); + pcfgs.add(pcfg); + + configuration.setContextPartitionConfigurations(pcfgs); + + // Create a working directory + File workingDirectory = new File("server-work"); + configuration.setWorkingDirectory(workingDirectory); + + // Now, let's call the upper class which is responsible for the + // partitions creation + setUp(); + + // Load a demo ldif file + importLdif(this.getClass().getResourceAsStream("init.ldif")); + + XWikiLDAPConnection connection = new XWikiLDAPConnection(); + + connection.open("localhost", this.port, "cn=Horatio Hornblower,ou=people,o=sevenSeas", + "pass", null, false); + } + + /** + * Shutdown the server. + */ + public void stop() throws Exception + { + tearDown(); + } + + /** + * @return the port to connect to LDAP server. + */ + public int getPort() + { + return port; + } +} Property changes on: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/it/com/xpn/xwiki/it/framework/XWikiLDAPTestSetup.java ___________________________________________________________________ Name: svn:eol-style + native Added: xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/xwiki/it/framework/init.ldif =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/xwiki/it/framework/init.ldif (rev 0) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/ldap-tests/src/test/resources/com/xpn/xwiki/it/framework/init.ldif 2008-02-15 14:17:23 UTC (rev 7753) @@ -0,0 +1,216 @@ +# Sample LDIF data for the ApacheDS v1.0 Basic User's Guide +# +# Some sailors and their ships +# userpassword for all persons is "pass" +# +version: 1 + +dn: ou=people,o=sevenSeas +objectclass: organizationalUnit +objectclass: top +description: Contains entries which describe persons (seamen) +ou: people + +dn: ou=groups,o=sevenSeas +objectclass: organizationalUnit +objectclass: top +description: Contains entries which describe groups (crews, for instance) +ou: groups + +dn: ou=crews,ou=groups,o=sevenSeas +objectclass: organizationalUnit +objectclass: top +description: Contains entries which describe ship crews +ou: crews + +dn: ou=ranks,ou=groups,o=sevenSeas +objectclass: organizationalUnit +objectclass: top +description: Contains entries which describe naval ranks (e.g. captain) +ou: ranks + +# HMS Lydia Crew +# -------------- + +dn: cn=Horatio Hornblower,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: Horatio Hornblower +description: Capt. Horatio Hornblower, R.N +givenname: Horatio +sn: Hornblower +uid: hhornblo +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=William Bush,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: William Bush +description: Lt. William Bush +givenname: William +manager: cn=Horatio Hornblower,ou=people,o=sevenSeas +sn: Bush +uid: wbush +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=Thomas Quist,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: Thomas Quist +description: Seaman Quist +givenname: Thomas +manager: cn=Horatio Hornblower,ou=people,o=sevenSeas +sn: Quist +uid: tquist +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=Moultrie Crystal,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: Moultrie Crystal +description: Lt. Crystal +givenname: Moultrie +manager: cn=Horatio Hornblower,ou=people,o=sevenSeas +sn: Crystal +uid: mchrysta +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=HMS Lydia,ou=crews,ou=groups,o=sevenSeas +objectclass: groupOfUniqueNames +objectclass: top +cn: HMS Lydia +uniquemember: cn=Horatio Hornblower,ou=people,o=sevenSeas +uniquemember: cn=William Bush,ou=people,o=sevenSeas +uniquemember: cn=Thomas Quist,ou=people,o=sevenSeas +uniquemember: cn=Moultrie Crystal,ou=people,o=sevenSeas + +# HMS Victory Crew +# ---------------- + +dn: cn=Horatio Nelson,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: Horatio Nelson +description: Lord Horatio Nelson +givenname: Horatio +sn: Nelson +uid: hnelson +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=Thomas Masterman Hardy,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: Thomas Masterman Hardy +description: Sir Thomas Masterman Hardy +givenname: Thomas +manager: cn=Horatio Nelson,ou=people,o=sevenSeas +sn: Hardy +uid: thardy +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=Cornelius Buckley,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: Cornelius Buckley +description: LM Cornelius Buckley +givenname: Cornelius +manager: cn=Horatio Nelson,ou=people,o=sevenSeas +sn: Buckley +uid: cbuckley +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=HMS Victory,ou=crews,ou=groups,o=sevenSeas +objectclass: groupOfUniqueNames +objectclass: top +cn: HMS Victory +uniquemember: cn=Horatio Nelson,ou=people,o=sevenSeas +uniquemember: cn=Thomas Masterman Hardy,ou=people,o=sevenSeas +uniquemember: cn=Cornelius Buckley,ou=people,o=sevenSeas + +# HMS Bounty Crew +# --------------- + +dn: cn=William Bligh,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: William Bligh +description: Captain William Bligh +givenname: William +sn: Bligh +uid: wbligh +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=Fletcher Christian,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: Fletcher Christian +description: Lieutenant Fletcher Christian +givenname: Fletcher +manager: cn=William Bligh,ou=people,o=sevenSeas +sn: Christian +uid: fchristi +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=John Fryer,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: John Fryer +description: Master John Fryer +givenname: John +manager: cn=William Bligh,ou=people,o=sevenSeas +sn: Fryer +uid: jfryer +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=John Hallett,ou=people,o=sevenSeas +objectclass: person +objectclass: organizationalPerson +objectclass: inetOrgPerson +objectclass: top +cn: John Hallett +description: Midshipman John Hallett +givenname: John +manager: cn=William Bligh,ou=people,o=sevenSeas +sn: Hallett +uid: jhallett +mail: [EMAIL PROTECTED] +userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ= + +dn: cn=HMS Bounty,ou=crews,ou=groups,o=sevenSeas +objectclass: groupOfUniqueNames +objectclass: top +cn: HMS Bounty +uniquemember: cn=William Bligh,ou=people,o=sevenSeas +uniquemember: cn=Fletcher Christian,ou=people,o=sevenSeas +uniquemember: cn=John Fryer,ou=people,o=sevenSeas +uniquemember: cn=John Hallett,ou=people,o=sevenSeas Modified: xwiki-products/xwiki-enterprise/trunk/distribution-test/pom.xml =================================================================== --- xwiki-products/xwiki-enterprise/trunk/distribution-test/pom.xml 2008-02-15 14:11:32 UTC (rev 7752) +++ xwiki-products/xwiki-enterprise/trunk/distribution-test/pom.xml 2008-02-15 14:17:23 UTC (rev 7753) @@ -220,5 +220,6 @@ <module>misc-tests</module> <module>xmlrpc-tests</module> <module>selenium-tests</module> + <module>ldap-tests</module> </modules> </project> _______________________________________________ notifications mailing list notifications@xwiki.org http://lists.xwiki.org/mailman/listinfo/notifications