]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10176 Fix query of users having a global permission
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 7 Dec 2017 14:28:45 +0000 (15:28 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 12 Dec 2017 12:35:16 +0000 (13:35 +0100)
server/sonar-db-dao/src/main/resources/org/sonar/db/permission/AuthorizationMapper.xml
server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java

index 60f105b4ede4b6176d5df5d6cf3ff7cb790621c1..3df9e766e1ebccf1e82716b426f897d2d7fc544b 100644 (file)
     inner join users u on u.id=ur.user_id
     where
     ur.role=#{permission,jdbcType=VARCHAR}
+    and ur.resource_id is null
 
     union
 
     inner join users u on u.id=gu.user_id
     where
     gr.role = #{permission,jdbcType=VARCHAR} and
+    gr.resource_id is null and
     gr.group_id is not null
   </select>
 
index 951f8011a034d9424446e45218a04d8e82d08cc4..2e6ba70c1e265819c29e5c36c3869353498983e1 100644 (file)
@@ -1021,8 +1021,11 @@ public class AuthorizationDaoTest {
     UserDto user3 = db.users().insertUser();
     db.users().insertMember(administratorGroup2, user3);
 
+    ComponentDto project = db.components().insertPrivateProject();
+
     UserDto user4 = db.users().insertUser();
     db.users().insertPermissionOnUser(organization1, user4, ADMINISTER_QUALITY_PROFILES);
+    db.users().insertProjectPermissionOnUser(user4, "admin", project);
     db.users().insertUser();
 
     List<String> logins = underTest.selectGlobalAdministratorLogins(dbSession);