Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +2 −2 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO { if (e.getResultCode() == ResultCode.SIZE_LIMIT_EXCEEDED) { String msg = "More than one User with email address " + emailAddress + " found"; String msg = "More than one user with email address " + emailAddress + " found"; logger.debug(msg); throw new UserNotFoundException(msg); } Loading Loading @@ -608,7 +608,7 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO { if (e.getResultCode() == ResultCode.SIZE_LIMIT_EXCEEDED) { String msg = "More than one User with email address " + emailAddress + " found"; String msg = "More than one user with email address " + emailAddress + " found"; logger.debug(msg); throw new UserNotFoundException(msg); } Loading cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAOTest.java +55 −23 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ import static org.junit.Assert.fail; import java.io.File; import java.security.AccessControlException; import java.security.Principal; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Collection; import java.util.Random; Loading Loading @@ -397,20 +398,9 @@ public class LdapUserDAOTest extends AbstractLdapDAOTest }); } /** * Test of getUserByEmailAddress method, of class LdapUserDAO. */ @Test public void testGetUserByEmailAddress() throws Exception { // create a user with the email attribute final String username = createUsername(); final String emailAddress = username +"@canada.ca"; final HttpPrincipal userID = new HttpPrincipal(username); final UserRequest<Principal> userRequest = createUserRequest(userID, emailAddress); addUser(userID, userRequest); try protected void testGetOneUserByEmailAddress(final String emailAddress, final String username) throws PrivilegedActionException { // do as servops Subject servops = SSLUtil.createSubject(new File(SERVOPS_PEM)); Loading @@ -437,6 +427,48 @@ public class LdapUserDAOTest extends AbstractLdapDAOTest } }); } /** * Test of getUserByEmailAddress method, of class LdapUserDAO. */ @Test public void testGetUserByEmailAddress() throws Exception { // create a user with the email attribute final String username = createUsername(); final String emailAddress = username +"@canada.ca"; final HttpPrincipal userID = new HttpPrincipal(username); final UserRequest<Principal> userRequest = createUserRequest(userID, emailAddress); addUser(userID, userRequest); try { // case 1: only one user matches the email address testGetOneUserByEmailAddress(emailAddress, username); // create another user with the same email attribute final String username1 = createUsername(); final HttpPrincipal userID1 = new HttpPrincipal(username1); final UserRequest<Principal> userRequest1 = createUserRequest(userID1, emailAddress); addUser(userID1, userRequest1); try { // case 2: two users match the email address testGetOneUserByEmailAddress(emailAddress, username); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); Throwable t = e.getCause(); assertTrue(e.getCause() instanceof UserNotFoundException); assertTrue(e.getCause().getMessage().contains("More than one user")); } finally { deleteUser(userID1); } } finally { deleteUser(userID); Loading Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +2 −2 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO { if (e.getResultCode() == ResultCode.SIZE_LIMIT_EXCEEDED) { String msg = "More than one User with email address " + emailAddress + " found"; String msg = "More than one user with email address " + emailAddress + " found"; logger.debug(msg); throw new UserNotFoundException(msg); } Loading Loading @@ -608,7 +608,7 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO { if (e.getResultCode() == ResultCode.SIZE_LIMIT_EXCEEDED) { String msg = "More than one User with email address " + emailAddress + " found"; String msg = "More than one user with email address " + emailAddress + " found"; logger.debug(msg); throw new UserNotFoundException(msg); } Loading
cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAOTest.java +55 −23 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ import static org.junit.Assert.fail; import java.io.File; import java.security.AccessControlException; import java.security.Principal; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Collection; import java.util.Random; Loading Loading @@ -397,20 +398,9 @@ public class LdapUserDAOTest extends AbstractLdapDAOTest }); } /** * Test of getUserByEmailAddress method, of class LdapUserDAO. */ @Test public void testGetUserByEmailAddress() throws Exception { // create a user with the email attribute final String username = createUsername(); final String emailAddress = username +"@canada.ca"; final HttpPrincipal userID = new HttpPrincipal(username); final UserRequest<Principal> userRequest = createUserRequest(userID, emailAddress); addUser(userID, userRequest); try protected void testGetOneUserByEmailAddress(final String emailAddress, final String username) throws PrivilegedActionException { // do as servops Subject servops = SSLUtil.createSubject(new File(SERVOPS_PEM)); Loading @@ -437,6 +427,48 @@ public class LdapUserDAOTest extends AbstractLdapDAOTest } }); } /** * Test of getUserByEmailAddress method, of class LdapUserDAO. */ @Test public void testGetUserByEmailAddress() throws Exception { // create a user with the email attribute final String username = createUsername(); final String emailAddress = username +"@canada.ca"; final HttpPrincipal userID = new HttpPrincipal(username); final UserRequest<Principal> userRequest = createUserRequest(userID, emailAddress); addUser(userID, userRequest); try { // case 1: only one user matches the email address testGetOneUserByEmailAddress(emailAddress, username); // create another user with the same email attribute final String username1 = createUsername(); final HttpPrincipal userID1 = new HttpPrincipal(username1); final UserRequest<Principal> userRequest1 = createUserRequest(userID1, emailAddress); addUser(userID1, userRequest1); try { // case 2: two users match the email address testGetOneUserByEmailAddress(emailAddress, username); } catch (PrivilegedActionException pae) { Exception e = pae.getException(); Throwable t = e.getCause(); assertTrue(e.getCause() instanceof UserNotFoundException); assertTrue(e.getCause().getMessage().contains("More than one user")); } finally { deleteUser(userID1); } } finally { deleteUser(userID); Loading