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 2005/11/05 09:27:56 UTC
svn commit: r330984 - in
/directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server:
authn/SimpleAuthenticationTest.java jndi/ObjStateFactoryTest.java
Author: akarasulu
Date: Sat Nov 5 00:27:53 2005
New Revision: 330984
URL: http://svn.apache.org/viewcvs?rev=330984&view=rev
Log:
fixed bug in test case introduced from changing octetstring syntax to binary - passwords are returned as binary values now (byte[])
Modified:
directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/jndi/ObjStateFactoryTest.java
Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/authn/SimpleAuthenticationTest.java?rev=330984&r1=330983&r2=330984&view=diff
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/authn/SimpleAuthenticationTest.java (original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/authn/SimpleAuthenticationTest.java Sat Nov 5 00:27:53 2005
@@ -48,7 +48,7 @@
{
/**
* Cleans up old database files on creation.
- * @throws IOException
+ * @throws IOException
*/
public SimpleAuthenticationTest() throws IOException
{
@@ -72,15 +72,8 @@
*/
protected void setUp() throws Exception
{
- if ( getName().equals( "test1AdminAccountCreation" ) ||
- getName().equals( "test2AccountExistsOnRestart" ) )
- {
- super.doDelete = false;
- }
- else
- {
- super.doDelete = true;
- }
+ super.doDelete = !( getName().equals("test1AdminAccountCreation") ||
+ getName().equals("test2AccountExistsOnRestart") );
if ( getName().equals( "test5BuildDbNoPassWithPrincAuthNone" ) ||
getName().equals( "test6BuildDbNoPassNotAdminPrinc" ) ||
@@ -211,7 +204,7 @@
try
{
- ctx = ( InitialLdapContext ) initial.lookup( "uid=admin" );
+ initial.lookup( "uid=admin" );
fail( "should not get here due to exception cuz anonymous user is "
+ "not allowed read access to the admin account entry" );
}
Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/jndi/ObjStateFactoryTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/jndi/ObjStateFactoryTest.java?rev=330984&r1=330983&r2=330984&view=diff
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/jndi/ObjStateFactoryTest.java (original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/ldap/server/jndi/ObjStateFactoryTest.java Sat Nov 5 00:27:53 2005
@@ -44,25 +44,15 @@
public void testObjectFactory() throws NamingException
{
super.sysRoot.addToEnvironment( Context.OBJECT_FACTORIES, PersonObjectFactory.class.getName() );
-
Object obj = super.sysRoot.lookup( "uid=akarasulu, ou=users" );
-
Attributes attrs = super.sysRoot.getAttributes( "uid=akarasulu, ou=users" );
-
assertEquals( Person.class, obj.getClass() );
-
Person me = ( Person ) obj;
-
assertEquals( attrs.get( "sn" ).get(), me.getLastname() );
-
assertEquals( attrs.get( "cn" ).get(), me.getCn() );
-
- assertEquals( attrs.get( "userPassword" ).get(), me.getPassword() );
-
+ assertEquals( attrs.get( "userPassword" ).get(), "test".getBytes() );
assertEquals( attrs.get( "telephonenumber" ).get(), me.getTelephoneNumber() );
-
assertNull( me.getSeealso() );
-
assertNull( me.getDescription() );
}
@@ -70,25 +60,15 @@
public void testStateFactory() throws NamingException
{
super.sysRoot.addToEnvironment( Context.STATE_FACTORIES, PersonStateFactory.class.getName() );
-
Person p = new Person( "Rodriguez", "Mr. Kerberos", "noices", "555-1212", "erodriguez", "committer" );
-
super.sysRoot.bind( "uid=erodriguez, ou=users", p );
-
Attributes attrs = super.sysRoot.getAttributes( "uid=erodriguez, ou=users" );
-
assertEquals( "Rodriguez", attrs.get( "sn" ).get() );
-
assertEquals( "Mr. Kerberos", attrs.get( "cn" ).get() );
-
- assertEquals( "noices", attrs.get( "userPassword" ).get() );
-
+ assertEquals( "noices".getBytes(), attrs.get( "userPassword" ).get() );
assertEquals( "555-1212", attrs.get( "telephonenumber" ).get() );
-
assertEquals( "erodriguez", attrs.get( "seealso" ).get() );
-
assertEquals( "committer", attrs.get( "description" ).get() );
-
}
@@ -115,9 +95,7 @@
if ( outAttrs.get( "objectclass" ) == null )
{
BasicAttribute oc = new BasicAttribute( "objectclass", "person" );
-
oc.add( "top" );
-
outAttrs.put( oc );
}
@@ -180,13 +158,15 @@
// Only interested in Attributes with "person" objectclass
// System.out.println("object factory: " + attrs);
Attribute oc = (attrs != null ? attrs.get("objectclass") : null);
- if (oc != null && oc.contains("person")) {
+ if (oc != null && oc.contains("person"))
+ {
Attribute attr;
- String passwd = null;
+ String passwd = null;
// Extract the password
attr = attrs.get("userPassword");
- if (attr != null) {
+ if (attr != null)
+ {
Object pw = attr.get();
if ( pw instanceof String )
@@ -194,14 +174,14 @@
else
passwd = new String((byte[]) pw);
}
- Person per = new Person(
- (String)attrs.get("sn").get(),
- (String)attrs.get("cn").get(),
- passwd,
- (attr=attrs.get("telephoneNumber")) != null ? (String)attr.get() : null,
- (attr=attrs.get("seealso")) != null ? (String)attr.get() : null,
- (attr=attrs.get("description")) != null ? (String)attr.get() : null);
- return per;
+
+ return new Person(
+ (String)attrs.get("sn").get(),
+ (String)attrs.get("cn").get(),
+ passwd,
+ (attr=attrs.get("telephoneNumber")) != null ? (String)attr.get() : null,
+ (attr=attrs.get("seealso")) != null ? (String)attr.get() : null,
+ (attr=attrs.get("description")) != null ? (String)attr.get() : null);
}
return null;
}