From 502da4c9070bf4423b6588cec97fc00c4c80e1ca Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 7 Feb 2017 16:44:05 +0100 Subject: [PATCH] SONAR-8716 manage root permissions in UserSessionRule --- .../sonar/server/tester/AbstractMockUserSession.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/sonar-server/src/test/java/org/sonar/server/tester/AbstractMockUserSession.java b/server/sonar-server/src/test/java/org/sonar/server/tester/AbstractMockUserSession.java index 18698808e6a..4a587779f00 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/tester/AbstractMockUserSession.java +++ b/server/sonar-server/src/test/java/org/sonar/server/tester/AbstractMockUserSession.java @@ -69,13 +69,16 @@ public abstract class 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 @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) { -- 2.39.5