aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantoine.vinot <antoine.vinot@sonarsource.com>2024-01-31 12:36:06 +0100
committersonartech <sonartech@sonarsource.com>2024-02-01 20:02:47 +0000
commit98457fb5d082e4b9d95da9e85e9d527ceb0cd59b (patch)
tree16348bcecf91608e453c2d8237b989c2a53b9f8b
parent854487694bec3d6d11b76961524cebf176ec8c8f (diff)
downloadsonarqube-98457fb5d082e4b9d95da9e85e9d527ceb0cd59b.tar.gz
sonarqube-98457fb5d082e4b9d95da9e85e9d527ceb0cd59b.zip
SONAR-21233 Be case insensitive on user email for issue assignment
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/user/UserDaoIT.java3
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml2
2 files changed, 4 insertions, 1 deletions
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}) )
</select>
</mapper>