directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r365896 - in /directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test: java/org/apache/ldap/server/LdapsTest.java resources/bogus.cert
Date Wed, 04 Jan 2006 11:53:51 GMT
Author: trustin
Date: Wed Jan  4 03:53:39 2006
New Revision: 365896

URL: http://svn.apache.org/viewcvs?rev=365896&view=rev
Log:
Added LdapsTest (doesn't work yet)

Added:
    directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/java/org/apache/ldap/server/LdapsTest.java
  (with props)
    directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/resources/bogus.cert   (with
props)

Added: directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/java/org/apache/ldap/server/LdapsTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/java/org/apache/ldap/server/LdapsTest.java?rev=365896&view=auto
==============================================================================
--- directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/java/org/apache/ldap/server/LdapsTest.java
(added)
+++ directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/java/org/apache/ldap/server/LdapsTest.java
Wed Jan  4 03:53:39 2006
@@ -0,0 +1,123 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.ldap.server;
+
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+import org.apache.mina.util.AvailablePortFinder;
+
+
+/**
+ * Test case to verify DIREVE-216.  Starts up the server binds via SUN JNDI provider
+ * to perform add modify operations on entries.
+ * 
+ * @author szoerner
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class LdapsTest extends AbstractServerTest
+{
+    private static final String RDN = "cn=The Person";
+
+    private DirContext ctx = null;
+
+
+    /**
+     * Create an entry for a person.
+     */
+    public void setUp() throws Exception
+    {
+        int ldapsPort = AvailablePortFinder.getNextAvailable( 8192 );
+        configuration.setEnableLdaps( true );
+        configuration.setLdapsPort( ldapsPort );
+
+        // Copy the bogus certificate to the certificates directory.
+        InputStream in = getClass().getResourceAsStream( "/bogus.cert" );
+        configuration.getLdapsCertificateFile().getParentFile().mkdirs();
+
+        System.out.println( configuration.getLdapsCertificateFile().getAbsolutePath() );
+        FileOutputStream out = new FileOutputStream(
+                configuration.getLdapsCertificateFile() );
+
+        for( ;; )
+        {
+            int c = in.read();
+            if( c < 0 )
+            {
+                break;
+            }
+            out.write( c );
+        }
+
+        in.close();
+        out.close();
+
+        super.setUp();
+
+        Hashtable env = new Hashtable();
+        env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+        env.put( "java.naming.provider.url", "ldaps://localhost:" + ldapsPort + "/ou=system"
);
+        env.put( "java.naming.security.principal", "uid=admin,ou=system" );
+        env.put( "java.naming.security.credentials", "secret" );
+        env.put( "java.naming.security.authentication", "simple" );
+        ctx = new InitialDirContext( env );
+    }
+
+
+    /**
+     * Remove the person.
+     */
+    public void tearDown() throws Exception
+    {
+        ctx.unbind(RDN);
+        ctx.close();
+        ctx = null;
+        super.tearDown();
+    }
+
+
+    /**
+     * Just a little test to check if the connection is made successfully.
+     */
+    public void testSetUpTearDown() throws NamingException
+    {
+        // Create a person
+        Attributes attributes = new BasicAttributes( true );
+        Attribute attribute = new BasicAttribute( "objectClass" );
+        attribute.add( "top" );
+        attribute.add( "person" );
+        attributes.put( attribute );
+        attributes.put( "cn", "The Person" );
+        attributes.put( "sn", "Person" );
+        attributes.put( "description", "this is a person" );
+        DirContext person = ctx.createSubcontext( RDN, attributes );
+
+        assertNotNull( person );
+    }
+}

Propchange: directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/java/org/apache/ldap/server/LdapsTest.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/resources/bogus.cert
URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/resources/bogus.cert?rev=365896&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/sandbox/trustin/ldaps/apacheds-server-unit/src/test/resources/bogus.cert
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message