/[Apache-SVN]/directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java
ViewVC logotype

Contents of /directory/trunks/apacheds/simple/unit/src/test/java/org/apache/ldap/server/BadDnTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 374520 - (show annotations)
Thu Feb 2 21:46:30 2006 UTC (3 years, 9 months ago) by akarasulu
File size: 2932 byte(s)
initial commit for bad dn tests
1 /*
2 * Copyright (c) 2004 Solarsis Group LLC.
3 *
4 * Licensed under the Open Software License, Version 2.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://opensource.org/licenses/osl-2.1.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.apache.ldap.server;
17
18
19 import java.util.Hashtable;
20
21 import javax.naming.AuthenticationException;
22 import javax.naming.InvalidNameException;
23 import javax.naming.ldap.InitialLdapContext;
24 import javax.naming.ldap.LdapContext;
25
26
27 /**
28 * Tests the effects of using a bad dn in various operations.
29 *
30 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31 * @version $Rev$
32 */
33 public class BadDnTest extends AbstractServerTest
34 {
35 /**
36 * Bind as a user.
37 */
38 public LdapContext bind( String bindDn, String password ) throws Exception
39 {
40 Hashtable env = new Hashtable();
41 env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
42 env.put( "java.naming.provider.url", "ldap://localhost:" + port + "/ou=system" );
43 env.put( "java.naming.security.principal", bindDn );
44 env.put( "java.naming.security.credentials", password );
45 env.put( "java.naming.security.authentication", "simple" );
46
47 LdapContext ctx = new InitialLdapContext( env, null );
48 assertNotNull( ctx );
49 return ctx;
50 }
51
52
53 /**
54 * Test with bindDn which is not even found under any namingContext of the
55 * server.
56 */
57 public void testBadBindDnNotInContext() throws Exception
58 {
59 try
60 {
61 bind( "cn=bogus", "blah" );
62 fail( "should never get here due to a " );
63 }
64 catch ( AuthenticationException e )
65 {
66 }
67 }
68
69
70 /**
71 * Test with bindDn that is under a naming context but points to non-existant user.
72 * @todo make this pass: see http://issues.apache.org/jira/browse/DIREVE-339
73 */
74 // public void testBadBindDnMalformed() throws Exception
75 // {
76 // try
77 // {
78 // bind( "system", "blah" );
79 // fail( "should never get here due to a " );
80 // }
81 // catch ( InvalidNameException e ){}
82 // }
83
84
85 /**
86 * Test with bindDn that is under a naming context but points to non-existant user.
87 */
88 public void testBadBindDnInContext() throws Exception
89 {
90 try
91 {
92 bind( "cn=bogus,ou=system", "blah" );
93 fail( "should never get here due to a " );
94 }
95 catch ( AuthenticationException e )
96 {
97 }
98 }
99 }

Properties

Name Value
svn:eol-style native

apache@apache.org
ViewVC Help
Powered by ViewVC 1.1.2