// actions
SearchAction.class,
SearchMembersAction.class,
- SearchMyOrganizationsAction.class);
+ SearchMyOrganizationsAction.class,
+ // Update of project visibility is used on on-premise instances, not only on SonarCloud / Organizations
+ UpdateProjectVisibilityAction.class);
if (config.getBoolean(SONARCLOUD_ENABLED).orElse(false)) {
add(
EnableSupportAction.class,
CreateAction.class,
DeleteAction.class,
RemoveMemberAction.class,
- UpdateAction.class,
- UpdateProjectVisibilityAction.class);
+ UpdateAction.class);
}
}
underTest.configure(container);
assertThat(container.getPicoContainer().getComponentAdapters())
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 5);
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 6);
}
@Test
import org.sonarqube.tests.authorisation.ExecuteAnalysisPermissionTest;
import org.sonarqube.tests.authorisation.IssuePermissionTest;
import org.sonarqube.tests.authorisation.PermissionSearchTest;
+import org.sonarqube.tests.authorisation.ProjectPermissionsTest;
import org.sonarqube.tests.authorisation.ProvisioningPermissionTest;
import org.sonarqube.tests.authorisation.QualityProfileAdminPermissionTest;
import org.sonarqube.tests.complexity.ComplexityMeasuresTest;
PermissionSearchTest.class,
ProvisioningPermissionTest.class,
QualityProfileAdminPermissionTest.class,
+ ProjectPermissionsTest.class,
// custom measure
CustomMeasuresTest.class,
// measure
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonarqube.tests.authorisation;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.pageobjects.ProjectPermissionsPage;
+import org.sonarqube.tests.Category1Suite;
+import org.sonarqube.tests.Tester;
+import org.sonarqube.ws.WsProjects.CreateWsResponse.Project;
+import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
+import org.sonarqube.ws.client.component.ShowWsRequest;
+import org.sonarqube.ws.client.organization.UpdateProjectVisibilityWsRequest;
+import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ProjectPermissionsTest {
+
+ @ClassRule
+ public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+
+ @Rule
+ public Tester tester = new Tester(orchestrator).disableOrganizations();
+
+ @Test
+ public void change_project_visibility_from_ui() {
+ Project project = tester.projects().generate(null);
+ User administrator = tester.users().generateAdministrator();
+
+ ProjectPermissionsPage page = tester.openBrowser().logIn()
+ .submitCredentials(administrator.getLogin())
+ .openProjectPermissions(project.getKey());
+
+ page
+ .shouldBePublic()
+ .turnToPrivate()
+ .shouldBePrivate()
+ .turnToPublic()
+ .shouldBePublic();
+ }
+
+ @Test
+ public void change_project_visibility_from_ws() {
+ Project project = tester.projects().generate(null);
+ assertThat(tester.wsClient().components().show(new ShowWsRequest().setKey(project.getKey())).getComponent().getVisibility()).isEqualTo("public");
+
+ tester.wsClient().projects().updateVisibility(UpdateVisibilityRequest.builder().setProject(project.getKey()).setVisibility("private").build());
+
+ assertThat(tester.wsClient().components().show(new ShowWsRequest().setKey(project.getKey())).getComponent().getVisibility()).isEqualTo("private");
+ }
+
+ /**
+ * SONAR-10569
+ */
+ @Test
+ public void change_default_project_visibility_from_ws() {
+ try {
+ tester.wsClient().organizations().updateProjectVisibility(UpdateProjectVisibilityWsRequest.builder()
+ .setOrganization(tester.organizations().getDefaultOrganization().getKey())
+ .setProjectVisibility("private")
+ .build());
+
+ Project project = tester.projects().generate(null);
+
+ assertThat(tester.wsClient().components().show(new ShowWsRequest().setKey(project.getKey())).getComponent().getVisibility()).isEqualTo("private");
+
+ } finally {
+ // Restore default visibility to public to not break other tests
+ tester.wsClient().organizations().updateProjectVisibility(UpdateProjectVisibilityWsRequest.builder()
+ .setOrganization(tester.organizations().getDefaultOrganization().getKey())
+ .setProjectVisibility("public")
+ .build());
+ }
+ }
+
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.tests.projectAdministration;
-
-import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category1Suite;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.pageobjects.Navigation;
-import org.sonarqube.pageobjects.ProjectPermissionsPage;
-import util.user.UserRule;
-
-import static util.ItUtils.projectDir;
-import static util.selenium.Selenese.runSelenese;
-
-public class ProjectPermissionsTest {
-
- @ClassRule
- public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
-
- @Rule
- public UserRule userRule = UserRule.from(orchestrator);
-
- private Navigation nav = Navigation.create(orchestrator);
- private String adminUser;
-
- @BeforeClass
- public static void beforeClass() {
- executeBuild("project-permissions-project", "Test Project");
- executeBuild("project-permissions-project-2", "Another Test Project");
- }
-
- @Before
- public void before() {
- adminUser = userRule.createAdminUser();
- }
-
- @Test
- public void test_project_permissions_page_shows_only_single_project() throws Exception {
- runSelenese(orchestrator, "/projectAdministration/ProjectPermissionsTest/test_project_permissions_page_shows_only_single_project.html");
- }
-
- @Test
- public void change_project_visibility() {
- ProjectPermissionsPage page = nav.logIn().submitCredentials(adminUser).openProjectPermissions("project-permissions-project");
- page
- .shouldBePublic()
- .turnToPrivate()
- .turnToPublic();
- }
-
- private static void executeBuild(String projectKey, String projectName) {
- orchestrator.executeBuild(
- SonarScanner.create(projectDir("shared/xoo-sample"))
- .setProjectKey(projectKey)
- .setProjectName(projectName)
- );
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <link rel="selenium.base" href="http://localhost:49506"/>
- <title>test_project_overview_after_first_analysis</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
- <thead>
- <tr>
- <td rowspan="1" colspan="3">test_project_overview_after_first_analysis</td>
- </tr>
- </thead>
- <tbody>
-
- <tr>
- <td>open</td>
- <td>/sessions/login</td>
- <td></td>
- </tr>
- <tr>
- <td>type</td>
- <td>login</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>type</td>
- <td>password</td>
- <td>admin</td>
- </tr>
- <tr>
- <td>clickAndWait</td>
- <td>commit</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForElementPresent</td>
- <td>css=.js-user-authenticated</td>
- <td></td>
- </tr>
- <tr>
- <td>open</td>
- <td>/project_roles?id=project-permissions-project</td>
- <td></td>
- </tr>
- <tr>
- <td>waitForElementPresent</td>
- <td>css=#projects</td>
- <td></td>
- </tr>
- <tr>
- <td>assertNotText</td>
- <td>css=#projects</td>
- <td>*Another Test Project*</td>
- </tr>
- <tr>
- <td>assertElementNotPresent</td>
- <td>css=footer</td>
- <td></td>
- </tr>
- <tr>
- <td>assertElementNotPresent</td>
- <td>css=.search-box</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-</body>
-</html>