From 9ad2a8272ebd96b8086a810cf9941bf6cc5baeca Mon Sep 17 00:00:00 2001 From: Charles Walker Date: Fri, 24 Jul 2015 16:08:26 -0400 Subject: [PATCH] quick return check for null email address, in reference to duplicate email check issue #1510 --- .../org/keycloak/models/cache/DefaultCacheUserProvider.java | 1 + .../federation/FederationProvidersIntegrationTest.java | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheUserProvider.java b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheUserProvider.java index aed1394415..0702553741 100755 --- a/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheUserProvider.java +++ b/model/invalidation-cache/model-adapters/src/main/java/org/keycloak/models/cache/DefaultCacheUserProvider.java @@ -172,6 +172,7 @@ public class DefaultCacheUserProvider implements CacheUserProvider { @Override public UserModel getUserByEmail(String email, RealmModel realm) { + if (email == null) return null; email = email.toLowerCase(); diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/FederationProvidersIntegrationTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/FederationProvidersIntegrationTest.java index 520ebd4cab..8c33f9fa36 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/FederationProvidersIntegrationTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/federation/FederationProvidersIntegrationTest.java @@ -520,6 +520,8 @@ public class FederationProvidersIntegrationTest { LDAPFederationProvider ldapFedProvider = FederationTestUtils.getLdapProvider(session, ldapModel); FederationTestUtils.addLDAPUser(ldapFedProvider, appRealm, "marykeycloak", "Mary1", "Kelly1", "mary1@email.org", null, "123"); FederationTestUtils.addLDAPUser(ldapFedProvider, appRealm, "mary-duplicatemail", "Mary2", "Kelly2", "mary@test.com", null, "123"); + LDAPObject marynoemail = FederationTestUtils.addLDAPUser(ldapFedProvider, appRealm, "marynoemail", "Mary1", "Kelly1", null, null, "123"); + ldapFedProvider.getLdapIdentityStore().updatePassword(marynoemail, "Password1"); } }); @@ -531,6 +533,8 @@ public class FederationProvidersIntegrationTest { loginPage.login("mary1@email.org", "password"); Assert.assertEquals("Username already exists.", loginPage.getError()); + + loginSuccessAndLogout("marynoemail", "Password1"); } @Test