From ea8bc156195d95eef947ff49dd4d2535a3c56d26 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 13 May 2019 18:04:50 +0200 Subject: [PATCH] SONARCLOUD-636 Update default org projects permission template --- .../organization/OrganizationUpdaterImpl.java | 8 ++++---- .../organization/OrganizationUpdaterImplTest.java | 15 +++++++++++---- .../server/organization/ws/CreateActionTest.java | 7 +++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/OrganizationUpdaterImpl.java b/server/sonar-server/src/main/java/org/sonar/server/organization/OrganizationUpdaterImpl.java index 05429484f9a..b8d82a462bb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/organization/OrganizationUpdaterImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/organization/OrganizationUpdaterImpl.java @@ -234,11 +234,11 @@ public class OrganizationUpdaterImpl implements OrganizationUpdater { .setUpdatedAt(now)); insertGroupPermission(dbSession, permissionTemplateDto, ADMIN, ownerGroup); - insertGroupPermission(dbSession, permissionTemplateDto, ISSUE_ADMIN, ownerGroup); - insertGroupPermission(dbSession, permissionTemplateDto, SECURITYHOTSPOT_ADMIN, ownerGroup); insertGroupPermission(dbSession, permissionTemplateDto, SCAN.getKey(), ownerGroup); insertGroupPermission(dbSession, permissionTemplateDto, USER, defaultGroup); insertGroupPermission(dbSession, permissionTemplateDto, CODEVIEWER, defaultGroup); + insertGroupPermission(dbSession, permissionTemplateDto, ISSUE_ADMIN, defaultGroup); + insertGroupPermission(dbSession, permissionTemplateDto, SECURITYHOTSPOT_ADMIN, defaultGroup); dbClient.organizationDao().setDefaultTemplates( dbSession, @@ -260,11 +260,11 @@ public class OrganizationUpdaterImpl implements OrganizationUpdater { .setUpdatedAt(dateNow)); insertProjectCreatorPermission(dbSession, permissionTemplateDto, ADMIN, now); - insertProjectCreatorPermission(dbSession, permissionTemplateDto, ISSUE_ADMIN, now); - insertProjectCreatorPermission(dbSession, permissionTemplateDto, SECURITYHOTSPOT_ADMIN, now); insertProjectCreatorPermission(dbSession, permissionTemplateDto, SCAN.getKey(), now); insertGroupPermission(dbSession, permissionTemplateDto, USER, defaultGroup); insertGroupPermission(dbSession, permissionTemplateDto, CODEVIEWER, defaultGroup); + insertGroupPermission(dbSession, permissionTemplateDto, ISSUE_ADMIN, defaultGroup); + insertGroupPermission(dbSession, permissionTemplateDto, SECURITYHOTSPOT_ADMIN, defaultGroup); dbClient.organizationDao().setDefaultTemplates( dbSession, diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationUpdaterImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationUpdaterImplTest.java index 099b2ba15c4..77a858eb9a7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationUpdaterImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationUpdaterImplTest.java @@ -203,9 +203,12 @@ public class OrganizationUpdaterImplTest { assertThat(dbClient.permissionTemplateDao().selectGroupPermissionsByTemplateId(dbSession, defaultTemplate.getId())) .extracting(PermissionTemplateGroupDto::getGroupId, PermissionTemplateGroupDto::getPermission) .containsOnly( - tuple(ownersGroup.getId(), UserRole.ADMIN), tuple(ownersGroup.getId(), UserRole.ISSUE_ADMIN), tuple(ownersGroup.getId(), UserRole.SECURITYHOTSPOT_ADMIN), + tuple(ownersGroup.getId(), UserRole.ADMIN), tuple(ownersGroup.getId(), GlobalPermissions.SCAN_EXECUTION), - tuple(defaultGroupId, UserRole.USER), tuple(defaultGroupId, UserRole.CODEVIEWER)); + tuple(defaultGroupId, UserRole.USER), + tuple(defaultGroupId, UserRole.CODEVIEWER), + tuple(defaultGroupId, UserRole.ISSUE_ADMIN), + tuple(defaultGroupId, UserRole.SECURITYHOTSPOT_ADMIN)); } @Test @@ -432,11 +435,15 @@ public class OrganizationUpdaterImplTest { assertThat(dbClient.permissionTemplateDao().selectGroupPermissionsByTemplateId(dbSession, defaultTemplate.getId())) .extracting(PermissionTemplateGroupDto::getGroupId, PermissionTemplateGroupDto::getPermission) .containsOnly( - tuple(defaultGroupId, UserRole.USER), tuple(defaultGroupId, UserRole.CODEVIEWER)); + tuple(defaultGroupId, UserRole.USER), + tuple(defaultGroupId, UserRole.CODEVIEWER), + tuple(defaultGroupId, UserRole.ISSUE_ADMIN), + tuple(defaultGroupId, UserRole.SECURITYHOTSPOT_ADMIN)); assertThat(dbClient.permissionTemplateCharacteristicDao().selectByTemplateIds(dbSession, Collections.singletonList(defaultTemplate.getId()))) .extracting(PermissionTemplateCharacteristicDto::getWithProjectCreator, PermissionTemplateCharacteristicDto::getPermission) .containsOnly( - tuple(true, UserRole.ADMIN), tuple(true, UserRole.ISSUE_ADMIN), tuple(true, UserRole.SECURITYHOTSPOT_ADMIN), tuple(true, GlobalPermissions.SCAN_EXECUTION)); + tuple(true, UserRole.ADMIN), + tuple(true, GlobalPermissions.SCAN_EXECUTION)); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java index ae0a3265ff4..de8573516a2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java @@ -221,9 +221,12 @@ public class CreateActionTest { assertThat(dbClient.permissionTemplateDao().selectGroupPermissionsByTemplateId(dbSession, defaultTemplate.getId())) .extracting(PermissionTemplateGroupDto::getGroupId, PermissionTemplateGroupDto::getPermission) .containsOnly( - tuple(ownersGroup.getId(), UserRole.ADMIN), tuple(ownersGroup.getId(), UserRole.ISSUE_ADMIN), tuple(ownersGroup.getId(), UserRole.SECURITYHOTSPOT_ADMIN), + tuple(ownersGroup.getId(), UserRole.ADMIN), tuple(ownersGroup.getId(), GlobalPermissions.SCAN_EXECUTION), - tuple(defaultGroup.getId(), UserRole.USER), tuple(defaultGroup.getId(), UserRole.CODEVIEWER)); + tuple(defaultGroup.getId(), UserRole.USER), + tuple(defaultGroup.getId(), UserRole.CODEVIEWER), + tuple(defaultGroup.getId(), UserRole.ISSUE_ADMIN), + tuple(defaultGroup.getId(), UserRole.SECURITYHOTSPOT_ADMIN)); } @Test -- 2.39.5