Search in sources :

Example 21 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_additional_settings_specific_for_scanner_when_no_keys.

@Test
public void return_additional_settings_specific_for_scanner_when_no_keys() throws Exception {
    logInAsAdmin();
    definitions.addComponent(PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("sonar.server_id").setValue("12345"), newGlobalPropertyDto().setKey("sonar.core.id").setValue("ID"), newGlobalPropertyDto().setKey("sonar.core.startTime").setValue("2017-01-01"), newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"), newGlobalPropertyDto().setKey("sonar.plugin.licenseHash.secured").setValue("987654321"));
    ValuesWsResponse result = executeRequestForGlobalProperties();
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("sonar.server_id", "sonar.core.id", "sonar.core.startTime", "plugin.license.secured", "sonar.plugin.licenseHash.secured");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 22 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_value_of_deprecated_key.

@Test
public void return_value_of_deprecated_key() throws Exception {
    logIn();
    definitions.addComponent(PropertyDefinition.builder("foo").deprecatedKey("deprecated").build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"));
    ValuesWsResponse result = executeRequestForGlobalProperties("deprecated");
    assertThat(result.getSettingsList()).hasSize(1);
    Settings.Setting value = result.getSettings(0);
    assertThat(value.getKey()).isEqualTo("deprecated");
    assertThat(value.getValue()).isEqualTo("one");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 23 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_component_secured_settings_when_not_authenticated_but_with_scan_permission.

@Test
public void return_component_secured_settings_when_not_authenticated_but_with_scan_permission() throws Exception {
    userSession.addProjectUuidPermissions(USER, project.uuid()).addProjectUuidPermissions(SCAN_EXECUTION, project.uuid());
    definitions.addComponents(asList(PropertyDefinition.builder("foo").onQualifiers(PROJECT).build(), PropertyDefinition.builder("global.secret.secured").build(), PropertyDefinition.builder("secret.secured").onQualifiers(PROJECT).build(), PropertyDefinition.builder("commercial.plugin").type(LICENSE).build(), PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
    propertyDb.insertProperties(newComponentPropertyDto(project).setKey("foo").setValue("one"), newGlobalPropertyDto().setKey("global.secret.secured").setValue("very secret"), newComponentPropertyDto(project).setKey("secret.secured").setValue("password"), newComponentPropertyDto(project).setKey("commercial.plugin").setValue("ABCD"), newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"), newGlobalPropertyDto().setKey("sonar.plugin.licenseHash.secured").setValue("987654321"));
    ValuesWsResponse result = executeRequestForProjectProperties();
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("foo", "global.secret.secured", "secret.secured", "commercial.plugin", "plugin.license.secured", "sonar.plugin.licenseHash.secured");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 24 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_inherited_values_on_global_setting.

@Test
public void return_inherited_values_on_global_setting() throws Exception {
    logIn();
    definitions.addComponents(asList(PropertyDefinition.builder("defaultProperty").defaultValue("default").build(), PropertyDefinition.builder("globalProperty").build()));
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("globalProperty").setValue("global"));
    ValuesWsResponse result = executeRequestForGlobalProperties("defaultProperty", "globalProperty");
    assertThat(result.getSettingsList()).hasSize(2);
    assertSetting(result.getSettings(0), "defaultProperty", "default", true);
    assertSetting(result.getSettings(1), "globalProperty", "global", false);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Example 25 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_is_inherited_to_true_when_property_is_defined_only_at_global_level.

@Test
public void return_is_inherited_to_true_when_property_is_defined_only_at_global_level() throws Exception {
    logInAsProjectUser();
    definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").onQualifiers(PROJECT).build());
    // The property is not defined on project
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("property").setValue("one"));
    ValuesWsResponse result = executeRequestForProjectProperties("property");
    assertThat(result.getSettingsList()).hasSize(1);
    assertSetting(result.getSettings(0), "property", "one", true);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Aggregations

ValuesWsResponse (org.sonarqube.ws.Settings.ValuesWsResponse)34 Test (org.junit.Test)32 Settings (org.sonarqube.ws.Settings)19 ComponentDto (org.sonar.db.component.ComponentDto)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 CheckForNull (javax.annotation.CheckForNull)1 Profiler (org.sonar.api.utils.log.Profiler)1 Setting (org.sonarqube.ws.Settings.Setting)1 GetRequest (org.sonarqube.ws.client.GetRequest)1 LicenseItem (pageobjects.licenses.LicenseItem)1 LicensesPage (pageobjects.licenses.LicensesPage)1