Search in sources :

Example 26 with ValuesWsResponse

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

the class ValuesActionTest method return_secured_and_license_settings_when_project_admin.

@Test
public void return_secured_and_license_settings_when_project_admin() throws Exception {
    logInAsProjectAdmin();
    definitions.addComponents(asList(PropertyDefinition.builder("foo").onQualifiers(PROJECT).build(), PropertyDefinition.builder("global.secret.secured").build(), PropertyDefinition.builder("secret.secured").onQualifiers(PROJECT).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"), 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", "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 27 with ValuesWsResponse

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

the class ValuesActionTest method return_multi_value_with_coma.

@Test
public void return_multi_value_with_coma() throws Exception {
    logIn();
    definitions.addComponent(PropertyDefinition.builder("global").multiValues(true).build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("global").setValue("three,four%2Cfive"));
    ValuesWsResponse result = executeRequestForGlobalProperties("global");
    assertThat(result.getSettingsList()).hasSize(1);
    Settings.Setting setting = result.getSettings(0);
    assertThat(setting.getKey()).isEqualTo("global");
    assertThat(setting.getValues().getValuesList()).containsOnly("three", "four,five");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 28 with ValuesWsResponse

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

the class ValuesActionTest method return_module_values.

@Test
public void return_module_values() throws Exception {
    logInAsProjectUser();
    ComponentDto module = componentDb.insertComponent(newModuleDto(project));
    definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").onQualifiers(PROJECT, MODULE).build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("property").setValue("one"), // The property is overriding global value
    newComponentPropertyDto(module).setKey("property").setValue("two"));
    ValuesWsResponse result = executeRequestForComponentProperties(module, "property");
    assertThat(result.getSettingsList()).hasSize(1);
    assertSetting(result.getSettings(0), "property", "two", false);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 29 with ValuesWsResponse

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

the class ValuesActionTest method return_global_values.

@Test
public void return_global_values() throws Exception {
    logIn();
    definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").build());
    propertyDb.insertProperties(// The property is overriding default value
    newGlobalPropertyDto().setKey("property").setValue("one"));
    ValuesWsResponse result = executeRequestForGlobalProperties("property");
    assertThat(result.getSettingsList()).hasSize(1);
    assertSetting(result.getSettings(0), "property", "one", false);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Example 30 with ValuesWsResponse

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

the class ValuesActionTest method return_property_set_for_component.

@Test
public void return_property_set_for_component() throws Exception {
    logInAsProjectUser();
    definitions.addComponent(PropertyDefinition.builder("foo").type(PropertyType.PROPERTY_SET).onQualifiers(PROJECT).fields(asList(PropertyFieldDefinition.build("key").name("Key").build(), PropertyFieldDefinition.build("size").name("Size").build())).build());
    propertyDb.insertPropertySet("foo", project, ImmutableMap.of("key", "key1", "size", "size1"), ImmutableMap.of("key", "key2"));
    ValuesWsResponse result = executeRequestForProjectProperties("foo");
    assertThat(result.getSettingsList()).hasSize(1);
    Settings.Setting value = result.getSettings(0);
    assertThat(value.getKey()).isEqualTo("foo");
    assertFieldValues(value, ImmutableMap.of("key", "key1", "size", "size1"), ImmutableMap.of("key", "key2"));
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) 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