aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>2013-07-04 13:38:22 +0200
committerJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>2013-07-04 13:38:22 +0200
commit67506dbb60457e0634e4aca3d8ca74f2afd8d50e (patch)
tree90116b4dfbc4e7f113789fdac194b1a6899febce /sonar-core
parentda1e8934e2fe8942867299679fe3e6cf9a148f3e (diff)
downloadsonarqube-67506dbb60457e0634e4aca3d8ca74f2afd8d50e.tar.gz
sonarqube-67506dbb60457e0634e4aca3d8ca74f2afd8d50e.zip
SONAR-4463 Updated the permission tables and the permission template select query
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java26
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java21
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java20
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java21
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl2
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml60
-rw-r--r--sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java56
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectAllPermissionTemplates.xml5
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml14
19 files changed, 211 insertions, 42 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java b/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java
index f834ec1d2c7..2e70595ec14 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java
@@ -27,6 +27,7 @@ import org.sonar.core.persistence.MyBatis;
import javax.annotation.Nullable;
import java.util.Date;
+import java.util.List;
public class PermissionDao implements TaskExtension, ServerExtension {
@@ -41,7 +42,9 @@ public class PermissionDao implements TaskExtension, ServerExtension {
SqlSession session = myBatis.openSession();
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
- permissionTemplate = mapper.selectByName(templateName);
+ permissionTemplate = mapper.selectTemplateUsersPermissions(templateName);
+ PermissionTemplateDto templateWithGroupsPermissions = mapper.selectTemplateGroupsPermissions(templateName);
+ permissionTemplate.setGroupsByPermission(templateWithGroupsPermissions.getGroupsPermissions());
session.commit();
} finally {
MyBatis.closeQuietly(session);
@@ -49,6 +52,15 @@ public class PermissionDao implements TaskExtension, ServerExtension {
return permissionTemplate;
}
+ public List<PermissionTemplateDto> selectAllPermissionTemplates() {
+ SqlSession session = myBatis.openSession();
+ try {
+ return session.selectList("selectAllPermissionTemplates");
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
public PermissionTemplateDto createPermissionTemplate(String templateName, @Nullable String description) {
PermissionTemplateDto permissionTemplate = new PermissionTemplateDto()
.setName(templateName)
@@ -66,10 +78,11 @@ public class PermissionDao implements TaskExtension, ServerExtension {
return permissionTemplate;
}
- public void addUserPermission(Long templateId, Long userId) {
+ public void addUserPermission(Long templateId, Long userId, String permission) {
PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto()
.setTemplateId(templateId)
.setUserId(userId)
+ .setPermission(permission)
.setCreatedAt(now())
.setUpdatedAt(now());
SqlSession session = myBatis.openSession();
@@ -82,9 +95,10 @@ public class PermissionDao implements TaskExtension, ServerExtension {
}
}
- public void removeUserPermission(Long templateId, Long userId) {
+ public void removeUserPermission(Long templateId, Long userId, String permission) {
PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto()
.setTemplateId(templateId)
+ .setPermission(permission)
.setUserId(userId);
SqlSession session = myBatis.openSession();
try {
@@ -96,9 +110,10 @@ public class PermissionDao implements TaskExtension, ServerExtension {
}
}
- public void addGroupPermission(Long templateId, @Nullable Long groupId) {
+ public void addGroupPermission(Long templateId, @Nullable Long groupId, String permission) {
PermissionTemplateGroupDto permissionTemplateGroup = new PermissionTemplateGroupDto()
.setTemplateId(templateId)
+ .setPermission(permission)
.setGroupId(groupId)
.setCreatedAt(now())
.setUpdatedAt(now());
@@ -112,9 +127,10 @@ public class PermissionDao implements TaskExtension, ServerExtension {
}
}
- public void removeGroupPermission(Long templateId, @Nullable Long groupId) {
+ public void removeGroupPermission(Long templateId, @Nullable Long groupId, String permission) {
PermissionTemplateGroupDto permissionTemplateGroup = new PermissionTemplateGroupDto()
.setTemplateId(templateId)
+ .setPermission(permission)
.setGroupId(groupId);
SqlSession session = myBatis.openSession();
try {
diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java
index 58fca22abe0..fb235c99e8b 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java
@@ -22,12 +22,15 @@ package org.sonar.core.user;
import javax.annotation.Nullable;
import java.util.Date;
+import java.util.List;
public class PermissionTemplateDto {
private Long id;
private String name;
private String description;
+ private List<PermissionTemplateUserDto> usersPermissions;
+ private List<PermissionTemplateGroupDto> groupsPermissions;
private Date createdAt;
private Date updatedAt;
@@ -58,6 +61,24 @@ public class PermissionTemplateDto {
return this;
}
+ public List<PermissionTemplateUserDto> getUsersPermissions() {
+ return usersPermissions;
+ }
+
+ public PermissionTemplateDto setUsersPermissions(List<PermissionTemplateUserDto> usersPermissions) {
+ this.usersPermissions = usersPermissions;
+ return this;
+ }
+
+ public List<PermissionTemplateGroupDto> getGroupsPermissions() {
+ return groupsPermissions;
+ }
+
+ public PermissionTemplateDto setGroupsByPermission(List<PermissionTemplateGroupDto> groupsPermissions) {
+ this.groupsPermissions = groupsPermissions;
+ return this;
+ }
+
public Date getCreatedAt() {
return createdAt;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java
index 5000ee760f9..157c6f78582 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java
@@ -28,6 +28,8 @@ public class PermissionTemplateGroupDto {
private Long id;
private Long templateId;
private Long groupId;
+ private String permission;
+ private String groupName;
private Date createdAt;
private Date updatedAt;
@@ -58,6 +60,24 @@ public class PermissionTemplateGroupDto {
return this;
}
+ public String getPermission() {
+ return permission;
+ }
+
+ public PermissionTemplateGroupDto setPermission(String permission) {
+ this.permission = permission;
+ return this;
+ }
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+ public PermissionTemplateGroupDto setGroupName(String groupName) {
+ this.groupName = groupName;
+ return this;
+ }
+
public Date getCreatedAt() {
return createdAt;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java
index 772b6e7ef9e..cc0f392e5d2 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java
@@ -27,7 +27,9 @@ public interface PermissionTemplateMapper {
void insert(PermissionTemplateDto permissionTemplate);
- PermissionTemplateDto selectByName(String name);
+ PermissionTemplateDto selectTemplateUsersPermissions(String templateName);
+
+ PermissionTemplateDto selectTemplateGroupsPermissions(String templateName);
void insertUserPermission(PermissionTemplateUserDto permissionTemplateUser);
diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java
index 7ebdc2cd0b1..bb441bcea98 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java
@@ -27,6 +27,8 @@ public class PermissionTemplateUserDto {
private Long id;
private Long templateId;
private Long userId;
+ private String permission;
+ private String userName;
private Date createdAt;
private Date updatedAt;
@@ -57,6 +59,25 @@ public class PermissionTemplateUserDto {
return this;
}
+ public String getUserName() {
+ return userName;
+ }
+
+ public PermissionTemplateUserDto setUserName(String userName) {
+ this.userName = userName;
+ return this;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+
+ public PermissionTemplateUserDto setPermission(String permission) {
+ this.permission = permission;
+ return this;
+ }
+
public Date getCreatedAt() {
return createdAt;
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
index 9924b3780d4..6bf00be3dbb 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
@@ -544,6 +544,7 @@ CREATE TABLE "PERM_TEMPLATES_USERS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"USER_ID" INTEGER NOT NULL,
"TEMPLATE_ID" INTEGER NOT NULL,
+ "PERMISSION" VARCHAR(64) NOT NULL,
"CREATED_AT" TIMESTAMP,
"UPDATED_AT" TIMESTAMP
);
@@ -552,6 +553,7 @@ CREATE TABLE "PERM_TEMPLATES_GROUPS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"GROUP_ID" INTEGER,
"TEMPLATE_ID" INTEGER NOT NULL,
+ "PERMISSION" VARCHAR(64) NOT NULL,
"CREATED_AT" TIMESTAMP,
"UPDATED_AT" TIMESTAMP
);
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 5876cda0f7e..ee260ea609b 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
@@ -9,8 +9,8 @@
</insert>
<insert id="insertUserPermission" parameterType="PermissionTemplateUser">
- INSERT INTO perm_templates_users (template_id, user_id, created_at, updated_at)
- VALUES (#{templateId}, #{userId}, #{createdAt}, #{updatedAt})
+ INSERT INTO perm_templates_users (template_id, user_id, permission, created_at, updated_at)
+ VALUES (#{templateId}, #{userId}, #{permission}, #{createdAt}, #{updatedAt})
</insert>
<delete id="deleteUserPermission" parameterType="PermissionTemplateUser">
@@ -20,8 +20,8 @@
</delete>
<insert id="insertGroupPermission" parameterType="PermissionTemplateGroup">
- INSERT INTO perm_templates_groups (template_id, group_id, created_at, updated_at)
- VALUES (#{templateId}, #{groupId}, #{createdAt}, #{updatedAt})
+ INSERT INTO perm_templates_groups (template_id, group_id, permission, created_at, updated_at)
+ VALUES (#{templateId}, #{groupId}, #{permission}, #{createdAt}, #{updatedAt})
</insert>
<delete id="deleteGroupPermission" parameterType="PermissionTemplateGroup">
@@ -38,9 +38,57 @@
</choose>
</delete>
- <select id="selectByName" parameterType="string" resultType="PermissionTemplate">
+ <select id="selectAllPermissionTemplates" resultType="PermissionTemplate">
SELECT id, name, description, created_at AS createdAt, updated_at AS updatedAt
- FROM permission_templates WHERE name=#{name}
+ FROM permission_templates
</select>
+ <select id="selectTemplateUsersPermissions" parameterType="String" resultMap="fullPermissionsTemplateResult">
+ SELECT pt.id AS template_id,
+ pt.name AS template_name,
+ pt.description AS template_description,
+ pt.created_at AS template_created_at,
+ pt.updated_at AS template_updated_at,
+ ptu.id AS permission_template_user_id,
+ ptu.permission AS user_permission,
+ u.name AS user_name
+ FROM permission_templates AS pt
+ INNER JOIN perm_templates_users AS ptu ON ptu.template_id = pt.id
+ INNER JOIN users AS u ON u.id = ptu.user_id
+ WHERE pt.name = #{templateName}
+ </select>
+
+ <select id="selectTemplateGroupsPermissions" parameterType="String" resultMap="fullPermissionsTemplateResult">
+ SELECT pt.id AS template_id,
+ pt.name AS template_name,
+ pt.description AS template_description,
+ pt.created_at AS template_created_at,
+ pt.updated_at AS template_updated_at,
+ ptg.id AS permission_template_group_id,
+ ptg.permission AS group_permission,
+ g.name AS group_name
+ FROM permission_templates AS pt
+ INNER JOIN perm_templates_groups AS ptg ON ptg.template_id = pt.id
+ LEFT OUTER JOIN groups AS g ON g.id = ptg.group_id
+ WHERE pt.name = #{templateName}
+ </select>
+
+ <resultMap id="fullPermissionsTemplateResult" type="PermissionTemplate">
+ <id property="id" column="template_id" />
+ <result property="name" column="template_name"/>
+ <result property="description" column="template_description"/>
+ <result property="createdAt" column="template_created_at"/>
+ <result property="updatedAt" column="template_updated_at"/>
+ <collection property="usersPermissions" ofType="PermissionTemplateUser">
+ <id property="id" column="permission_template_user_id"/>
+ <result property="permission" column="user_permission"/>
+ <result property="userName" column="user_name"/>
+ </collection>
+ <collection property="groupsPermissions" ofType="PermissionTemplateGroup">
+ <id property="id" column="permission_template_group_id"/>
+ <result property="permission" column="group_permission"/>
+ <result property="groupName" column="group_name"/>
+ </collection>
+ </resultMap>
+
</mapper>
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 6a81efda50b..205c9365cfb 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
@@ -24,6 +24,8 @@ import org.junit.Before;
import org.junit.Test;
import org.sonar.core.persistence.AbstractDaoTestCase;
+import java.util.List;
+
import static org.fest.assertions.Assertions.assertThat;
public class PermissionDaoTest extends AbstractDaoTestCase {
@@ -52,65 +54,83 @@ public class PermissionDaoTest extends AbstractDaoTestCase {
assertThat(permissionTemplate).isNotNull();
assertThat(permissionTemplate.getName()).isEqualTo("my template");
assertThat(permissionTemplate.getDescription()).isEqualTo("my description");
+ assertThat(permissionTemplate.getUsersPermissions()).hasSize(3);
+ assertThat(permissionTemplate.getUsersPermissions()).onProperty("userName").containsOnly("user1", "user2", "user2");
+ assertThat(permissionTemplate.getUsersPermissions()).onProperty("permission").containsOnly("user_permission1", "user_permission1", "user_permission2");
+ assertThat(permissionTemplate.getGroupsPermissions()).hasSize(3);
+ assertThat(permissionTemplate.getGroupsPermissions()).onProperty("groupName").containsOnly("group1", "group2", null);
+ assertThat(permissionTemplate.getGroupsPermissions()).onProperty("permission").containsOnly("group_permission1", "group_permission1", "group_permission2");
+ }
+
+ @Test
+ public void should_select_all_permission_templates() throws Exception {
+ setupData("selectAllPermissionTemplates");
+
+ List<PermissionTemplateDto> permissionTemplates = permissionDao.selectAllPermissionTemplates();
+
+ assertThat(permissionTemplates).hasSize(3);
+ assertThat(permissionTemplates).onProperty("id").containsOnly(1L, 2L, 3L);
+ assertThat(permissionTemplates).onProperty("name").containsOnly("template1", "template2", "template3");
+ assertThat(permissionTemplates).onProperty("description").containsOnly("description1", "description2", "description3");
}
@Test
public void should_add_user_permission_to_template() throws Exception {
setupData("addUserPermissionToTemplate");
- permissionDao.addUserPermission(1L, 1L);
+ permissionDao.addUserPermission(1L, 1L, "new_permission");
checkTable("addUserPermissionToTemplate", "permission_templates", "id", "name", "description");
- checkTable("addUserPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id");
- checkTable("addUserPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id");
+ checkTable("addUserPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
+ checkTable("addUserPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
}
@Test
public void should_remove_user_permission_from_template() throws Exception {
setupData("removeUserPermissionFromTemplate");
- permissionDao.removeUserPermission(1L, 2L);
+ permissionDao.removeUserPermission(1L, 2L, "existing_permission");
checkTable("removeUserPermissionFromTemplate", "permission_templates", "id", "name", "description");
- checkTable("removeUserPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id");
- checkTable("removeUserPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id");
+ checkTable("removeUserPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
+ checkTable("removeUserPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
}
@Test
public void should_add_group_permission_to_template() throws Exception {
setupData("addGroupPermissionToTemplate");
- permissionDao.addGroupPermission(1L, 1L);
+ permissionDao.addGroupPermission(1L, 1L, "new_permission");
checkTable("addGroupPermissionToTemplate", "permission_templates", "id", "name", "description");
- checkTable("addGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id");
- checkTable("addGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id");
+ checkTable("addGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
+ checkTable("addGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
}
@Test
public void should_remove_group_permission_from_template() throws Exception {
setupData("removeGroupPermissionFromTemplate");
- permissionDao.removeGroupPermission(1L, 2L);
+ permissionDao.removeGroupPermission(1L, 2L, "existing_permission");
checkTable("removeGroupPermissionFromTemplate", "permission_templates", "id", "name", "description");
- checkTable("removeGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id");
- checkTable("removeGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id");
+ checkTable("removeGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
+ checkTable("removeGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
}
@Test
public void should_add_group_permission_with_null_name() throws Exception {
setupData("addNullGroupPermissionToTemplate");
- permissionDao.addGroupPermission(1L, null);
+ permissionDao.addGroupPermission(1L, null, "new_permission");
checkTable("addNullGroupPermissionToTemplate", "permission_templates", "id", "name", "description");
- checkTable("addNullGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id");
- checkTable("addNullGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id");
+ checkTable("addNullGroupPermissionToTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
+ checkTable("addNullGroupPermissionToTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
}
@Test
public void should_remove_group_permission_with_null_name() throws Exception {
setupData("removeNullGroupPermissionFromTemplate");
- permissionDao.removeGroupPermission(1L, null);
+ permissionDao.removeGroupPermission(1L, null, "existing_permission");
checkTable("removeNullGroupPermissionFromTemplate", "permission_templates", "id", "name", "description");
- checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id");
- checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id");
+ checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_users", "id", "template_id", "user_id", "permission");
+ checkTable("removeNullGroupPermissionFromTemplate", "perm_templates_groups", "id", "template_id", "group_id", "permission");
}
}
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate-result.xml
index 55f6631b4bd..b7b0225d345 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate-result.xml
@@ -1,5 +1,5 @@
<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"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission="new_permission"/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml
index 28a40c594b9..fda5cefa69b 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml
@@ -1,5 +1,5 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
<perm_templates_users/>
- <perm_templates_groups id="1" template_id="1" group_id="[null]"/>
+ <perm_templates_groups id="1" template_id="1" group_id="[null]" permission="new_permission"/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate-result.xml
index c691de7ca4b..3f243536113 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate-result.xml
@@ -1,5 +1,5 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
- <perm_templates_users id="1" template_id="1" user_id="1"/>
+ <perm_templates_users id="1" template_id="1" user_id="1" permission="new_permission"/>
<perm_templates_groups/>
</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 55f6631b4bd..1d43ca22fea 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,5 @@
<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"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission="remaining_permission"/>
</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 af9c26e2a75..06e5322a5d3 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,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"/>
- <perm_templates_groups id="2" template_id="1" group_id="2"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission="remaining_permission"/>
+ <perm_templates_groups id="2" template_id="1" group_id="2" permission="existing_permission"/>
</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 55f6631b4bd..1d43ca22fea 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,5 @@
<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"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission="remaining_permission"/>
</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 c438548850b..095449a77b6 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,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"/>
- <perm_templates_groups id="2" template_id="1" group_id="[null]"/>
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission="remaining_permission"/>
+ <perm_templates_groups id="2" template_id="1" group_id="[null]" permission="existing_permission"/>
</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 11cf1aeeafc..68bf04077f4 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,7 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
- <perm_templates_users id="1" template_id="1" user_id="1"/>
+ <perm_templates_users id="1" template_id="1" user_id="1" permission="remaining_permission"/>
<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 e48d90f3df6..69427d2d3bf 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,8 @@
<dataset>
<permission_templates id="1" name="my template" description="my description"/>
- <perm_templates_users id="1" template_id="1" user_id="1"/>
- <perm_templates_users id="2" template_id="1" user_id="2"/>
+ <perm_templates_users id="1" template_id="1" user_id="1" permission="remaining_permission"/>
+ <perm_templates_users id="2" template_id="1" user_id="2" permission="existing_permission"/>
<perm_templates_groups/>
</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectAllPermissionTemplates.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectAllPermissionTemplates.xml
new file mode 100644
index 00000000000..fc6e8c15234
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectAllPermissionTemplates.xml
@@ -0,0 +1,5 @@
+<dataset>
+ <permission_templates id="1" name="template1" description="description1" created_at="[null]" updated_at="[null]"/>
+ <permission_templates id="2" name="template2" description="description2" created_at="[null]" updated_at="[null]"/>
+ <permission_templates id="3" name="template3" description="description3" created_at="[null]" updated_at="[null]"/>
+</dataset> \ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml
index ff512b88358..0de01c53486 100644
--- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml
@@ -1,3 +1,17 @@
<dataset>
<permission_templates id="1" name="my template" description="my description" created_at="[null]" updated_at="[null]"/>
+
+ <perm_templates_users id="1" template_id="1" user_id="1" permission="user_permission1"/>
+ <perm_templates_users id="2" template_id="1" user_id="2" permission="user_permission1"/>
+ <perm_templates_users id="3" template_id="1" user_id="2" permission="user_permission2"/>
+
+ <users id="1" login="user1" name="user1" />
+ <users id="2" login="user2" name="user2" />
+
+ <perm_templates_groups id="1" template_id="1" group_id="1" permission="group_permission1"/>
+ <perm_templates_groups id="2" template_id="1" group_id="2" permission="group_permission1"/>
+ <perm_templates_groups id="3" template_id="1" group_id="[null]" permission="group_permission2"/>
+
+ <groups id="1" name="group1"/>
+ <groups id="2" name="group2"/>
</dataset> \ No newline at end of file