]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9054 Revert WS api/navigation/organization filter out billing pages for persona... 2009/head
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 3 May 2017 06:23:51 +0000 (08:23 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Fri, 5 May 2017 09:47:37 +0000 (11:47 +0200)
server/sonar-server/src/main/java/org/sonar/server/ui/ws/OrganizationAction.java
server/sonar-server/src/test/java/org/sonar/server/ui/ws/OrganizationActionTest.java

index 915c69e93ed7b160c97ba82d9e31708b20ef1432..3f63af0869afdfb1958b4ae87bf9493a6c7b0b86 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.ui.ws;
 
 import java.util.List;
 import java.util.function.Consumer;
-import java.util.function.Predicate;
 import org.sonar.api.server.ws.Change;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
@@ -38,7 +37,6 @@ import org.sonar.server.project.Visibility;
 import org.sonar.server.ui.PageRepository;
 import org.sonar.server.user.UserSession;
 
-import static org.sonar.core.util.stream.MoreCollectors.toList;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
 import static org.sonar.db.permission.OrganizationPermission.PROVISION_PROJECTS;
 import static org.sonar.server.ws.KeyExamples.KEY_ORG_EXAMPLE_001;
@@ -108,14 +106,11 @@ public class OrganizationAction implements NavigationWsAction {
       .prop("canUpdateProjectsVisibilityToPrivate",
         userSession.hasPermission(ADMINISTER, organization) &&
           billingValidations.canUpdateProjectVisibilityToPrivate(new BillingValidations.Organization(organization.getKey(), organization.getUuid())));
-    Predicate<Page> personalOrgForBilling = page -> organization.getUserId() == null || !page.getKey().startsWith("billing/");
-    List<Page> pages = pageRepository.getOrganizationPages(false).stream().filter(personalOrgForBilling).collect(toList());
     json.name("pages");
-    writePages(json, pages);
+    writePages(json, pageRepository.getOrganizationPages(false));
     if (userSession.hasPermission(ADMINISTER, organization)) {
-      List<Page> adminPages = pageRepository.getOrganizationPages(true).stream().filter(personalOrgForBilling).collect(toList());
       json.name("adminPages");
-      writePages(json, adminPages);
+      writePages(json, pageRepository.getOrganizationPages(true));
     }
     json.endObject();
   }
index a23a57c9eb4c75bb2a7abcd1ad0852fe7c334bd1..6c04d911948a947616b7052f1bb245616b72a554 100644 (file)
@@ -125,38 +125,6 @@ public class OrganizationActionTest {
       .doesNotContain("my-plugin/org-admin-page");
   }
 
-  @Test
-  public void filter_out_billing_pages_for_personal_organizations() {
-    initWithPages(
-      Page.builder("my-plugin/org-page").setName("Organization page").setScope(ORGANIZATION).build(),
-      Page.builder("my-plugin/org-admin-page").setName("Organization admin page").setScope(ORGANIZATION).setAdmin(true).build(),
-      Page.builder("billing/org-page").setName("Organization page").setScope(ORGANIZATION).build(),
-      Page.builder("billing/org-admin-page").setName("Organization admin page").setScope(ORGANIZATION).setAdmin(true).build());
-    OrganizationDto organization = dbTester.organizations().insert(dto -> dto.setUserId(101));
-    userSession.logIn().addPermission(ADMINISTER, organization);
-
-    TestResponse response = executeRequest(organization);
-
-    assertThat(response.getInput())
-      .contains("my-plugin/org-page", "my-plugin/org-admin-page")
-      .doesNotContain("billing/org-page")
-      .doesNotContain("billing/org-admin-page");
-  }
-
-  @Test
-  public void include_billing_pages_for_non_personal_organizations() {
-    initWithPages(
-      Page.builder("billing/org-page").setName("Organization page").setScope(ORGANIZATION).build(),
-      Page.builder("billing/org-admin-page").setName("Organization admin page").setScope(ORGANIZATION).setAdmin(true).build());
-    OrganizationDto organization = dbTester.organizations().insert(dto -> dto.setUserId(null));
-    userSession.logIn().addPermission(ADMINISTER, organization);
-
-    TestResponse response = executeRequest(organization);
-
-    assertThat(response.getInput())
-      .contains("billing/org-page", "billing/org-admin-page");
-  }
-
   @Test
   public void returns_non_admin_and_canDelete_false_when_user_not_logged_in_and_key_is_the_default_organization() {
     TestResponse response = executeRequest(dbTester.getDefaultOrganization());