aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>2013-07-11 17:19:51 +0200
committerJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>2013-07-11 17:19:51 +0200
commit4c20d02a36d8da972e2983e4c02372285c76b153 (patch)
tree15fd9b44a897c53ef3ec6a9c0bb19a0549c57bf9 /sonar-core
parentd217475442c8b463724626325f27ff5bfe06fc14 (diff)
downloadsonarqube-4c20d02a36d8da972e2983e4c02372285c76b153.tar.gz
sonarqube-4c20d02a36d8da972e2983e4c02372285c76b153.zip
SONAR-4453 Added tests to cover permission template application
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/permission/ComponentPermissionFacade.java4
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml2
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml46
-rw-r--r--sonar-core/src/test/java/org/sonar/core/permission/ComponentPermissionFacadeTest.java32
-rw-r--r--sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java34
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template-result.xml34
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template.xml25
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml3
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml5
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml3
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml5
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml3
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml5
13 files changed, 150 insertions, 51 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/permission/ComponentPermissionFacade.java b/sonar-core/src/main/java/org/sonar/core/permission/ComponentPermissionFacade.java
index 177a5c69f5f..e1dcb52b8d8 100644
--- a/sonar-core/src/main/java/org/sonar/core/permission/ComponentPermissionFacade.java
+++ b/sonar-core/src/main/java/org/sonar/core/permission/ComponentPermissionFacade.java
@@ -135,6 +135,7 @@ public class ComponentPermissionFacade implements TaskComponent, ServerComponent
public void applyPermissionTemplate(Long templateId, Long resourceId) {
SqlSession session = myBatis.openSession();
try {
+ removeAllPermissions(resourceId, session);
PermissionTemplateDto permissionTemplate = getPermissionTemplate(templateId);
List<PermissionTemplateUserDto> usersPermissions = permissionTemplate.getUsersPermissions();
if(usersPermissions != null) {
@@ -146,7 +147,8 @@ public class ComponentPermissionFacade implements TaskComponent, ServerComponent
List<PermissionTemplateGroupDto> groupsPermissions = permissionTemplate.getGroupsPermissions();
if(groupsPermissions != null) {
for (PermissionTemplateGroupDto groupPermission : groupsPermissions) {
- addGroupPermission(resourceId, groupPermission.getGroupName(), groupPermission.getPermission(), session);
+ String groupName = groupPermission.getGroupName() == null ? DefaultGroups.ANYONE : groupPermission.getGroupName();
+ addGroupPermission(resourceId, groupName, groupPermission.getPermission(), session);
}
}
session.commit();
diff --git a/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml
index de84f3485bd..4e9dc2d47f0 100644
--- a/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml
@@ -38,6 +38,7 @@
DELETE FROM perm_templates_users
WHERE template_id = #{templateId}
AND user_id = #{userId}
+ AND permission_reference = #{permission}
</delete>
<insert id="insertGroupPermission" parameterType="PermissionTemplateGroup">
@@ -48,6 +49,7 @@
<delete id="deleteGroupPermission" parameterType="PermissionTemplateGroup">
DELETE FROM perm_templates_groups
WHERE template_id = #{templateId}
+ AND permission_reference = #{permission}
AND
<choose>
<when test="groupId != null">
diff --git a/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml
index 3b5f9003cb6..4b3a0ad0599 100644
--- a/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml
@@ -14,89 +14,89 @@
</sql>
<select id="selectUserByLogin" parameterType="string" resultType="User">
- select
+ SELECT
<include refid="userColumns"/>
- from users u where u.login=#{id} and u.active=${_true}
+ FROM users u WHERE u.login=#{id} AND u.active=${_true}
</select>
<select id="selectUsersByLogins" parameterType="map" resultType="User">
- select
+ SELECT
<include refid="userColumns"/>
- from users u where u.login in
+ FROM users u WHERE u.login IN
<foreach item="login" index="index" collection="logins" open="(" separator="," close=")">
#{login}
</foreach>
</select>
<select id="selectUsers" parameterType="map" resultType="User">
- select
+ SELECT
<include refid="userColumns"/>
- from users u
+ FROM users u
<where>
<if test="logins != null and logins.size() > 0">
- u.login in
+ u.login IN
<foreach item="login" index="index" collection="logins" open="(" separator="," close=")">
#{login}
</foreach>
</if>
<if test="includeDeactivated==false">
- and u.active=${_true}
+ AND u.active=${_true}
</if>
<if test="searchText != null">
- and (u.login like #{searchTextSql} escape '/' or u.name like #{searchTextSql} escape '/')
+ AND (u.login LIKE #{searchTextSql} ESCAPE '/' OR u.name LIKE #{searchTextSql} ESCAPE '/')
</if>
</where>
- order by u.name
+ ORDER BY u.name
</select>
<select id="selectGroupByName" parameterType="string" resultType="Group">
- select id, name, description, created_at AS "createdAt", updated_at AS "updatedAt"
- from groups where name=#{id}
+ SELECT id, name, description, created_at AS "createdAt", updated_at AS "updatedAt"
+ FROM groups WHERE name=#{id}
</select>
<delete id="removeUserFromGroups" parameterType="long">
- delete from groups_users where user_id=#{id}
+ DELETE FROM groups_users WHERE user_id=#{id}
</delete>
<delete id="deleteUserRoles" parameterType="long">
- delete from user_roles where user_id=#{id}
+ DELETE FROM user_roles WHERE user_id=#{id}
</delete>
<delete id="deleteUserProperties" parameterType="long">
- delete from properties where user_id=#{id}
+ DELETE FROM properties WHERE user_id=#{id}
</delete>
<delete id="deleteUserDashboards" parameterType="long">
- delete from dashboards where user_id=#{id}
+ DELETE FROM dashboards WHERE user_id=#{id}
</delete>
<delete id="deleteUserActiveDashboards" parameterType="long">
- delete from active_dashboards where user_id=#{id}
+ DELETE FROM active_dashboards WHERE user_id=#{id}
</delete>
<delete id="" parameterType="long">
- delete from user_roles where user_id=#{id}
+ DELETE FROM user_roles WHERE user_id=#{id}
</delete>
<delete id="deleteUserMeasureFilters" parameterType="long">
- delete from measure_filters where user_id=#{id}
+ DELETE FROM measure_filters WHERE user_id=#{id}
</delete>
<delete id="deleteUserMeasureFilterFavourites" parameterType="long">
- delete from measure_filter_favourites where user_id=#{id}
+ DELETE FROM measure_filter_favourites WHERE user_id=#{id}
</delete>
<delete id="deleteUserIssueFilters" parameterType="String">
- delete from issue_filters where user_login=#{id}
+ DELETE FROM issue_filters WHERE user_login=#{id}
</delete>
<delete id="deleteUserIssueFilterFavourites" parameterType="String">
- delete from issue_filter_favourites where user_login=#{id}
+ DELETE FROM issue_filter_favourites WHERE user_login=#{id}
</delete>
<update id="deactivateUser" parameterType="long">
- update users set active=${_false} where id=#{id}
+ UPDATE users SET active=${_false} WHERE id=#{id}
</update>
</mapper>
diff --git a/sonar-core/src/test/java/org/sonar/core/permission/ComponentPermissionFacadeTest.java b/sonar-core/src/test/java/org/sonar/core/permission/ComponentPermissionFacadeTest.java
index 88fca000c36..6760a01ee15 100644
--- a/sonar-core/src/test/java/org/sonar/core/permission/ComponentPermissionFacadeTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/permission/ComponentPermissionFacadeTest.java
@@ -20,5 +20,35 @@
package org.sonar.core.permission;
-public class ComponentPermissionFacadeTest {
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.core.persistence.AbstractDaoTestCase;
+import org.sonar.core.user.PermissionDao;
+import org.sonar.core.user.RoleDao;
+import org.sonar.core.user.UserDao;
+
+public class ComponentPermissionFacadeTest extends AbstractDaoTestCase {
+
+ private ComponentPermissionFacade permissionFacade;
+ private RoleDao roleDao;
+ private UserDao userDao;
+ private PermissionDao permissionDao;
+
+ @Before
+ public void setUp() {
+ roleDao = new RoleDao(getMyBatis());
+ userDao = new UserDao(getMyBatis());
+ permissionDao = new PermissionDao(getMyBatis());
+ permissionFacade = new ComponentPermissionFacade(getMyBatis(), roleDao, userDao, permissionDao);
+ }
+
+ @Test
+ public void should_apply_permission_template() throws Exception {
+ setupData("should_apply_permission_template");
+
+ permissionFacade.applyPermissionTemplate(1L, 123L);
+
+ checkTable("should_apply_permission_template", "group_roles", "group_id", "resource_id", "role");
+ checkTable("should_apply_permission_template", "user_roles", "group_id", "resource_id", "role");
+ }
}
diff --git a/sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java b/sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java
index 6f99afabffc..bfce78a6942 100644
--- a/sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java
@@ -129,8 +129,8 @@ public class PermissionDaoTest extends AbstractDaoTestCase {
permissionDao.deletePermissionTemplate(1L);
checkTable("deletePermissionTemplate", "permission_templates", "id", "name", "description");
- checkTable("deletePermissionTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
- checkTable("deletePermissionTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
+ checkTable("deletePermissionTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission_reference");
+ checkTable("deletePermissionTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission_reference");
}
@Test
@@ -139,18 +139,18 @@ public class PermissionDaoTest extends AbstractDaoTestCase {
permissionDao.addUserPermission(1L, 1L, "new_permission");
checkTable("addUserPermissionToTemplate", "permission_templates", "id", "name", "description");
- checkTable("addUserPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
- checkTable("addUserPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
+ checkTable("addUserPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission_reference");
+ checkTable("addUserPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission_reference");
}
@Test
public void should_remove_user_permission_from_template() throws Exception {
setupData("removeUserPermissionFromTemplate");
- permissionDao.removeUserPermission(1L, 2L, "existing_permission");
+ permissionDao.removeUserPermission(1L, 2L, "permission_to_remove");
checkTable("removeUserPermissionFromTemplate", "permission_templates", "id", "name", "description");
- checkTable("removeUserPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
- checkTable("removeUserPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
+ checkTable("removeUserPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission_reference");
+ checkTable("removeUserPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission_reference");
}
@Test
@@ -159,18 +159,18 @@ public class PermissionDaoTest extends AbstractDaoTestCase {
permissionDao.addGroupPermission(1L, 1L, "new_permission");
checkTable("addGroupPermissionToTemplate", "permission_templates", "id", "name", "description");
- checkTable("addGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
- checkTable("addGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
+ checkTable("addGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission_reference");
+ checkTable("addGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission_reference");
}
@Test
public void should_remove_group_permission_from_template() throws Exception {
setupData("removeGroupPermissionFromTemplate");
- permissionDao.removeGroupPermission(1L, 2L, "existing_permission");
+ permissionDao.removeGroupPermission(1L, 2L, "permission_to_remove");
checkTable("removeGroupPermissionFromTemplate", "permission_templates", "id", "name", "description");
- checkTable("removeGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
- checkTable("removeGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
+ checkTable("removeGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission_reference");
+ checkTable("removeGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission_reference");
}
@Test
@@ -179,17 +179,17 @@ public class PermissionDaoTest extends AbstractDaoTestCase {
permissionDao.addGroupPermission(1L, null, "new_permission");
checkTable("addNullGroupPermissionToTemplate", "permission_templates", "id", "name", "description");
- checkTable("addNullGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
- checkTable("addNullGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
+ checkTable("addNullGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission_reference");
+ checkTable("addNullGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission_reference");
}
@Test
public void should_remove_group_permission_with_null_name() throws Exception {
setupData("removeNullGroupPermissionFromTemplate");
- permissionDao.removeGroupPermission(1L, null, "existing_permission");
+ permissionDao.removeGroupPermission(1L, null, "permission_to_remove");
checkTable("removeNullGroupPermissionFromTemplate", "permission_templates", "id", "name", "description");
- checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
- checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
+ checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission_reference");
+ checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission_reference");
}
}
diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template-result.xml b/sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template-result.xml
new file mode 100644
index 00000000000..ab25beb9f07
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template-result.xml
@@ -0,0 +1,34 @@
+<dataset>
+
+ <groups id="100" name="sonar-administrators" />
+ <groups id="101" name="sonar-users" />
+
+ <users id="200" login="marius" name="Marius" email="[null]" active="[true]" />
+
+ <!-- on other resources -->
+ <group_roles id="1" group_id="100" resource_id="1" role="admin"/>
+ <group_roles id="2" group_id="101" resource_id="1" role="user"/>
+ <user_roles id="1" user_id="200" resource_id="1" role="admin"/>
+
+ <!-- new groups permissions : sonar-administrators (admin), sonar-users (user & codeviewer), Anyone (user & codeviewer) -->
+ <group_roles id="3" group_id="100" resource_id="123" role="admin"/>
+ <group_roles id="4" group_id="101" resource_id="123" role="user"/>
+ <group_roles id="5" group_id="[null]" resource_id="123" role="user"/>
+ <group_roles id="6" group_id="101" resource_id="123" role="codeviewer"/>
+ <group_roles id="7" group_id="[null]" resource_id="123" role="codeviewer"/>
+
+ <!-- new user permission : marius (admin) -->
+ <user_roles id="2" user_id="200" resource_id="123" role="admin"/>
+
+ <!-- default permission template for all qualifiers -->
+ <permission_templates id="1" name="default"/>
+
+ <perm_templates_groups id="1" template_id="1" group_id="100" permission_reference="admin"/>
+ <perm_templates_groups id="2" template_id="1" group_id="101" permission_reference="user"/>
+ <perm_templates_groups id="3" template_id="1" group_id="[null]" permission_reference="user"/>
+ <perm_templates_groups id="4" template_id="1" group_id="101" permission_reference="codeviewer"/>
+ <perm_templates_groups id="5" template_id="1" group_id="[null]" permission_reference="codeviewer"/>
+
+ <perm_templates_users id="1" template_id="1" user_id="200" permission_reference="admin"/>
+
+</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template.xml b/sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template.xml
new file mode 100644
index 00000000000..f962b008ca8
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/permission/ComponentPermissionFacadeTest/should_apply_permission_template.xml
@@ -0,0 +1,25 @@
+<dataset>
+
+ <groups id="100" name="sonar-administrators" />
+ <groups id="101" name="sonar-users" />
+
+ <users id="200" login="marius" name="Marius" email="[null]" active="[true]" />
+
+ <!-- on other resources -->
+ <group_roles id="1" group_id="100" resource_id="1" role="admin"/>
+ <group_roles id="2" group_id="101" resource_id="1" role="user"/>
+ <user_roles id="1" user_id="200" resource_id="1" role="admin"/>
+
+
+ <!-- default permission template for all qualifiers -->
+ <permission_templates id="1" name="default"/>
+
+ <perm_templates_groups id="1" template_id="1" group_id="100" permission_reference="admin"/>
+ <perm_templates_groups id="2" template_id="1" group_id="101" permission_reference="user"/>
+ <perm_templates_groups id="3" template_id="1" group_id="[null]" permission_reference="user"/>
+ <perm_templates_groups id="4" template_id="1" group_id="101" permission_reference="codeviewer"/>
+ <perm_templates_groups id="5" template_id="1" group_id="[null]" permission_reference="codeviewer"/>
+
+ <perm_templates_users id="1" template_id="1" user_id="200" permission_reference="admin"/>
+
+</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml
index d2b04dcce89..33773a8d4e0 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml
@@ -1,5 +1,6 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
<perm_templates_users/>
- <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission_other_group"/>
+ <perm_templates_groups id="3" template_id="1" group_id="2" permission_reference="remaining_permission_same_group"/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml
index 2cb0ab460fd..9df53ee7d2b 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml
@@ -1,6 +1,7 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
<perm_templates_users/>
- <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission"/>
- <perm_templates_groups id="2" template_id="1" group_id="2" permission_reference="existing_permission"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission_other_group"/>
+ <perm_templates_groups id="2" template_id="1" group_id="2" permission_reference="permission_to_remove"/>
+ <perm_templates_groups id="3" template_id="1" group_id="2" permission_reference="remaining_permission_same_group"/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml
index d2b04dcce89..52fd267873b 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml
@@ -1,5 +1,6 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
<perm_templates_users/>
- <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission_other_group"/>
+ <perm_templates_groups id="3" template_id="1" group_id="[null]" permission_reference="remaining_permission_same_group"/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml
index 23bd158f3a1..3e3f93359a2 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml
@@ -1,6 +1,7 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
<perm_templates_users/>
- <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission"/>
- <perm_templates_groups id="2" template_id="1" group_id="[null]" permission_reference="existing_permission"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission_reference="remaining_permission_other_group"/>
+ <perm_templates_groups id="2" template_id="1" group_id="[null]" permission_reference="permission_to_remove"/>
+ <perm_templates_groups id="3" template_id="1" group_id="[null]" permission_reference="remaining_permission_same_group"/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml
index f4c500ba1ff..925a1b25692 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml
@@ -1,7 +1,8 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
- <perm_templates_users id="1" template_id="1" user_id="1" permission_reference="remaining_permission"/>
+ <perm_templates_users id="1" template_id="1" user_id="1" permission_reference="remaining_permission_other_user"/>
+ <perm_templates_users id="3" template_id="1" user_id="2" permission_reference="remaining_permission_same_user"/>
<perm_templates_groups/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml
index 219c1f07286..c160e4edf30 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml
@@ -1,8 +1,9 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
- <perm_templates_users id="1" template_id="1" user_id="1" permission_reference="remaining_permission"/>
- <perm_templates_users id="2" template_id="1" user_id="2" permission_reference="existing_permission"/>
+ <perm_templates_users id="1" template_id="1" user_id="1" permission_reference="remaining_permission_other_user"/>
+ <perm_templates_users id="2" template_id="1" user_id="2" permission_reference="permission_to_remove"/>
+ <perm_templates_users id="3" template_id="1" user_id="2" permission_reference="remaining_permission_same_user"/>
<perm_templates_groups/>
</dataset> \ No newline at end of file