]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15142 Use permission instead of role
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 16 Aug 2021 20:39:56 +0000 (15:39 -0500)
committersonartech <sonartech@sonarsource.com>
Thu, 19 Aug 2021 20:08:15 +0000 (20:08 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/ComponentNewValue.java
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/PermissionNewValue.java
server/sonar-db-dao/src/main/java/org/sonar/db/audit/model/PermissionTemplateNewValue.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/UserPermissionDaoWithPersisterTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoWithPersisterTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoWithPersisterTest.java

index d45bd7f7d7f0cbaa0b3fe2538383c9e64e8cc3c9..51925c8c67384ff1dbde0daec5090c966c3b234e 100644 (file)
@@ -53,7 +53,7 @@ public class ComponentNewValue extends NewValue {
     this.componentUuid = componentUuid;
     this.componentName = name;
     this.isPrivate = isPrivate;
-    this.qualifier = this.getQualifier(qualifier);
+    this.qualifier = getQualifier(qualifier);
   }
 
   public ComponentNewValue(String uuid, String name, String key, boolean enabled, String path, @Nullable String qualifier) {
index 96a7bcb9ca3f21ead314e2041824ea0ef325a549..8c1addd360a355ed21019add2cfb020df756f21c 100644 (file)
@@ -33,18 +33,18 @@ public abstract class PermissionNewValue extends NewValue {
   protected String componentName;
 
   @Nullable
-  protected String role;
+  protected String permission;
 
   @Nullable
   protected String qualifier;
 
   protected PermissionNewValue(@Nullable String permissionUuid, @Nullable String componentUuid, @Nullable String componentName,
-    @Nullable String role, @Nullable String qualifier) {
+    @Nullable String permission, @Nullable String qualifier) {
     this.permissionUuid = permissionUuid;
     this.componentUuid = componentUuid;
     this.componentName = componentName;
     this.qualifier = getQualifier(qualifier);
-    this.role = role;
+    this.permission = permission;
   }
 
   @CheckForNull
@@ -58,8 +58,8 @@ public abstract class PermissionNewValue extends NewValue {
   }
 
   @CheckForNull
-  public String getRole() {
-    return this.role;
+  public String getPermission() {
+    return this.permission;
   }
 
   @CheckForNull
index 26ff2491b9e39cd7c3ba758126ea511f5b8ac44f..4a24fb4633613f19feda48d54fb317cf8eba5aab 100644 (file)
@@ -35,7 +35,7 @@ public class PermissionTemplateNewValue extends NewValue {
   private String description;
 
   @Nullable
-  private String role;
+  private String permission;
 
   @Nullable
   private String userUuid;
@@ -64,21 +64,21 @@ public class PermissionTemplateNewValue extends NewValue {
     this.description = permissionTemplateDto.getDescription();
   }
 
-  public PermissionTemplateNewValue(@Nullable String templateUuid, @Nullable String name, @Nullable String role,
+  public PermissionTemplateNewValue(@Nullable String templateUuid, @Nullable String name, @Nullable String permission,
     @Nullable String userUuid, @Nullable String userLogin, @Nullable String groupUuid, @Nullable String groupName) {
     this.templateUuid = templateUuid;
     this.name = name;
-    this.role = role;
+    this.permission = permission;
     this.userUuid = userUuid;
     this.userLogin = userLogin;
     this.groupUuid = groupUuid;
     this.groupName = groupName;
   }
 
-  public PermissionTemplateNewValue(String templateUuid, String role, String name, boolean withProjectCreator) {
+  public PermissionTemplateNewValue(String templateUuid, String permission, String name, boolean withProjectCreator) {
     this.templateUuid = templateUuid;
     this.name = name;
-    this.role = role;
+    this.permission = permission;
     this.withProjectCreator = withProjectCreator;
   }
 
@@ -101,8 +101,8 @@ public class PermissionTemplateNewValue extends NewValue {
   }
 
   @CheckForNull
-  public String getRole() {
-    return this.role;
+  public String getPermission() {
+    return this.permission;
   }
 
   @CheckForNull
@@ -137,7 +137,7 @@ public class PermissionTemplateNewValue extends NewValue {
     addField(sb, "\"name\": ", this.name, true);
     addField(sb, "\"keyPattern\": ", this.keyPattern, true);
     addField(sb, "\"description\": ", this.description, true);
-    addField(sb, "\"role\": ", this.role, true);
+    addField(sb, "\"permission\": ", this.permission, true);
     addField(sb, "\"userUuid\": ", this.userUuid, true);
     addField(sb, "\"userLogin\": ", this.userLogin, true);
     addField(sb, "\"groupUuid\": ", this.groupUuid, true);
index 4e37d71c52d8abec0447569ae65e8a6a5b52ded1..a50e9b10b16ac6e049c227a0a29800f023eb5c5f 100644 (file)
@@ -67,14 +67,14 @@ public class GroupPermissionDaoWithPersisterTest {
     verify(auditPersister).addGroupPermission(eq(dbSession), newValueCaptor.capture());
     GroupPermissionNewValue newValue = newValueCaptor.getValue();
     assertNewValue(newValue, dto.getUuid(), group.getUuid(), group.getName(), null, dto.getRole(), null, null);
-    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"role\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\" }");
+    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"permission\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\" }");
 
     underTest.delete(dbSession, ADMIN, group.getUuid(), group.getName(), null, null);
 
     verify(auditPersister).deleteGroupPermission(eq(dbSession), newValueCaptor.capture());
     newValue = newValueCaptor.getValue();
     assertNewValue(newValue, null, group.getUuid(), group.getName(), null, ADMIN, null, null);
-    assertThat(newValue).hasToString("{\"role\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\" }");
+    assertThat(newValue).hasToString("{\"permission\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\" }");
   }
 
   @Test
@@ -91,7 +91,7 @@ public class GroupPermissionDaoWithPersisterTest {
     verify(auditPersister).addGroupPermission(eq(dbSession), newValueCaptor.capture());
     GroupPermissionNewValue newValue = newValueCaptor.getValue();
     assertNewValue(newValue, dto.getUuid(), group.getUuid(), group.getName(), project.uuid(), dto.getRole(), project.name(), "project");
-    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"role\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\", \"componentUuid\": \"cuuid\", "
+    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"permission\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\", \"componentUuid\": \"cuuid\", "
       + "\"componentName\": \"cname\", \"qualifier\": \"project\" }");
 
     underTest.deleteByRootComponentUuid(dbSession, project);
@@ -119,7 +119,8 @@ public class GroupPermissionDaoWithPersisterTest {
     verify(auditPersister).addGroupPermission(eq(dbSession), newValueCaptor.capture());
     GroupPermissionNewValue newValue = newValueCaptor.getValue();
     assertNewValue(newValue, dto.getUuid(), null, null, project.uuid(), dto.getRole(), project.name(), "project");
-    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"role\": \"admin\", \"componentUuid\": \"cuuid\", \"componentName\": \"cname\", \"qualifier\": \"project\" }");
+    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"permission\": \"admin\", \"componentUuid\": \"cuuid\", "
+      + "\"componentName\": \"cname\", \"qualifier\": \"project\" }");
 
     underTest.deleteByRootComponentUuidForAnyOne(dbSession, project);
 
@@ -146,7 +147,7 @@ public class GroupPermissionDaoWithPersisterTest {
     verify(auditPersister).addGroupPermission(eq(dbSession), newValueCaptor.capture());
     GroupPermissionNewValue newValue = newValueCaptor.getValue();
     assertNewValue(newValue, dto.getUuid(), group.getUuid(), group.getName(), project.uuid(), dto.getRole(), project.name(), "project");
-    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"role\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\", "
+    assertThat(newValue).hasToString("{\"permissionUuid\": \"1\", \"permission\": \"admin\", \"groupUuid\": \"guuid\", \"groupName\": \"gname\", "
       + "\"componentUuid\": \"cuuid\", \"componentName\": \"cname\", \"qualifier\": \"project\" }");
 
     underTest.deleteByRootComponentUuidAndPermission(dbSession, dto.getRole(), project);
@@ -154,7 +155,7 @@ public class GroupPermissionDaoWithPersisterTest {
     verify(auditPersister).deleteGroupPermission(eq(dbSession), newValueCaptor.capture());
     newValue = newValueCaptor.getValue();
     assertNewValue(newValue, null, null, null, project.uuid(), ADMIN, project.name(), "project");
-    assertThat(newValue).hasToString("{\"role\": \"admin\", \"componentUuid\": \"cuuid\", \"componentName\": \"cname\", \"qualifier\": \"project\" }");
+    assertThat(newValue).hasToString("{\"permission\": \"admin\", \"componentUuid\": \"cuuid\", \"componentName\": \"cname\", \"qualifier\": \"project\" }");
   }
 
   @Test
index 5f85b9afd441fd2245b0f7e2eedd4ba25ad44a43..b423bf01e2b36fb3d7b20f456460796d42af8fcc 100644 (file)
@@ -61,7 +61,7 @@ public class UserPermissionDaoWithPersisterTest {
     UserPermissionNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin,
-        UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
+        UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
       .containsExactly(dto.getUuid(), user.getUuid(), user.getLogin(), null, dto.getPermission(), null, null);
     assertThat(newValue.toString()).doesNotContain("projectUuid");
 
@@ -71,7 +71,7 @@ public class UserPermissionDaoWithPersisterTest {
     newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName)
+        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName)
       .containsExactly(null, user.getUuid(), user.getLogin(), null, dto.getPermission(), null);
     assertThat(newValue.toString()).doesNotContain("permissionUuid");
   }
@@ -97,7 +97,7 @@ public class UserPermissionDaoWithPersisterTest {
     UserPermissionNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
+        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
       .containsExactly(dto.getUuid(), user.getUuid(), user.getLogin(), project.uuid(), dto.getPermission(), project.name(), "project");
     assertThat(newValue.toString()).contains("componentUuid");
 
@@ -107,7 +107,7 @@ public class UserPermissionDaoWithPersisterTest {
     newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin,
-        UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName)
+        UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName)
       .containsExactly(null, user.getUuid(), user.getLogin(), project.uuid(), dto.getPermission(), project.name());
     assertThat(newValue.toString())
       .doesNotContain("permissionUuid");
@@ -136,7 +136,7 @@ public class UserPermissionDaoWithPersisterTest {
     UserPermissionNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
+        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
       .containsExactly(dto.getUuid(), user.getUuid(), portfolio.uuid(), dto.getPermission(), portfolio.name(), "portfolio");
     assertThat(newValue.toString())
       .contains("componentUuid");
@@ -153,7 +153,7 @@ public class UserPermissionDaoWithPersisterTest {
     UserPermissionNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
+        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
       .containsExactly(dto.getUuid(), user.getUuid(), application.uuid(), dto.getPermission(), application.name(), "application");
     assertThat(newValue.toString())
       .contains("componentUuid");
@@ -171,7 +171,7 @@ public class UserPermissionDaoWithPersisterTest {
     UserPermissionNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
+        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
       .containsExactly(null, null, null, project.uuid(), SCAN_EXECUTION, project.name(), "project");
     assertThat(newValue.toString()).doesNotContain("userUuid");
   }
@@ -198,7 +198,7 @@ public class UserPermissionDaoWithPersisterTest {
     UserPermissionNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid,
-        UserPermissionNewValue::getRole, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
+        UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier)
       .containsExactly(null, user.getUuid(), user.getLogin(), null, null, null, null);
     assertThat(newValue.toString()).contains("userUuid");
   }
index d6c646af846dfc681dd82957c17bf7b07a07146b..7006ccb0647be60d9ffdb59016e43ae81ac8cc68 100644 (file)
@@ -52,7 +52,7 @@ public class PermissionTemplateCharacteristicDaoWithPersisterTest {
     PermissionTemplateNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::isWithProjectCreator)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::isWithProjectCreator)
       .containsExactly(dto.getTemplateUuid(), "template", dto.getPermission(), dto.getWithProjectCreator());
     assertThat(newValue.toString()).contains("withProjectCreator");
   }
@@ -68,7 +68,7 @@ public class PermissionTemplateCharacteristicDaoWithPersisterTest {
     PermissionTemplateNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::isWithProjectCreator)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::isWithProjectCreator)
       .containsExactly(updated.getTemplateUuid(), "template", updated.getPermission(), updated.getWithProjectCreator());
     assertThat(newValue.toString()).contains("withProjectCreator");
   }
index 4a2182eb9a182533fc3c94a29395619d94f120f3..9d6949f76355c0704be91aa79a97ed3bd4a2e20a 100644 (file)
@@ -109,7 +109,7 @@ public class PermissionTemplateDaoWithPersisterTest {
     PermissionTemplateNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::getUserUuid, PermissionTemplateNewValue::getUserLogin)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::getUserUuid, PermissionTemplateNewValue::getUserLogin)
       .containsExactly(dto.getUuid(), dto.getName(), ADMIN, user.getUuid(), user.getLogin());
     assertThat(newValue.toString()).doesNotContain("groupUuid");
 
@@ -119,7 +119,7 @@ public class PermissionTemplateDaoWithPersisterTest {
     newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::getUserUuid, PermissionTemplateNewValue::getUserLogin)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::getUserUuid, PermissionTemplateNewValue::getUserLogin)
       .containsExactly(dto.getUuid(), dto.getName(), ADMIN, user.getUuid(), user.getLogin());
     assertThat(newValue.toString()).doesNotContain("groupUuid");
   }
@@ -143,7 +143,7 @@ public class PermissionTemplateDaoWithPersisterTest {
     PermissionTemplateNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::getUserUuid, PermissionTemplateNewValue::getUserLogin)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::getUserUuid, PermissionTemplateNewValue::getUserLogin)
       .containsExactly(null, null, null, user.getUuid(), user.getLogin());
     assertThat(newValue.toString()).doesNotContain("groupUuid");
   }
@@ -165,7 +165,7 @@ public class PermissionTemplateDaoWithPersisterTest {
     PermissionTemplateNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
       .containsExactly(dto.getUuid(), dto.getName(), ADMIN, group.getUuid(), group.getName());
     assertThat(newValue.toString()).contains("groupUuid");
 
@@ -175,7 +175,7 @@ public class PermissionTemplateDaoWithPersisterTest {
     newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
       .containsExactly(dto.getUuid(), dto.getName(), ADMIN, group.getUuid(), group.getName());
     assertThat(newValue.toString()).contains("groupUuid");
   }
@@ -205,7 +205,7 @@ public class PermissionTemplateDaoWithPersisterTest {
     PermissionTemplateNewValue newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
       .containsExactly(templateDto.getUuid(), templateDto.getName(), ADMIN, templateGroupDto.getGroupUuid(), templateGroupDto.getGroupName());
     assertThat(newValue.toString()).doesNotContain("userUuid");
 
@@ -215,7 +215,7 @@ public class PermissionTemplateDaoWithPersisterTest {
     newValue = newValueCaptor.getValue();
     assertThat(newValue)
       .extracting(PermissionTemplateNewValue::getTemplateUuid, PermissionTemplateNewValue::getName,
-        PermissionTemplateNewValue::getRole, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
+        PermissionTemplateNewValue::getPermission, PermissionTemplateNewValue::getGroupUuid, PermissionTemplateNewValue::getGroupName)
       .containsExactly(null, null, null, templateGroupDto.getGroupUuid(), templateGroupDto.getGroupName());
     assertThat(newValue.toString()).doesNotContain("userUuid");
   }