]> source.dussan.org Git - sonarqube.git/commitdiff
SONARCLOUD-636 Update default org projects permission template
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 13 May 2019 16:04:50 +0000 (18:04 +0200)
committerSonarTech <sonartech@sonarsource.com>
Wed, 22 May 2019 18:21:15 +0000 (20:21 +0200)
server/sonar-server/src/main/java/org/sonar/server/organization/OrganizationUpdaterImpl.java
server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationUpdaterImplTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java

index 05429484f9a966e9e348e4b9f1a4e14e58ae9a96..b8d82a462bbbd193568f4fd375050ca54e9bad8b 100644 (file)
@@ -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,
index 099b2ba15c477661fcc7ee0b39192ddfc5c6838e..77a858eb9a7a1edabd45eecfa4e6e2865fcac537 100644 (file)
@@ -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
index ae0a3265ff47b7c44c5d4604300c3c68adbf245c..de8573516a2ef510d6f2c45759f5a94e75936832 100644 (file)
@@ -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