You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProjectSettingsTest.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2018 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonarqube.tests.project;
  21. import com.sonar.orchestrator.Orchestrator;
  22. import com.sonar.orchestrator.build.SonarScanner;
  23. import java.io.UnsupportedEncodingException;
  24. import org.junit.Before;
  25. import org.junit.ClassRule;
  26. import org.junit.Rule;
  27. import org.junit.Test;
  28. import org.openqa.selenium.By;
  29. import org.sonarqube.qa.util.Tester;
  30. import org.sonarqube.qa.util.pageobjects.Navigation;
  31. import org.sonarqube.qa.util.pageobjects.settings.SettingsPage;
  32. import static com.codeborne.selenide.Selenide.$;
  33. import static util.ItUtils.projectDir;
  34. public class ProjectSettingsTest {
  35. @ClassRule
  36. public static Orchestrator orchestrator = ProjectSuite.ORCHESTRATOR;
  37. @Rule
  38. public Tester tester = new Tester(orchestrator);
  39. private String adminUser;
  40. @Before
  41. public void setUp() {
  42. adminUser = tester.users().generateAdministratorOnDefaultOrganization().getLogin();
  43. }
  44. @Test
  45. public void display_project_settings() {
  46. analyzeSample();
  47. SettingsPage page = tester.openBrowser()
  48. .logIn()
  49. .submitCredentials(adminUser)
  50. .openSettings("sample")
  51. .assertMenuContains("Analysis Scope")
  52. .assertMenuContains("Category 1")
  53. .assertMenuContains("project-only")
  54. .assertMenuContains("Xoo")
  55. .assertSettingDisplayed("sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay");
  56. page.openCategory("project-only")
  57. .assertSettingDisplayed("prop_only_on_project");
  58. page.openCategory("General")
  59. .assertStringSettingValue("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "30")
  60. .assertStringSettingValue("sonar.leak.period", "previous_version")
  61. .assertBooleanSettingValue("sonar.dbcleaner.cleanDirectory", true)
  62. .setStringValue("sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay", "48")
  63. .assertStringSettingValue("sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay", "48");
  64. }
  65. /**
  66. * Values set on project level must not appear on global level
  67. */
  68. @Test
  69. public void display_correct_global_setting() {
  70. analyzeSample();
  71. Navigation nav = tester.openBrowser();
  72. SettingsPage page = nav.logIn()
  73. .submitCredentials(adminUser)
  74. .openSettings("sample")
  75. .openCategory("Analysis Scope")
  76. .assertSettingDisplayed("sonar.coverage.exclusions")
  77. .setStringValue("sonar.coverage.exclusions", "foo")
  78. .assertStringSettingValue("sonar.coverage.exclusions", "foo");
  79. nav.logOut();
  80. // login as root
  81. tester.wsClient().users().skipOnboardingTutorial();
  82. nav.logIn().submitCredentials("admin", "admin");
  83. $(".global-navbar-menu ").$(By.linkText("Administration")).click();
  84. page
  85. .openCategory("Analysis Scope")
  86. .assertSettingDisplayed("sonar.coverage.exclusions")
  87. .assertStringSettingValue("sonar.coverage.exclusions", "");
  88. }
  89. @Test
  90. public void display_module_settings() {
  91. orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-multi-modules-sample")));
  92. tester.openBrowser().logIn().submitCredentials(adminUser)
  93. .openSettings("com.sonarsource.it.samples:multi-modules-sample:module_a")
  94. .assertMenuContains("Analysis Scope")
  95. .assertSettingDisplayed("sonar.coverage.exclusions");
  96. }
  97. private void analyzeSample() {
  98. SonarScanner scan = SonarScanner.create(projectDir("shared/xoo-sample"))
  99. .setProperty("sonar.cpd.exclusions", "**/*");
  100. orchestrator.executeBuild(scan);
  101. }
  102. }