]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7135 WS api/measures/component_tree fix permissions and IT
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 13 Jan 2016 13:34:47 +0000 (14:34 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 13 Jan 2016 13:34:47 +0000 (14:34 +0100)
it/it-tests/src/test/java/it/measure/MeasuresWsTest.java
server/sonar-server/src/main/java/org/sonar/server/measure/ws/ComponentTreeDataLoader.java

index b62e390e627cba131c9e39be644b42b54fef71db..367c16919c532a1ea6298485d7384f61820f6c72 100644 (file)
@@ -74,9 +74,10 @@ public class MeasuresWsTest {
       .setAdditionalFields(newArrayList("metrics", "periods")));
 
     assertThat(response).isNotNull();
+    assertThat(response.getBaseComponent().getKey()).isEqualTo("sample");
     assertThat(response.getMetrics().getMetricsList()).extracting("key").containsOnly("ncloc");
     List<WsMeasures.Component> components = response.getComponentsList();
     assertThat(components).hasSize(2).extracting("key").containsOnly("sample:src/main/xoo/sample", FILE_KEY);
-    assertThat(components.get(0).getMeasuresList().get(0).getValue()).isEqualTo("13");
+    assertThat(components.get(0).getMeasures().getMeasuresList().get(0).getValue()).isEqualTo("13");
   }
 }
index bc84c432c9d2615642aeaa8017df393ff01f7bce..9a967c66413eed7d3e2a4ef11ce0ca7ed290f6fe 100644 (file)
@@ -333,9 +333,9 @@ public class ComponentTreeDataLoader {
 
   private void checkPermissions(ComponentDto baseComponent) {
     String projectUuid = firstNonNull(baseComponent.projectUuid(), baseComponent.uuid());
-    if (!userSession.hasGlobalPermission(GlobalPermissions.SYSTEM_ADMIN) &&
-      !userSession.hasProjectPermissionByUuid(UserRole.ADMIN, projectUuid) &&
-      !userSession.hasProjectPermissionByUuid(UserRole.USER, projectUuid)) {
+    if (!userSession.hasPermission(GlobalPermissions.SYSTEM_ADMIN) &&
+      !userSession.hasComponentUuidPermission(UserRole.ADMIN, projectUuid) &&
+      !userSession.hasComponentUuidPermission(UserRole.USER, projectUuid)) {
       throw insufficientPrivilegesException();
     }
   }