diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-10-06 11:16:30 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-10-06 11:44:11 +0200 |
commit | e6b5cdd0c0e3d6c59fefbb0d12dcd0205004122d (patch) | |
tree | 95b317cdf51a46d618d9cd9bcad683774b05cc44 | |
parent | 9562b6cd5d1c6ba9d6dd243226d3000ca89a5771 (diff) | |
download | sonarqube-e6b5cdd0c0e3d6c59fefbb0d12dcd0205004122d.tar.gz sonarqube-e6b5cdd0c0e3d6c59fefbb0d12dcd0205004122d.zip |
SONAR-5612 Disabled users are displayed in global and project permissions page
5 files changed, 46 insertions, 6 deletions
diff --git a/sonar-core/src/main/resources/org/sonar/core/permission/PermissionMapper.xml b/sonar-core/src/main/resources/org/sonar/core/permission/PermissionMapper.xml index b3957662fa9..efb946a92c3 100644 --- a/sonar-core/src/main/resources/org/sonar/core/permission/PermissionMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/permission/PermissionMapper.xml @@ -15,6 +15,7 @@ AND user_role.resource_id IS NULL </if> <where> + u.active = ${_true} <choose> <when test="query.membership() == 'IN'"> AND user_role.role IS NOT NULL diff --git a/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionDaoTest.java b/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionDaoTest.java index 896d6f87de0..0265d269137 100644 --- a/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/permission/UserWithPermissionDaoTest.java @@ -20,10 +20,14 @@ package org.sonar.core.permission; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import org.junit.Before; import org.junit.Test; import org.sonar.core.persistence.AbstractDaoTestCase; +import javax.annotation.Nullable; + import java.util.List; import static org.fest.assertions.Assertions.assertThat; @@ -113,6 +117,23 @@ public class UserWithPermissionDaoTest extends AbstractDaoTestCase { } @Test + public void select_only_enable_users() throws Exception { + setupData("select_only_enable_users"); + + PermissionQuery query = PermissionQuery.builder().permission("user").build(); + List<UserWithPermissionDto> result = dao.selectUsers(query, COMPONENT_ID); + assertThat(result).hasSize(3); + + // Disabled user should not be returned + assertThat(Iterables.find(result, new Predicate<UserWithPermissionDto>() { + @Override + public boolean apply(@Nullable UserWithPermissionDto input) { + return input.getLogin().equals("disabledUser"); + } + }, null)).isNull(); + } + + @Test public void should_be_sorted_by_user_name() throws Exception { setupData("users_with_permissions_should_be_sorted_by_user_name"); diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/select_only_enable_users.xml b/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/select_only_enable_users.xml new file mode 100644 index 00000000000..662af1a0a8c --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/select_only_enable_users.xml @@ -0,0 +1,18 @@ +<dataset> + + <users id="200" login="user1" name="User1" active="[true]"/> + <users id="201" login="user2" name="User2" active="[true]"/> + <users id="202" login="user3" name="User3" active="[true]"/> + <users id="999" login="disabledUser" name="disabledUser" active="[false]"/> + + <!-- Project permissions --> + <user_roles id="1" user_id="200" resource_id="100" role="user"/> + <user_roles id="2" user_id="200" resource_id="100" role="admin"/> + <user_roles id="3" user_id="200" resource_id="100" role="codeviewer"/> + + <user_roles id="4" user_id="201" resource_id="100" role="user"/> + + <!-- Global permission --> + <user_roles id="10" user_id="200" resource_id="[null]" role="admin"/> + +</dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions.xml b/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions.xml index c67ff39f25b..6f40d31f21d 100644 --- a/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions.xml @@ -1,8 +1,8 @@ <dataset> - <users id="200" login="user1" name="User1"/> - <users id="201" login="user2" name="User2"/> - <users id="202" login="user3" name="User3"/> + <users id="200" login="user1" name="User1" active="[true]"/> + <users id="201" login="user2" name="User2" active="[true]"/> + <users id="202" login="user3" name="User3" active="[true]"/> <!-- Project permissions --> <user_roles id="1" user_id="200" resource_id="100" role="user"/> diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml b/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml index 3bb7487923c..6b39124ce6c 100644 --- a/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/UserWithPermissionDaoTest/users_with_permissions_should_be_sorted_by_user_name.xml @@ -1,8 +1,8 @@ <dataset> - <users id="200" login="user3" name="User3"/> - <users id="201" login="user1" name="User1"/> - <users id="202" login="user2" name="User2"/> + <users id="200" login="user3" name="User3" active="[true]"/> + <users id="201" login="user1" name="User1" active="[true]"/> + <users id="202" login="user2" name="User2" active="[true]"/> <user_roles id="1" user_id="200" resource_id="100" role="user"/> <user_roles id="2" user_id="200" resource_id="100" role="admin"/> |