From 98457fb5d082e4b9d95da9e85e9d527ceb0cd59b Mon Sep 17 00:00:00 2001 From: "antoine.vinot" Date: Wed, 31 Jan 2024 12:36:06 +0100 Subject: [PATCH] SONAR-21233 Be case insensitive on user email for issue assignment --- .../sonar-db-dao/src/it/java/org/sonar/db/user/UserDaoIT.java | 3 +++ .../src/main/resources/org/sonar/db/user/UserMapper.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/user/UserDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/user/UserDaoIT.java index 6c01e7fdbca..80305e2fbee 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/user/UserDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/user/UserDaoIT.java @@ -96,6 +96,7 @@ public class UserDaoIT { String user1 = db.users().insertUser(user -> user.setLogin("user1").setEmail("toto@tata.com")).getUuid(); String user2 = db.users().insertUser(user -> user.setLogin("user2")).getUuid(); String user3 = db.users().insertUser(user -> user.setLogin("user3").setScmAccounts(List.of("scmuser3", "scmuser3bis"))).getUuid(); + String user4 = db.users().insertUser(user -> user.setLogin("user4").setEmail("UPPERCASE@tata.com")).getUuid(); db.users().insertUser(); db.users().insertUser(user -> user.setLogin("inactive_user1").setActive(false)); db.users().insertUser(user -> user.setLogin("inactive_user2").setActive(false).setScmAccounts(List.of("inactive_user2"))); @@ -108,6 +109,8 @@ public class UserDaoIT { .extracting(UserIdDto::getUuid, UserIdDto::getLogin).containsExactly(new Tuple(user3, "user3")); assertThat(underTest.selectActiveUsersByScmAccountOrLoginOrEmail(session, "inactive_user1")).isEmpty(); assertThat(underTest.selectActiveUsersByScmAccountOrLoginOrEmail(session, "inactive_user2")).isEmpty(); + assertThat(underTest.selectActiveUsersByScmAccountOrLoginOrEmail(session, "uppercase@tata.com")) + .extracting(UserIdDto::getUuid, UserIdDto::getLogin).containsExactly(new Tuple(user4, "user4")); } @Test diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml index dae72afd8ce..81e514fd729 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml @@ -364,7 +364,7 @@ union select uuid, login from users u - where active=${_true} and (login=#{scmAccount,jdbcType=VARCHAR} or email=#{scmAccount,jdbcType=VARCHAR} ) + where active=${_true} and (login=#{scmAccount,jdbcType=VARCHAR} or lower(email)=lower(#{scmAccount,jdbcType=VARCHAR}) ) -- 2.39.5