From 2dc9ca437d7bade2a56cd2e0ec7559aee6c58ecb Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Vilain Date: Fri, 12 Jul 2013 18:01:48 +0200 Subject: [PATCH] SONAR-4453 Added a logical key in the permission_templates table and rearranged permission-related classes --- .../org/sonar/core/date/DateProvider.java | 31 +++++++++++++++++++ .../sonar/core/date/DefaultDateProvider.java | 31 +++++++++++++++++++ .../core/{user => permission}/Permission.java | 2 +- .../{user => permission}/PermissionDao.java | 28 +++++++++++++---- .../PermissionTemplateDto.java | 12 ++++++- .../PermissionTemplateGroupDto.java | 2 +- .../PermissionTemplateMapper.java | 2 +- .../PermissionTemplateUserDto.java | 2 +- .../org/sonar/core/persistence/DaoUtils.java | 6 +++- .../org/sonar/core/persistence/MyBatis.java | 4 +++ .../resource/DefaultResourcePermissions.java | 6 ++-- .../PermissionTemplateMapper.xml | 6 ++-- .../org/sonar/core/persistence/rows-h2.sql | 2 +- .../org/sonar/core/persistence/schema-h2.ddl | 1 + .../ComponentPermissionFacadeTest.java | 1 - .../PermissionDaoTest.java | 27 +++++++++++++--- .../DefaultResourcePermissionsTest.java | 2 +- .../java/org/sonar/core/user/RoleDaoTest.java | 1 + ...hould_apply_permission_template-result.xml | 2 +- .../should_apply_permission_template.xml | 2 +- .../addGroupPermissionToTemplate-result.xml | 2 +- .../addGroupPermissionToTemplate.xml | 5 +++ ...ddNullGroupPermissionToTemplate-result.xml | 2 +- .../addNullGroupPermissionToTemplate.xml | 5 +++ .../addUserPermissionToTemplate-result.xml | 2 +- .../addUserPermissionToTemplate.xml | 5 +++ ...reateNonAsciiPermissionTemplate-result.xml | 3 ++ .../createNonAsciiPermissionTemplate.xml} | 0 .../createPermissionTemplate-result.xml | 3 ++ .../createPermissionTemplate.xml | 1 + .../deletePermissionTemplate-result.xml | 7 +++++ .../deletePermissionTemplate.xml | 4 +-- ...moveGroupPermissionFromTemplate-result.xml | 2 +- .../removeGroupPermissionFromTemplate.xml | 2 +- ...NullGroupPermissionFromTemplate-result.xml | 2 +- .../removeNullGroupPermissionFromTemplate.xml | 2 +- ...emoveUserPermissionFromTemplate-result.xml | 2 +- .../removeUserPermissionFromTemplate.xml | 2 +- .../selectAllPermissionTemplates.xml | 5 +++ .../selectEmptyPermissionTemplate.xml | 2 +- .../selectPermissionTemplate.xml | 2 +- .../updatePermissionTemplate-result.xml | 4 +++ .../updatePermissionTemplate.xml | 4 +++ .../should_copy_permission_templates.xml | 2 +- .../grantDefaultRoles-result.xml | 2 +- .../grantDefaultRoles.xml | 2 +- .../grantDefaultRolesProject.xml | 4 +-- ...grantDefaultRoles_unknown_group-result.xml | 2 +- .../grantDefaultRoles_unknown_group.xml | 2 +- .../grantDefaultRoles_users-result.xml | 2 +- .../grantDefaultRoles_users.xml | 2 +- .../addGroupPermissionToTemplate.xml | 5 --- .../addNullGroupPermissionToTemplate.xml | 5 --- .../addUserPermissionToTemplate.xml | 5 --- .../createPermissionTemplate-result.xml | 3 -- .../deletePermissionTemplate-result.xml | 7 ----- .../selectAllPermissionTemplates.xml | 5 --- .../updatePermissionTemplate-result.xml | 4 --- .../updatePermissionTemplate.xml | 4 --- .../server/issue/IssueFilterService.java | 3 +- .../permission/InternalPermissionService.java | 1 + .../InternalPermissionTemplateService.java | 4 +-- .../permission/PermissionChangeQuery.java | 2 +- .../server/permission/PermissionTemplate.java | 6 ++-- .../permission/PermissionTemplateUpdater.java | 7 ++++- .../sonar/server/user/DefaultUserService.java | 3 +- .../org/sonar/server/user/UserSession.java | 3 +- .../415_create_permission_templates.rb | 1 + .../server/issue/IssueFilterServiceTest.java | 2 +- .../InternalPermissionServiceTest.java | 1 + ...InternalPermissionTemplateServiceTest.java | 5 ++- .../permission/PermissionChangeQueryTest.java | 2 +- .../permission/PermissionTemplateTest.java | 6 ++-- .../PermissionTemplateUpdaterTest.java | 7 ++++- .../server/user/DefaultUserServiceTest.java | 8 ++--- .../sonar/server/user/MockUserSession.java | 3 +- .../sonar/server/user/UserSessionTest.java | 2 +- 77 files changed, 244 insertions(+), 116 deletions(-) create mode 100644 sonar-core/src/main/java/org/sonar/core/date/DateProvider.java create mode 100644 sonar-core/src/main/java/org/sonar/core/date/DefaultDateProvider.java rename sonar-core/src/main/java/org/sonar/core/{user => permission}/Permission.java (98%) rename sonar-core/src/main/java/org/sonar/core/{user => permission}/PermissionDao.java (88%) rename sonar-core/src/main/java/org/sonar/core/{user => permission}/PermissionTemplateDto.java (93%) rename sonar-core/src/main/java/org/sonar/core/{user => permission}/PermissionTemplateGroupDto.java (98%) rename sonar-core/src/main/java/org/sonar/core/{user => permission}/PermissionTemplateMapper.java (98%) rename sonar-core/src/main/java/org/sonar/core/{user => permission}/PermissionTemplateUserDto.java (98%) rename sonar-core/src/main/resources/org/sonar/core/{user => permission}/PermissionTemplateMapper.xml (95%) rename sonar-core/src/test/java/org/sonar/core/{user => permission}/PermissionDaoTest.java (89%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/addGroupPermissionToTemplate-result.xml (52%) create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addGroupPermissionToTemplate.xml rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml (53%) create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addNullGroupPermissionToTemplate.xml rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/addUserPermissionToTemplate-result.xml (52%) create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addUserPermissionToTemplate.xml create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createNonAsciiPermissionTemplate-result.xml rename sonar-core/src/test/resources/org/sonar/core/{user/PermissionDaoTest/createPermissionTemplate.xml => permission/PermissionDaoTest/createNonAsciiPermissionTemplate.xml} (100%) create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate-result.xml create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate.xml create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/deletePermissionTemplate-result.xml rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/deletePermissionTemplate.xml (65%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml (68%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/removeGroupPermissionFromTemplate.xml (75%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml (68%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml (75%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml (68%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/removeUserPermissionFromTemplate.xml (75%) create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectAllPermissionTemplates.xml rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/selectEmptyPermissionTemplate.xml (50%) rename sonar-core/src/test/resources/org/sonar/core/{user => permission}/PermissionDaoTest/selectPermissionTemplate.xml (85%) create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate-result.xml create mode 100644 sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/createPermissionTemplate-result.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/deletePermissionTemplate-result.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectAllPermissionTemplates.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate-result.xml delete mode 100644 sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate.xml diff --git a/sonar-core/src/main/java/org/sonar/core/date/DateProvider.java b/sonar-core/src/main/java/org/sonar/core/date/DateProvider.java new file mode 100644 index 00000000000..f6fd58faa39 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/date/DateProvider.java @@ -0,0 +1,31 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.core.date; + +import java.util.Date; + +/** + * @since 3.7 + */ +public interface DateProvider { + + Date now(); +} diff --git a/sonar-core/src/main/java/org/sonar/core/date/DefaultDateProvider.java b/sonar-core/src/main/java/org/sonar/core/date/DefaultDateProvider.java new file mode 100644 index 00000000000..eb716b2d57d --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/date/DefaultDateProvider.java @@ -0,0 +1,31 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.core.date; + +import java.util.Date; + +public class DefaultDateProvider implements DateProvider { + + @Override + public Date now() { + return new Date(); + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/user/Permission.java b/sonar-core/src/main/java/org/sonar/core/permission/Permission.java similarity index 98% rename from sonar-core/src/main/java/org/sonar/core/user/Permission.java rename to sonar-core/src/main/java/org/sonar/core/permission/Permission.java index 98bb97723a8..bf8fd3d2e06 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/Permission.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/Permission.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.user; +package org.sonar.core.permission; import java.util.LinkedHashMap; import java.util.Map; diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java similarity index 88% rename from sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java rename to sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java index bad927a8e50..43555999195 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java @@ -18,25 +18,34 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.user; +package org.sonar.core.permission; +import org.apache.commons.lang.time.DateFormatUtils; import org.apache.ibatis.session.SqlSession; import org.sonar.api.ServerComponent; import org.sonar.api.task.TaskComponent; +import org.sonar.core.date.DateProvider; +import org.sonar.core.date.DefaultDateProvider; import org.sonar.core.persistence.MyBatis; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - +import java.text.Normalizer; import java.util.Date; import java.util.List; public class PermissionDao implements TaskComponent, ServerComponent { private final MyBatis myBatis; + private final DateProvider dateProvider; - public PermissionDao(MyBatis myBatis) { + public PermissionDao(MyBatis myBatis, DateProvider dateProvider) { this.myBatis = myBatis; + this.dateProvider = dateProvider; + } + + public PermissionDao(MyBatis myBatis) { + this(myBatis, new DefaultDateProvider()); } @CheckForNull @@ -93,11 +102,13 @@ public class PermissionDao implements TaskComponent, ServerComponent { } public PermissionTemplateDto createPermissionTemplate(String templateName, @Nullable String description) { + Date creationDate = now(); PermissionTemplateDto permissionTemplate = new PermissionTemplateDto() .setName(templateName) + .setKee(generateTemplateKee(templateName, creationDate)) .setDescription(description) - .setCreatedAt(now()) - .setUpdatedAt(now()); + .setCreatedAt(creationDate) + .setUpdatedAt(creationDate); SqlSession session = myBatis.openSession(); try { PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class); @@ -202,7 +213,12 @@ public class PermissionDao implements TaskComponent, ServerComponent { } } + private String generateTemplateKee(String name, Date timeStamp) { + String normalizedName = Normalizer.normalize(name, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "").replace(" ", "_"); + return normalizedName.toLowerCase() + "_" + DateFormatUtils.format(timeStamp, "yyyyMMdd_HHmmss"); + } + private Date now() { - return new Date(); + return dateProvider.now(); } } diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDto.java similarity index 93% rename from sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java rename to sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDto.java index 93db1524086..6eead5a1cc8 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateDto.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDto.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.user; +package org.sonar.core.permission; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -29,6 +29,7 @@ public class PermissionTemplateDto { private Long id; private String name; + private String kee; private String description; private List usersPermissions; private List groupsPermissions; @@ -53,6 +54,15 @@ public class PermissionTemplateDto { return this; } + public String getKee() { + return kee; + } + + public PermissionTemplateDto setKee(String kee) { + this.kee = kee; + return this; + } + @CheckForNull public String getDescription() { return description; diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateGroupDto.java similarity index 98% rename from sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java rename to sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateGroupDto.java index 157c6f78582..a2818d13ddf 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateGroupDto.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateGroupDto.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.user; +package org.sonar.core.permission; import javax.annotation.Nullable; import java.util.Date; diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateMapper.java similarity index 98% rename from sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java rename to sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateMapper.java index 8f00c507968..f14df167170 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateMapper.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.user; +package org.sonar.core.permission; /** * @since 3.7 diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateUserDto.java similarity index 98% rename from sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java rename to sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateUserDto.java index b0fa21a952b..62014458d2e 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateUserDto.java +++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateUserDto.java @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.user; +package org.sonar.core.permission; import java.util.Date; diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java index 1798e89e920..3027aada8fa 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java @@ -26,6 +26,7 @@ import org.sonar.core.duplication.DuplicationDao; import org.sonar.core.graph.jdbc.GraphDao; import org.sonar.core.issue.db.*; import org.sonar.core.measure.MeasureFilterDao; +import org.sonar.core.permission.PermissionDao; import org.sonar.core.properties.PropertiesDao; import org.sonar.core.purge.PurgeDao; import org.sonar.core.resource.ResourceDao; @@ -34,7 +35,10 @@ import org.sonar.core.resource.ResourceKeyUpdaterDao; import org.sonar.core.rule.RuleDao; import org.sonar.core.source.jdbc.SnapshotDataDao; import org.sonar.core.template.LoadedTemplateDao; -import org.sonar.core.user.*; +import org.sonar.core.user.AuthorDao; +import org.sonar.core.user.AuthorizationDao; +import org.sonar.core.user.RoleDao; +import org.sonar.core.user.UserDao; import java.util.List; diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index e5e4c015a9c..19a9ecbbf57 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -47,6 +47,10 @@ import org.sonar.core.graph.jdbc.GraphDtoMapper; import org.sonar.core.issue.db.*; import org.sonar.core.measure.MeasureFilterDto; import org.sonar.core.measure.MeasureFilterMapper; +import org.sonar.core.permission.PermissionTemplateDto; +import org.sonar.core.permission.PermissionTemplateGroupDto; +import org.sonar.core.permission.PermissionTemplateMapper; +import org.sonar.core.permission.PermissionTemplateUserDto; import org.sonar.core.properties.PropertiesMapper; import org.sonar.core.properties.PropertyDto; import org.sonar.core.purge.PurgeMapper; diff --git a/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java b/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java index eeec2bbebef..d5dcbc4fe03 100644 --- a/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java +++ b/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java @@ -27,10 +27,10 @@ import org.sonar.api.security.DefaultGroups; import org.sonar.api.security.ResourcePermissions; import org.sonar.api.web.UserRole; import org.sonar.core.permission.ComponentPermissionFacade; +import org.sonar.core.permission.PermissionTemplateDto; +import org.sonar.core.permission.PermissionTemplateGroupDto; +import org.sonar.core.permission.PermissionTemplateUserDto; import org.sonar.core.persistence.MyBatis; -import org.sonar.core.user.PermissionTemplateDto; -import org.sonar.core.user.PermissionTemplateGroupDto; -import org.sonar.core.user.PermissionTemplateUserDto; import java.util.ArrayList; import java.util.List; diff --git a/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml b/sonar-core/src/main/resources/org/sonar/core/permission/PermissionTemplateMapper.xml similarity index 95% rename from sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml rename to sonar-core/src/main/resources/org/sonar/core/permission/PermissionTemplateMapper.xml index 4e9dc2d47f0..525f2c8ee74 100644 --- a/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/permission/PermissionTemplateMapper.xml @@ -1,11 +1,11 @@ - + - INSERT INTO permission_templates (name, description, created_at, updated_at) - VALUES (#{name}, #{description}, #{createdAt}, #{updatedAt}) + INSERT INTO permission_templates (name, kee, description, created_at, updated_at) + VALUES (#{name}, #{kee}, #{description}, #{createdAt}, #{updatedAt}) diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index e55347bdf3b..92f82950400 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -15,7 +15,7 @@ INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 1); INSERT INTO GROUPS_USERS(USER_ID, GROUP_ID) VALUES (1, 2); -- Default permissions - Replaces the previous role-based properties such as 'sonar.role.admin.TRK.defaultGroups' (see migration 418) -INSERT INTO PERMISSION_TEMPLATES(ID, name, description) VALUES (1, 'Default template', 'This permission template will be used as default when no other permission configuration is available'); +INSERT INTO PERMISSION_TEMPLATES(ID, name, kee, description) VALUES (1, 'Default template', 'default_template', 'This permission template will be used as default when no other permission configuration is available'); ALTER TABLE PERMISSION_TEMPLATES ALTER COLUMN ID RESTART WITH 2; INSERT INTO PERM_TEMPLATES_GROUPS(ID, template_id, group_id, permission_reference) VALUES (1, 1, 1, 'admin'); 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 2624837ac89..b450b85b834 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 @@ -535,6 +535,7 @@ CREATE TABLE "SNAPSHOT_DATA" ( CREATE TABLE "PERMISSION_TEMPLATES" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "NAME" VARCHAR(100) NOT NULL, + "KEE" VARCHAR(100) NOT NULL, "DESCRIPTION" VARCHAR(4000), "CREATED_AT" TIMESTAMP, "UPDATED_AT" TIMESTAMP 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 6760a01ee15..7259c8b7ff2 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 @@ -23,7 +23,6 @@ package org.sonar.core.permission; 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; diff --git a/sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java b/sonar-core/src/test/java/org/sonar/core/permission/PermissionDaoTest.java similarity index 89% rename from sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java rename to sonar-core/src/test/java/org/sonar/core/permission/PermissionDaoTest.java index bfce78a6942..9cf31e25f27 100644 --- a/sonar-core/src/test/java/org/sonar/core/user/PermissionDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/permission/PermissionDaoTest.java @@ -18,23 +18,33 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.core.user; +package org.sonar.core.permission; import org.junit.Before; import org.junit.Test; +import org.sonar.api.utils.DateUtils; +import org.sonar.core.date.DateProvider; import org.sonar.core.persistence.AbstractDaoTestCase; +import java.util.Date; import java.util.List; import static org.fest.assertions.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.stub; public class PermissionDaoTest extends AbstractDaoTestCase { + private final Date now = DateUtils.parseDateTime("2013-01-02T03:04:05+0100"); + private PermissionDao permissionDao; + private DateProvider dateProvider; @Before public void setUpDao() { - permissionDao = new PermissionDao(getMyBatis()); + dateProvider = mock(DateProvider.class); + stub(dateProvider.now()).toReturn(now); + permissionDao = new PermissionDao(getMyBatis(), dateProvider); } @Test @@ -43,7 +53,16 @@ public class PermissionDaoTest extends AbstractDaoTestCase { PermissionTemplateDto permissionTemplate = permissionDao.createPermissionTemplate("my template", "my description"); assertThat(permissionTemplate).isNotNull(); assertThat(permissionTemplate.getId()).isEqualTo(1L); - checkTable("createPermissionTemplate", "permission_templates", "id", "name", "description"); + checkTable("createPermissionTemplate", "permission_templates", "id", "name", "kee", "description"); + } + + @Test + public void should_normalize_kee_on_template_creation() throws Exception { + setupData("createNonAsciiPermissionTemplate"); + PermissionTemplateDto permissionTemplate = permissionDao.createPermissionTemplate("Môü Gnô Gnèçàß", "my description"); + assertThat(permissionTemplate).isNotNull(); + assertThat(permissionTemplate.getId()).isEqualTo(1L); + checkTable("createNonAsciiPermissionTemplate", "permission_templates", "id", "name", "kee", "description"); } @Test @@ -119,7 +138,7 @@ public class PermissionDaoTest extends AbstractDaoTestCase { permissionDao.updatePermissionTemplate(1L, "new_name", "new_description"); - checkTable("updatePermissionTemplate", "permission_templates", "id", "name", "description"); + checkTable("updatePermissionTemplate", "permission_templates", "id", "name", "kee", "description"); } @Test diff --git a/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java b/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java index 5a6fc165002..c39e89527c1 100644 --- a/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java +++ b/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java @@ -28,8 +28,8 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.security.DefaultGroups; import org.sonar.core.permission.ComponentPermissionFacade; +import org.sonar.core.permission.PermissionDao; import org.sonar.core.persistence.AbstractDaoTestCase; -import org.sonar.core.user.PermissionDao; import org.sonar.core.user.RoleDao; import org.sonar.core.user.UserDao; 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 582616cc5a6..6d0c9b0830e 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 @@ -22,6 +22,7 @@ package org.sonar.core.user; import org.junit.Test; import org.sonar.api.security.DefaultGroups; +import org.sonar.core.permission.Permission; import org.sonar.core.persistence.AbstractDaoTestCase; import static org.fest.assertions.Assertions.assertThat; 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 index ab25beb9f07..c512d7e3a61 100644 --- 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 @@ -21,7 +21,7 @@ - + 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 index f962b008ca8..2c9dd6309fd 100644 --- 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 @@ -12,7 +12,7 @@ - + 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/permission/PermissionDaoTest/addGroupPermissionToTemplate-result.xml similarity index 52% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate-result.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addGroupPermissionToTemplate-result.xml index ae1db0b574e..c80216743b1 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addGroupPermissionToTemplate-result.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addGroupPermissionToTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addGroupPermissionToTemplate.xml new file mode 100644 index 00000000000..6645e851711 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addGroupPermissionToTemplate.xml @@ -0,0 +1,5 @@ + + + + + \ 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/permission/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml similarity index 53% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml index 4fe3b439832..7d42701d39f 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addNullGroupPermissionToTemplate-result.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addNullGroupPermissionToTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addNullGroupPermissionToTemplate.xml new file mode 100644 index 00000000000..6645e851711 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addNullGroupPermissionToTemplate.xml @@ -0,0 +1,5 @@ + + + + + \ 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/permission/PermissionDaoTest/addUserPermissionToTemplate-result.xml similarity index 52% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate-result.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addUserPermissionToTemplate-result.xml index 8676d568d5e..40bf5d45d4e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addUserPermissionToTemplate-result.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addUserPermissionToTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addUserPermissionToTemplate.xml new file mode 100644 index 00000000000..6645e851711 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/addUserPermissionToTemplate.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createNonAsciiPermissionTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createNonAsciiPermissionTemplate-result.xml new file mode 100644 index 00000000000..962c1d62f61 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createNonAsciiPermissionTemplate-result.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/createPermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createNonAsciiPermissionTemplate.xml similarity index 100% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/createPermissionTemplate.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createNonAsciiPermissionTemplate.xml diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate-result.xml new file mode 100644 index 00000000000..0fbf6524539 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate-result.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate.xml new file mode 100644 index 00000000000..5ed00ba028b --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/createPermissionTemplate.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/deletePermissionTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/deletePermissionTemplate-result.xml new file mode 100644 index 00000000000..06f6413de31 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/deletePermissionTemplate-result.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/deletePermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/deletePermissionTemplate.xml similarity index 65% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/deletePermissionTemplate.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/deletePermissionTemplate.xml index 61c40436844..b5a8064cd11 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/deletePermissionTemplate.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/deletePermissionTemplate.xml @@ -1,6 +1,6 @@ - - + + 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/permission/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml similarity index 68% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml index 33773a8d4e0..140738df7db 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeGroupPermissionFromTemplate-result.xml @@ -1,5 +1,5 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeGroupPermissionFromTemplate.xml similarity index 75% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeGroupPermissionFromTemplate.xml index 9df53ee7d2b..3258dcc22e5 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeGroupPermissionFromTemplate.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeGroupPermissionFromTemplate.xml @@ -1,5 +1,5 @@ - + 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/permission/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml similarity index 68% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml index 52fd267873b..cc62050281b 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeNullGroupPermissionFromTemplate-result.xml @@ -1,5 +1,5 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml similarity index 75% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml index 3e3f93359a2..3e3289534fe 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeNullGroupPermissionFromTemplate.xml @@ -1,5 +1,5 @@ - + 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/permission/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml similarity index 68% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml index 925a1b25692..89983781b67 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeUserPermissionFromTemplate-result.xml @@ -1,5 +1,5 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeUserPermissionFromTemplate.xml similarity index 75% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeUserPermissionFromTemplate.xml index c160e4edf30..779bd770de8 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/removeUserPermissionFromTemplate.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/removeUserPermissionFromTemplate.xml @@ -1,5 +1,5 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectAllPermissionTemplates.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectAllPermissionTemplates.xml new file mode 100644 index 00000000000..1fa43bea18c --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectAllPermissionTemplates.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectEmptyPermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectEmptyPermissionTemplate.xml similarity index 50% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectEmptyPermissionTemplate.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectEmptyPermissionTemplate.xml index 1bc1f3999a0..e8360e44924 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectEmptyPermissionTemplate.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectEmptyPermissionTemplate.xml @@ -1,5 +1,5 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectPermissionTemplate.xml similarity index 85% rename from sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml rename to sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectPermissionTemplate.xml index f869265575c..8cfb9606511 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectPermissionTemplate.xml +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/selectPermissionTemplate.xml @@ -1,5 +1,5 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate-result.xml new file mode 100644 index 00000000000..6f25f75defe --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate-result.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate.xml new file mode 100644 index 00000000000..2c056af7153 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/permission/PermissionDaoTest/updatePermissionTemplate.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_copy_permission_templates.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_copy_permission_templates.xml index 623ed1fd453..6bead9e07e1 100644 --- a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_copy_permission_templates.xml +++ b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_copy_permission_templates.xml @@ -1,6 +1,6 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles-result.xml index 88a68afdb6b..8dd0f010003 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles-result.xml @@ -18,7 +18,7 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles.xml b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles.xml index fea38a879d8..ad5e93d9eeb 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles.xml @@ -10,7 +10,7 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRolesProject.xml b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRolesProject.xml index 3ef5580c464..dac9bf90929 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRolesProject.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRolesProject.xml @@ -10,7 +10,7 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group-result.xml index 8158b940535..1aa42985eab 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group-result.xml @@ -12,7 +12,7 @@ - + \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group.xml b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group.xml index 0c4dfd1ab47..bcf1ee02a0e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_unknown_group.xml @@ -9,7 +9,7 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users-result.xml index 75c11a9834c..ca14596bafe 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users-result.xml @@ -13,7 +13,7 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users.xml b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users.xml index 3f492a44512..bef56d94ebe 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/DefaultResourcePermissionsTest/grantDefaultRoles_users.xml @@ -10,7 +10,7 @@ - + diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate.xml deleted file mode 100644 index 34ffb7f564a..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addGroupPermissionToTemplate.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate.xml deleted file mode 100644 index 34ffb7f564a..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addNullGroupPermissionToTemplate.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate.xml deleted file mode 100644 index 34ffb7f564a..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/addUserPermissionToTemplate.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/createPermissionTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/createPermissionTemplate-result.xml deleted file mode 100644 index 4602891a02f..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/createPermissionTemplate-result.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/deletePermissionTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/deletePermissionTemplate-result.xml deleted file mode 100644 index df9b962986d..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/deletePermissionTemplate-result.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ 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 deleted file mode 100644 index fc6e8c15234..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/selectAllPermissionTemplates.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate-result.xml deleted file mode 100644 index c29fef833b8..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate-result.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate.xml b/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate.xml deleted file mode 100644 index ef9d2a209af..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/user/PermissionDaoTest/updatePermissionTemplate.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java b/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java index 51ba1b246ac..e46717848cb 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java @@ -34,8 +34,8 @@ import org.sonar.core.issue.db.IssueFilterDao; import org.sonar.core.issue.db.IssueFilterDto; import org.sonar.core.issue.db.IssueFilterFavouriteDao; import org.sonar.core.issue.db.IssueFilterFavouriteDto; +import org.sonar.core.permission.Permission; import org.sonar.core.user.AuthorizationDao; -import org.sonar.core.user.Permission; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; @@ -43,7 +43,6 @@ import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.user.UserSession; import javax.annotation.CheckForNull; - import java.util.List; import java.util.Map; diff --git a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java index 825e4d66cd4..162bd1111e0 100644 --- a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java +++ b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionService.java @@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory; import org.sonar.api.ServerComponent; import org.sonar.api.security.DefaultGroups; import org.sonar.core.permission.ComponentPermissionFacade; +import org.sonar.core.permission.Permission; import org.sonar.core.user.*; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.user.UserSession; diff --git a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java index 306771b55ee..dee18cc0d7c 100644 --- a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java +++ b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java @@ -25,8 +25,8 @@ import org.h2.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.ServerComponent; -import org.sonar.core.user.PermissionDao; -import org.sonar.core.user.PermissionTemplateDto; +import org.sonar.core.permission.PermissionDao; +import org.sonar.core.permission.PermissionTemplateDto; import org.sonar.core.user.UserDao; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ServerErrorException; diff --git a/sonar-server/src/main/java/org/sonar/server/permission/PermissionChangeQuery.java b/sonar-server/src/main/java/org/sonar/server/permission/PermissionChangeQuery.java index 02197715c7a..92bee097d59 100644 --- a/sonar-server/src/main/java/org/sonar/server/permission/PermissionChangeQuery.java +++ b/sonar-server/src/main/java/org/sonar/server/permission/PermissionChangeQuery.java @@ -21,7 +21,7 @@ package org.sonar.server.permission; import org.apache.commons.lang.StringUtils; -import org.sonar.core.user.Permission; +import org.sonar.core.permission.Permission; import org.sonar.server.exceptions.BadRequestException; import java.util.Map; diff --git a/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplate.java b/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplate.java index 20cd6888bcb..a88bf35d11f 100644 --- a/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplate.java +++ b/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplate.java @@ -23,9 +23,9 @@ package org.sonar.server.permission; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; -import org.sonar.core.user.PermissionTemplateDto; -import org.sonar.core.user.PermissionTemplateGroupDto; -import org.sonar.core.user.PermissionTemplateUserDto; +import org.sonar.core.permission.PermissionTemplateDto; +import org.sonar.core.permission.PermissionTemplateGroupDto; +import org.sonar.core.permission.PermissionTemplateUserDto; import javax.annotation.Nullable; import java.util.List; diff --git a/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateUpdater.java b/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateUpdater.java index ace626614b1..ff0716f1ab2 100644 --- a/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateUpdater.java +++ b/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateUpdater.java @@ -23,7 +23,12 @@ package org.sonar.server.permission; import com.google.common.collect.Lists; import org.sonar.api.security.DefaultGroups; import org.sonar.api.web.UserRole; -import org.sonar.core.user.*; +import org.sonar.core.permission.Permission; +import org.sonar.core.permission.PermissionDao; +import org.sonar.core.permission.PermissionTemplateDto; +import org.sonar.core.user.GroupDto; +import org.sonar.core.user.UserDao; +import org.sonar.core.user.UserDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.user.UserSession; diff --git a/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java b/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java index b807e92952f..799cf3f2b48 100644 --- a/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java +++ b/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java @@ -25,13 +25,12 @@ import org.sonar.api.user.RubyUserService; import org.sonar.api.user.User; import org.sonar.api.user.UserFinder; import org.sonar.api.user.UserQuery; -import org.sonar.core.user.Permission; +import org.sonar.core.permission.Permission; import org.sonar.core.user.UserDao; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.util.RubyUtils; import javax.annotation.CheckForNull; - import java.util.List; import java.util.Map; diff --git a/sonar-server/src/main/java/org/sonar/server/user/UserSession.java b/sonar-server/src/main/java/org/sonar/server/user/UserSession.java index b51f71b0b47..6f153d7c302 100644 --- a/sonar-server/src/main/java/org/sonar/server/user/UserSession.java +++ b/sonar-server/src/main/java/org/sonar/server/user/UserSession.java @@ -23,15 +23,14 @@ import com.google.common.base.Objects; import com.google.common.base.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.sonar.core.permission.Permission; import org.sonar.core.user.AuthorizationDao; -import org.sonar.core.user.Permission; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.platform.Platform; import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.util.ArrayList; import java.util.List; import java.util.Locale; diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/415_create_permission_templates.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/415_create_permission_templates.rb index 58ace28ff96..cde3e930306 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/415_create_permission_templates.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/415_create_permission_templates.rb @@ -26,6 +26,7 @@ class CreatePermissionTemplates < ActiveRecord::Migration def self.up create_table :permission_templates do |t| t.column :name, :string, :null => false, :limit => 100 + t.column :kee, :string, :null => false, :limit => 100 t.column :description, :string, :null => true, :limit => 4000 t.column :created_at, :datetime, :null => true t.column :updated_at, :datetime, :null => true diff --git a/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java b/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java index 0bac5e1a74b..eab2f15d8dc 100644 --- a/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java @@ -36,8 +36,8 @@ import org.sonar.core.issue.db.IssueFilterDao; import org.sonar.core.issue.db.IssueFilterDto; import org.sonar.core.issue.db.IssueFilterFavouriteDao; import org.sonar.core.issue.db.IssueFilterFavouriteDto; +import org.sonar.core.permission.Permission; import org.sonar.core.user.AuthorizationDao; -import org.sonar.core.user.Permission; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; diff --git a/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java b/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java index 5112fe239cd..0f5d9a7af33 100644 --- a/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionServiceTest.java @@ -31,6 +31,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.security.DefaultGroups; import org.sonar.core.permission.ComponentPermissionFacade; +import org.sonar.core.permission.Permission; import org.sonar.core.user.*; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; diff --git a/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java b/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java index 49d9e10a76d..9ddc5e31f09 100644 --- a/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java @@ -26,7 +26,10 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.web.UserRole; -import org.sonar.core.user.*; +import org.sonar.core.permission.*; +import org.sonar.core.user.GroupDto; +import org.sonar.core.user.UserDao; +import org.sonar.core.user.UserDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.user.MockUserSession; diff --git a/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeQueryTest.java b/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeQueryTest.java index 148147b1408..02f98978fc4 100644 --- a/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeQueryTest.java +++ b/sonar-server/src/test/java/org/sonar/server/permission/PermissionChangeQueryTest.java @@ -24,7 +24,7 @@ import com.google.common.collect.Maps; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.core.user.Permission; +import org.sonar.core.permission.Permission; import org.sonar.server.exceptions.BadRequestException; import java.util.Map; diff --git a/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateTest.java b/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateTest.java index db52030e3cc..69a11a8a2ca 100644 --- a/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateTest.java +++ b/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateTest.java @@ -22,9 +22,9 @@ package org.sonar.server.permission; import com.google.common.collect.Lists; import org.junit.Test; -import org.sonar.core.user.PermissionTemplateDto; -import org.sonar.core.user.PermissionTemplateGroupDto; -import org.sonar.core.user.PermissionTemplateUserDto; +import org.sonar.core.permission.PermissionTemplateDto; +import org.sonar.core.permission.PermissionTemplateGroupDto; +import org.sonar.core.permission.PermissionTemplateUserDto; import static org.fest.assertions.Assertions.assertThat; diff --git a/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java b/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java index e2eda87c932..8a70b2f8c27 100644 --- a/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java +++ b/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java @@ -25,7 +25,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.web.UserRole; -import org.sonar.core.user.*; +import org.sonar.core.permission.Permission; +import org.sonar.core.permission.PermissionDao; +import org.sonar.core.permission.PermissionTemplateDto; +import org.sonar.core.user.GroupDto; +import org.sonar.core.user.UserDao; +import org.sonar.core.user.UserDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.UnauthorizedException; diff --git a/sonar-server/src/test/java/org/sonar/server/user/DefaultUserServiceTest.java b/sonar-server/src/test/java/org/sonar/server/user/DefaultUserServiceTest.java index 194de223491..df0e60b63cd 100644 --- a/sonar-server/src/test/java/org/sonar/server/user/DefaultUserServiceTest.java +++ b/sonar-server/src/test/java/org/sonar/server/user/DefaultUserServiceTest.java @@ -27,7 +27,7 @@ import org.junit.rules.ExpectedException; import org.mockito.ArgumentMatcher; import org.sonar.api.user.UserFinder; import org.sonar.api.user.UserQuery; -import org.sonar.core.user.Permission; +import org.sonar.core.permission.Permission; import org.sonar.core.user.UserDao; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.ForbiddenException; @@ -35,11 +35,7 @@ import org.sonar.server.exceptions.ForbiddenException; import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.Fail.fail; import static org.mockito.Matchers.argThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.*; public class DefaultUserServiceTest { diff --git a/sonar-server/src/test/java/org/sonar/server/user/MockUserSession.java b/sonar-server/src/test/java/org/sonar/server/user/MockUserSession.java index d7dd2de8cbd..7e38dfe808c 100644 --- a/sonar-server/src/test/java/org/sonar/server/user/MockUserSession.java +++ b/sonar-server/src/test/java/org/sonar/server/user/MockUserSession.java @@ -19,10 +19,9 @@ */ package org.sonar.server.user; -import org.sonar.core.user.Permission; +import org.sonar.core.permission.Permission; import javax.annotation.Nullable; - import java.util.Arrays; import java.util.Collections; import java.util.Locale; diff --git a/sonar-server/src/test/java/org/sonar/server/user/UserSessionTest.java b/sonar-server/src/test/java/org/sonar/server/user/UserSessionTest.java index a5890d3d7e1..dcbfe23735a 100644 --- a/sonar-server/src/test/java/org/sonar/server/user/UserSessionTest.java +++ b/sonar-server/src/test/java/org/sonar/server/user/UserSessionTest.java @@ -20,8 +20,8 @@ package org.sonar.server.user; import org.junit.Test; +import org.sonar.core.permission.Permission; import org.sonar.core.user.AuthorizationDao; -import org.sonar.core.user.Permission; import org.sonar.server.exceptions.ForbiddenException; import java.util.Arrays; -- 2.39.5