]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8716 manage root permissions in UserSessionRule
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 7 Feb 2017 15:44:05 +0000 (16:44 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 8 Feb 2017 16:18:43 +0000 (17:18 +0100)
server/sonar-server/src/test/java/org/sonar/server/tester/AbstractMockUserSession.java

index 18698808e6a61e8886a2e868f28186b85125d124..4a587779f00835833759a41ec7bb480f071f3eaf 100644 (file)
@@ -69,13 +69,16 @@ public abstract class AbstractMockUserSession<T extends AbstractMockUserSession>
 
   @Override
   public boolean hasComponentPermission(String permission, ComponentDto component) {
-    return hasComponentUuidPermission(permission, component.projectUuid());
+    return isRoot() || hasComponentUuidPermission(permission, component.projectUuid());
   }
 
-    @Override
+  @Override
   public boolean hasComponentUuidPermission(String permission, String componentUuid) {
+    if (isRoot()) {
+      return true;
+    }
     String projectUuid = projectUuidByComponentUuid.get(componentUuid);
-    return hasPermission(permission) || (projectUuid != null && hasProjectPermissionByUuid(permission, projectUuid));
+    return projectUuid != null && hasProjectPermissionByUuid(permission, projectUuid);
   }
 
   private boolean hasProjectPermissionByUuid(String permission, String projectUuid) {
@@ -84,7 +87,7 @@ public abstract class AbstractMockUserSession<T extends AbstractMockUserSession>
 
   @Override
   public boolean hasOrganizationPermission(String organizationUuid, String permission) {
-    return permissionsByOrganizationUuid.get(organizationUuid).contains(permission);
+    return isRoot() || permissionsByOrganizationUuid.get(organizationUuid).contains(permission);
   }
 
   public T addOrganizationPermission(String organizationUuid, String permission) {