You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/02/02 22:46:32 UTC
svn commit: r374520 -
/directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java
Author: akarasulu
Date: Thu Feb 2 13:46:30 2006
New Revision: 374520
URL: http://svn.apache.org/viewcvs?rev=374520&view=rev
Log:
initial commit for bad dn tests
Added:
directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java (with props)
Added: directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java?rev=374520&view=auto
==============================================================================
--- directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java (added)
+++ directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java Thu Feb 2 13:46:30 2006
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2004 Solarsis Group LLC.
+ *
+ * Licensed under the Open Software License, Version 2.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://opensource.org/licenses/osl-2.1.php
+ *
+ * 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.util.Hashtable;
+
+import javax.naming.AuthenticationException;
+import javax.naming.InvalidNameException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+
+
+/**
+ * Tests the effects of using a bad dn in various operations.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class BadDnTest extends AbstractServerTest
+{
+ /**
+ * Bind as a user.
+ */
+ public LdapContext bind( String bindDn, String password ) throws Exception
+ {
+ Hashtable env = new Hashtable();
+ env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
+ env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
+ env.put( "java.naming.security.principal", bindDn );
+ env.put( "java.naming.security.credentials", password );
+ env.put( "java.naming.security.authentication", "simple" );
+
+ LdapContext ctx = new InitialLdapContext( env, null );
+ assertNotNull( ctx );
+ return ctx;
+ }
+
+
+ /**
+ * Test with bindDn which is not even found under any namingContext of the
+ * server.
+ */
+ public void testBadBindDnNotInContext() throws Exception
+ {
+ try
+ {
+ bind( "cn=bogus", "blah" );
+ fail( "should never get here due to a " );
+ }
+ catch ( AuthenticationException e )
+ {
+ }
+ }
+
+
+ /**
+ * Test with bindDn that is under a naming context but points to non-existant user.
+ * @todo make this pass: see http://issues.apache.org/jira/browse/DIREVE-339
+ */
+// public void testBadBindDnMalformed() throws Exception
+// {
+// try
+// {
+// bind( "system", "blah" );
+// fail( "should never get here due to a " );
+// }
+// catch ( InvalidNameException e ){}
+// }
+
+
+ /**
+ * Test with bindDn that is under a naming context but points to non-existant user.
+ */
+ public void testBadBindDnInContext() throws Exception
+ {
+ try
+ {
+ bind( "cn=bogus,ou=system", "blah" );
+ fail( "should never get here due to a " );
+ }
+ catch ( AuthenticationException e )
+ {
+ }
+ }
+}
Propchange: directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java
------------------------------------------------------------------------------
svn:eol-style = native