aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-04-28 09:14:34 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-04-28 18:36:09 +0200
commit65a250757f5c7d60c03a8d94a78ba716729cf379 (patch)
tree815591b11668217297e187edf39935fca45bd63e /it
parent211c8f4574a43d68a026a1b230ca3c9a9ff52587 (diff)
downloadsonarqube-65a250757f5c7d60c03a8d94a78ba716729cf379.tar.gz
sonarqube-65a250757f5c7d60c03a8d94a78ba716729cf379.zip
SONAR-9124 Allow preventing project to become private api/projects/update_visibility
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/organization/BillingTest.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/it/it-tests/src/test/java/it/organization/BillingTest.java b/it/it-tests/src/test/java/it/organization/BillingTest.java
index 869f7601943..ef90a697432 100644
--- a/it/it-tests/src/test/java/it/organization/BillingTest.java
+++ b/it/it-tests/src/test/java/it/organization/BillingTest.java
@@ -37,6 +37,7 @@ import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.organization.CreateWsRequest;
import org.sonarqube.ws.client.organization.UpdateProjectVisibilityWsRequest;
import org.sonarqube.ws.client.project.CreateRequest;
+import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
import util.ItUtils;
import util.user.UserRule;
@@ -148,7 +149,7 @@ public class BillingTest {
}
@Test
- public void fail_to_update_default_projects_visibility_to_private() {
+ public void fail_to_update_organization_default_visibility_to_private() {
String organizationKey = createOrganization();
setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
@@ -161,6 +162,32 @@ public class BillingTest {
}
}
+ @Test
+ public void does_not_fail_to_update_project_visibility_to_private() {
+ String organizationKey = createOrganization();
+ String projectKey = createPublicProject(organizationKey);
+ setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
+
+ adminClient.projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(projectKey).setVisibility("private").build());
+
+ assertWsResponseAsAdmin(new GetRequest("api/navigation/component").setParam("componentKey", projectKey), "\"visibility\":\"private\"");
+ }
+
+ @Test
+ public void fail_to_update_project_visibility_to_private() {
+ String organizationKey = createOrganization();
+ String projectKey = createPublicProject(organizationKey);
+ setServerProperty(orchestrator, "sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "true");
+
+ try {
+ adminClient.projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(projectKey).setVisibility("private").build());
+ fail();
+ } catch (HttpException ex) {
+ assertThat(ex.code()).isEqualTo(400);
+ assertThat(ex.content()).contains(format("Organization %s cannot use private project", organizationKey));
+ }
+ }
+
private static String createOrganization() {
String key = newOrganizationKey();
adminClient.organizations().create(new CreateWsRequest.Builder().setKey(key).setName(key).build()).getOrganization();