From 1588dbb48810f06b4b84a337b1b18d3b2050d5a5 Mon Sep 17 00:00:00 2001 From: Robert Sanders Date: Mon, 21 Mar 2005 03:16:18 +0000 Subject: [PATCH] My LDAP server setup is different, so I can't test this without re-writing it; but at least it now compiles. Once I get the ApacheDS based tests working, I'll removed this test. --- .../TestLdapPasswordAuthenticationDao.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sandbox/src/test/java/org/acegisecurity/providers/dao/ldap/TestLdapPasswordAuthenticationDao.java b/sandbox/src/test/java/org/acegisecurity/providers/dao/ldap/TestLdapPasswordAuthenticationDao.java index 3d1720cbe0..774b129b22 100644 --- a/sandbox/src/test/java/org/acegisecurity/providers/dao/ldap/TestLdapPasswordAuthenticationDao.java +++ b/sandbox/src/test/java/org/acegisecurity/providers/dao/ldap/TestLdapPasswordAuthenticationDao.java @@ -32,6 +32,7 @@ import org.springframework.dao.DataAccessException; public class TestLdapPasswordAuthenticationDao extends TestCase { //~ Static fields/initializers ============================================= + static String PORT = "389"; static String HOSTNAME = "ntserver"; static String HOST_IP = "192.168.1.1"; static String ROOT_CONTEXT = "DC=issa,DC=cz"; @@ -61,7 +62,7 @@ public class TestLdapPasswordAuthenticationDao extends TestCase { } public void testAuthenticationInvalidHost() { - dao.setHost("xxx"); + dao.setURL("ldap://xxx/"); try { UserDetails user = dao.loadUserByUsernameAndPassword(USERNAME, @@ -86,7 +87,7 @@ public class TestLdapPasswordAuthenticationDao extends TestCase { } public void testAuthenticationInvalidPort() { - dao.setPort(123); + dao.setURL("ldap://" + HOSTNAME + ":123"); try { UserDetails user = dao.loadUserByUsernameAndPassword(USERNAME, @@ -102,8 +103,7 @@ public class TestLdapPasswordAuthenticationDao extends TestCase { public void testAuthenticationInvalidRolesAttribute() { // dao.setRolesAttribute("xxx"); try { - UserDetails user = dao.loadUserByUsernameAndPassword(USERNAME, - PASSWORD); + UserDetails user = dao.loadUserByUsernameAndPassword(USERNAME, PASSWORD); fail(); } catch (BadCredentialsException ex) { assertEquals("The user has no granted authorities or the rolesAttribute is invalid", @@ -163,7 +163,8 @@ public class TestLdapPasswordAuthenticationDao extends TestCase { } public void testAuthenticationValidWithIpHost() { - dao.setHost(HOST_IP); + //dao.setHost(HOST_IP); + dao.setURL("ldap://" + HOST_IP + ":" + PORT); UserDetails user = dao.loadUserByUsernameAndPassword(USERNAME, PASSWORD); assertEquals(USERNAME, user.getUsername()); @@ -177,9 +178,10 @@ public class TestLdapPasswordAuthenticationDao extends TestCase { protected void setUp() throws Exception { super.setUp(); dao = new LdapPasswordAuthenticationDao(); - dao.setHost(HOSTNAME); // ldap://lojza:389/DC=elcom,DC=cz - dao.setPort(389); - dao.setRootContext(ROOT_CONTEXT); + //dao.setHost(HOSTNAME); // ldap://lojza:389/DC=elcom,DC=cz + //dao.setPort(389); + dao.setURL("ldap://" + HOSTNAME + ":" + PORT); + dao.setRootContext(ROOT_CONTEXT); //Depending on server this can be confusing... dao.setUserContext(USER_CONTEXT); // dao.setRolesAttribute(ROLES_ATTRIBUTE);