You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/09/20 08:37:08 UTC

svn commit: r998799 - in /directory/apacheds/trunk: kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java

Author: seelmann
Date: Mon Sep 20 06:37:08 2010
New Revision: 998799

URL: http://svn.apache.org/viewvc?rev=998799&view=rev
Log:
Fix GSSAPI tests on Windows 7 and Server 2008, hopefully.

Modified:
    directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java

Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java?rev=998799&r1=998798&r2=998799&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/SaslGssapiBindITest.java Mon Sep 20 06:37:08 2010
@@ -23,6 +23,8 @@ package org.apache.directory.server.kerb
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.security.PrivilegedAction;
 import java.util.Hashtable;
 
@@ -158,6 +160,23 @@ public class SaslGssapiBindITest extends
     @Before
     public void setUp() throws Exception
     {
+        // On Windows 7 and Server 2008 the loopback address 127.0.0.1
+        // isn't resolved to localhost by default. In that case we need
+        // to use the IP address for the service principal.
+        String hostName;
+        try
+        {
+            InetAddress loopback = InetAddress.getByName( "127.0.0.1" );
+            hostName = loopback.getHostName();
+        }
+        catch ( UnknownHostException e )
+        {
+            System.err.println( "Can't find loopback address '127.0.0.1', using hostname 'localhost'" );
+            hostName = "localhost";
+        }
+        String servicePrincipal = "ldap/" + hostName + "@EXAMPLE.COM";
+        ldapServer.setSaslPrincipal( servicePrincipal );
+
         Attributes attrs;
 
         setContexts( "uid=admin,ou=system", "secret" );
@@ -203,7 +222,7 @@ public class SaslGssapiBindITest extends
         attrs = getPrincipalAttributes( "Service", "KDC Service", "krbtgt", "secret", "krbtgt/EXAMPLE.COM@EXAMPLE.COM" );
         users.createSubcontext( "uid=krbtgt", attrs );
 
-        attrs = getPrincipalAttributes( "Service", "LDAP Service", "ldap", "randall", "ldap/localhost@EXAMPLE.COM" );
+        attrs = getPrincipalAttributes( "Service", "LDAP Service", "ldap", "randall", servicePrincipal );
         users.createSubcontext( "uid=ldap", attrs );
     }
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java?rev=998799&r1=998798&r2=998799&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java Mon Sep 20 06:37:08 2010
@@ -25,13 +25,13 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 
 import javax.naming.NamingEnumeration;
 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;
 
@@ -120,8 +120,8 @@ import org.slf4j.LoggerFactory;
         "cn: KDC Service",
         "sn: Service",
         
-        // ldap 
-        "dn: uid=ldap,ou=users,dc=example,dc=com",
+        // ldap per host
+        "dn: uid=ldap-host,ou=users,dc=example,dc=com",
         "objectClass: inetOrgPerson",
         "objectClass: organizationalPerson",
         "objectClass: person",
@@ -133,6 +133,21 @@ import org.slf4j.LoggerFactory;
         "krb5PrincipalName: ldap/localhost@EXAMPLE.COM",
         "krb5KeyVersionNumber: 0",
         "cn: LDAP Service",
+        "sn: Service",
+        
+        // ldap per IP
+        "dn: uid=ldap-ip,ou=users,dc=example,dc=com",
+        "objectClass: inetOrgPerson",
+        "objectClass: organizationalPerson",
+        "objectClass: person",
+        "objectClass: krb5principal",
+        "objectClass: krb5kdcentry",
+        "objectClass: top",
+        "uid: ldap",
+        "userPassword: randall",
+        "krb5PrincipalName: ldap/127.0.0.1@EXAMPLE.COM",
+        "krb5KeyVersionNumber: 0",
+        "cn: LDAP Service",
         "sn: Service"
     })
 @CreateDS(allowAnonAccess = false, name = "SaslBindIT-class", partitions =
@@ -158,6 +173,26 @@ additionalInterceptors = { KeyDerivation
     })
 public class SaslBindIT extends AbstractLdapTestUnit
 {
+    public SaslBindIT()
+    {
+        // On Windows 7 and Server 2008 the loopback address 127.0.0.1
+        // isn't resolved to localhost by default. In that case we need
+        // to use the IP address for the service principal.
+        String hostName;
+        try
+        {
+            InetAddress loopback = InetAddress.getByName( "127.0.0.1" );
+            hostName = loopback.getHostName();
+        }
+        catch ( UnknownHostException e )
+        {
+            System.err.println( "Can't find loopback address '127.0.0.1', using hostname 'localhost'" );
+            hostName = "localhost";
+        }
+        String servicePrincipal = "ldap/" + hostName + "@EXAMPLE.COM";
+        ldapServer.setSaslPrincipal( servicePrincipal );
+    }
+
 
     /**
      * Tests to make sure the server properly returns the supportedSASLMechanisms.