]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21233 Be case insensitive on user email for issue assignment
authorantoine.vinot <antoine.vinot@sonarsource.com>
Wed, 31 Jan 2024 11:36:06 +0000 (12:36 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 1 Feb 2024 20:02:47 +0000 (20:02 +0000)
server/sonar-db-dao/src/it/java/org/sonar/db/user/UserDaoIT.java
server/sonar-db-dao/src/main/resources/org/sonar/db/user/UserMapper.xml

index 6c01e7fdbcad63178d9bed22f175d492e285c738..80305e2fbeee6d35217875a55eea3f8b641419af 100644 (file)
@@ -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
index dae72afd8ce28d1cc2411c9b8b84e70aecd0e855..81e514fd729828d5da9767d6c0b83737cbd75822 100644 (file)
       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>