Search in sources :

Example 41 with ValuesWsResponse

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

the class ValuesActionTest method return_secured_settings_when_system_admin.

@Test
public void return_secured_settings_when_system_admin() {
    logInAsAdmin();
    definitions.addComponents(asList(PropertyDefinition.builder("foo").build(), PropertyDefinition.builder("secret.secured").build()));
    propertyDb.insertProperties(null, null, null, null, newGlobalPropertyDto().setKey("foo").setValue("one"), newGlobalPropertyDto().setKey("secret.secured").setValue("password"));
    ValuesWsResponse result = executeRequestForGlobalProperties();
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("foo");
    assertThat(result.getSetSecuredSettingsList()).containsOnly("secret.secured");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) MapSettings(org.sonar.api.config.internal.MapSettings) Test(org.junit.Test)

Example 42 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() {
    logInAsAdmin();
    definitions.addComponent(PropertyDefinition.builder("secret.secured").build());
    propertyDb.insertProperties(null, null, null, null, newGlobalPropertyDto().setKey("sonar.core.id").setValue("ID"), newGlobalPropertyDto().setKey("sonar.core.startTime").setValue("2017-01-01"));
    ValuesWsResponse result = executeRequestForGlobalProperties();
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("sonar.core.id", "sonar.core.startTime");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) MapSettings(org.sonar.api.config.internal.MapSettings) Test(org.junit.Test)

Example 43 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() {
    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) MapSettings(org.sonar.api.config.internal.MapSettings) Test(org.junit.Test)

Example 44 with ValuesWsResponse

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

the class ValuesActionTest method return_default_values.

@Test
public void return_default_values() {
    logIn();
    definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
    ValuesWsResponse result = executeRequestForGlobalProperties("foo");
    assertThat(result.getSettingsList()).hasSize(1);
    assertSetting(result.getSettings(0), "foo", "default", true);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Example 45 with ValuesWsResponse

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

the class ValuesActionTest method do_not_return_secured_settings_when_not_authenticated.

@Test
public void do_not_return_secured_settings_when_not_authenticated() {
    definitions.addComponents(asList(PropertyDefinition.builder("foo").build(), PropertyDefinition.builder("secret.secured").build()));
    propertyDb.insertProperties(null, null, null, null, newGlobalPropertyDto().setKey("foo").setValue("one"), newGlobalPropertyDto().setKey("secret.secured").setValue("password"));
    ValuesWsResponse result = executeRequestForGlobalProperties();
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("foo");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) MapSettings(org.sonar.api.config.internal.MapSettings) Test(org.junit.Test)

Aggregations

ValuesWsResponse (org.sonarqube.ws.Settings.ValuesWsResponse)46 Test (org.junit.Test)43 Settings (org.sonarqube.ws.Settings)25 MapSettings (org.sonar.api.config.internal.MapSettings)18 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 PipedInputStream (java.io.PipedInputStream)2 PipedOutputStream (java.io.PipedOutputStream)2 ComponentDto (org.sonar.db.component.ComponentDto)2 Setting (org.sonarqube.ws.Settings.Setting)2 SonarLintWsClient (org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)2 CheckForNull (javax.annotation.CheckForNull)1 PropertyDefinition (org.sonar.api.config.PropertyDefinition)1 Profiler (org.sonar.api.utils.log.Profiler)1 WsActionTester (org.sonar.server.ws.WsActionTester)1 Value (org.sonarqube.ws.Settings.FieldValues.Value)1 GetRequest (org.sonarqube.ws.client.GetRequest)1 GlobalProperties (org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties)1 Builder (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleConfiguration.Builder)1 WsResponse (org.sonarsource.sonarlint.core.util.ws.WsResponse)1