aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/RoleDao.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/RoleMapper.java3
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/user/RoleMapper.xml4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/user/RoleDaoTest.java2
4 files changed, 6 insertions, 6 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java b/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java
index 6f8828c91bf..b74fd723598 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java
@@ -27,7 +27,6 @@ import org.sonar.api.task.TaskComponent;
import org.sonar.core.persistence.MyBatis;
import javax.annotation.Nullable;
-
import java.util.List;
public class RoleDao implements TaskComponent, ServerComponent {
@@ -52,7 +51,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
SqlSession session = mybatis.openSession();
RoleMapper mapper = session.getMapper(RoleMapper.class);
try {
- return mapper.selectGroupPermissions(groupName, resourceId, DefaultGroups.ANYONE);
+ return mapper.selectGroupPermissions(groupName, resourceId, DefaultGroups.isAnyone(groupName));
} finally {
MyBatis.closeQuietly(session);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/user/RoleMapper.java b/sonar-core/src/main/java/org/sonar/core/user/RoleMapper.java
index 6d640c79423..0bf7b30fb3c 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/RoleMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/RoleMapper.java
@@ -22,7 +22,6 @@ package org.sonar.core.user;
import org.apache.ibatis.annotations.Param;
import javax.annotation.Nullable;
-
import java.util.List;
/**
@@ -38,7 +37,7 @@ public interface RoleMapper {
/**
* @return permissions from to a group
*/
- List<String> selectGroupPermissions(@Param("groupName") String groupName, @Nullable @Param("resourceId") Long resourceId, @Param("anyOneGroup") String anyOneGroup);
+ List<String> selectGroupPermissions(@Param("groupName") String groupName, @Nullable @Param("resourceId") Long resourceId, @Param("isAnyOneGroup") Boolean isAnyOneGroup);
void insertGroupRole(GroupRoleDto groupRole);
diff --git a/sonar-core/src/main/resources/org/sonar/core/user/RoleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/RoleMapper.xml
index dd79e541e35..6587141c772 100644
--- a/sonar-core/src/main/resources/org/sonar/core/user/RoleMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/user/RoleMapper.xml
@@ -23,12 +23,12 @@
<select id="selectGroupPermissions" parameterType="map" resultType="String">
SELECT gr.role
FROM group_roles gr
- <if test="groupName != anyOneGroup">
+ <if test="isAnyOneGroup != true">
INNER JOIN groups g ON g.id = gr.group_id
</if>
<where>
<choose>
- <when test="groupName != anyOneGroup">
+ <when test="isAnyOneGroup != true">
AND g.name = #{groupName}
</when>
<otherwise>
diff --git a/sonar-core/src/test/java/org/sonar/core/user/RoleDaoTest.java b/sonar-core/src/test/java/org/sonar/core/user/RoleDaoTest.java
index f2d702f9e47..71e883f7194 100644
--- a/sonar-core/src/test/java/org/sonar/core/user/RoleDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/user/RoleDaoTest.java
@@ -60,6 +60,8 @@ public class RoleDaoTest extends AbstractDaoTestCase {
GlobalPermissions.DASHBOARD_SHARING);
assertThat(dao.selectGroupPermissions("sonar-users", null)).containsOnly(GlobalPermissions.DASHBOARD_SHARING);
assertThat(dao.selectGroupPermissions(DefaultGroups.ANYONE, null)).containsOnly(GlobalPermissions.DRY_RUN_EXECUTION, GlobalPermissions.SCAN_EXECUTION);
+ assertThat(dao.selectGroupPermissions("anyone", null)).containsOnly(GlobalPermissions.DRY_RUN_EXECUTION, GlobalPermissions.SCAN_EXECUTION);
+ assertThat(dao.selectGroupPermissions("AnYoNe", null)).containsOnly(GlobalPermissions.DRY_RUN_EXECUTION, GlobalPermissions.SCAN_EXECUTION);
}
@Test