diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-16 09:05:16 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-07-16 09:05:16 +0200 |
commit | 268d08284b5e1f2d151ac427c9e23917fd0ad37f (patch) | |
tree | f86d99a12bdaeed70f66b2e10f0311c5ba616378 /sonar-core | |
parent | 8a153bf24c3476af8b8783cb3861b895293bd402 (diff) | |
download | sonarqube-268d08284b5e1f2d151ac427c9e23917fd0ad37f.tar.gz sonarqube-268d08284b5e1f2d151ac427c9e23917fd0ad37f.zip |
Fix UT on MySQL 5.6
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java | 12 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/resource/DefaultResourcePermissionsTest.java | 30 |
2 files changed, 35 insertions, 7 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java b/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java index e76001acafc..9b1596d7d55 100644 --- a/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java +++ b/sonar-core/src/test/java/org/sonar/core/permission/PermissionFacadeTest.java @@ -59,10 +59,18 @@ public class PermissionFacadeTest extends AbstractDaoTestCase { public void should_apply_permission_template() throws Exception { setupData("should_apply_permission_template"); + assertThat(permissionFacade.selectGroupPermissions("sonar-administrators", 123L)).isEmpty(); + assertThat(permissionFacade.selectGroupPermissions("sonar-users", 123L)).isEmpty(); + assertThat(permissionFacade.selectGroupPermissions("Anyone", 123L)).isEmpty(); + assertThat(permissionFacade.selectUserPermissions("marius", 123L)).isEmpty(); + permissionFacade.applyPermissionTemplate("default_20130101_010203", 123L); - checkTable("should_apply_permission_template", "group_roles", "group_id", "resource_id", "role"); - checkTable("should_apply_permission_template", "user_roles", "group_id", "resource_id", "role"); + assertThat(permissionFacade.selectGroupPermissions("sonar-administrators", 123L)).containsOnly("admin", "issueadmin"); + assertThat(permissionFacade.selectGroupPermissions("sonar-users", 123L)).containsOnly("user", "codeviewer"); + assertThat(permissionFacade.selectGroupPermissions("Anyone", 123L)).containsOnly("user", "codeviewer"); + + assertThat(permissionFacade.selectUserPermissions("marius", 123L)).containsOnly("admin"); } @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 e24d07ba7ef..eb0cb230752 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 @@ -38,18 +38,21 @@ import static org.fest.assertions.Assertions.assertThat; public class DefaultResourcePermissionsTest extends AbstractDaoTestCase { + private final static Long PROJECT_ID = 123L; + private Resource project; private Settings settings; private DefaultResourcePermissions permissions; + private PermissionFacade permissionFacade; @Rule public ExpectedException throwable = ExpectedException.none(); @Before public void initResourcePermissions() { - project = new Project("project").setId(123); + project = new Project("project").setId(PROJECT_ID.intValue()); settings = new Settings(); - PermissionFacade permissionFacade = new PermissionFacade(getMyBatis(), + permissionFacade = new PermissionFacade(getMyBatis(), new RoleDao(getMyBatis()), new UserDao(getMyBatis()), new ResourceDao(getMyBatis()), new PermissionTemplateDao(getMyBatis(), System2.INSTANCE), settings); permissions = new DefaultResourcePermissions(getMyBatis(), permissionFacade); } @@ -112,9 +115,18 @@ public class DefaultResourcePermissionsTest extends AbstractDaoTestCase { settings.setProperty("sonar.permission.template.default", "default_template_20130101_010203"); + assertThat(permissionFacade.selectGroupPermissions("sonar-administrators", PROJECT_ID)).isEmpty(); + assertThat(permissionFacade.selectGroupPermissions("sonar-users", PROJECT_ID)).isEmpty(); + assertThat(permissionFacade.selectGroupPermissions("Anyone", PROJECT_ID)).isEmpty(); + assertThat(permissionFacade.selectUserPermissions("marius", PROJECT_ID)).isEmpty(); + permissions.grantDefaultRoles(project); - checkTables("grantDefaultRoles", "user_roles", "group_roles"); + assertThat(permissionFacade.selectGroupPermissions("sonar-administrators", PROJECT_ID)).containsOnly("admin"); + assertThat(permissionFacade.selectGroupPermissions("sonar-users", PROJECT_ID)).containsOnly("user", "codeviewer"); + assertThat(permissionFacade.selectGroupPermissions("Anyone", PROJECT_ID)).containsOnly("user", "codeviewer"); + + assertThat(permissionFacade.selectUserPermissions("marius", PROJECT_ID)).isEmpty(); } @Test @@ -139,7 +151,6 @@ public class DefaultResourcePermissionsTest extends AbstractDaoTestCase { .expectMessage("The \"foo.project\" key matches multiple permission templates: \"Start with foo\", \"Start with foo again\". A system administrator must update these templates so that only one of them matches the key."); permissions.grantDefaultRoles(project); - } @Test @@ -149,9 +160,18 @@ public class DefaultResourcePermissionsTest extends AbstractDaoTestCase { settings.setProperty("sonar.permission.template.default", "default_20130101_010203"); settings.setProperty("sonar.permission.template.TRK.default", "default_for_trk_20130101_010203"); + assertThat(permissionFacade.selectGroupPermissions("sonar-administrators", PROJECT_ID)).isEmpty(); + assertThat(permissionFacade.selectGroupPermissions("sonar-users", PROJECT_ID)).isEmpty(); + assertThat(permissionFacade.selectGroupPermissions("Anyone", PROJECT_ID)).isEmpty(); + assertThat(permissionFacade.selectUserPermissions("marius", PROJECT_ID)).isEmpty(); + permissions.grantDefaultRoles(project); - checkTables("grantDefaultRolesProject", "user_roles", "group_roles"); + assertThat(permissionFacade.selectGroupPermissions("sonar-administrators", PROJECT_ID)).containsOnly("admin", "user", "codeviewer"); + assertThat(permissionFacade.selectGroupPermissions("sonar-users", PROJECT_ID)).containsOnly("admin"); + assertThat(permissionFacade.selectGroupPermissions("Anyone", PROJECT_ID)).containsOnly("codeviewer"); + + assertThat(permissionFacade.selectUserPermissions("marius", PROJECT_ID)).containsOnly("codeviewer"); } @Test |