Search in sources :

Example 1 with ValuesWsResponse

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

the class ValuesActionTest method return_secured_and_license_settings_in_property_set_when_system_admin.

@Test
public void return_secured_and_license_settings_in_property_set_when_system_admin() throws Exception {
    logInAsAdmin();
    definitions.addComponent(PropertyDefinition.builder("foo").type(PropertyType.PROPERTY_SET).fields(asList(PropertyFieldDefinition.build("key").name("Key").build(), PropertyFieldDefinition.build("plugin.license.secured").name("License").type(LICENSE).build(), PropertyFieldDefinition.build("secret.secured").name("Secured").build())).build());
    propertyDb.insertPropertySet("foo", null, ImmutableMap.of("key", "key1", "plugin.license.secured", "ABCD", "secret.secured", "123456"));
    ValuesWsResponse result = executeRequestForGlobalProperties();
    assertFieldValues(result.getSettings(0), ImmutableMap.of("key", "key1", "plugin.license.secured", "ABCD", "secret.secured", "123456"));
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Example 2 with ValuesWsResponse

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

the class ValuesActionTest method return_secured_and_license_settings_even_if_not_defined_when_project_admin.

@Test
public void return_secured_and_license_settings_even_if_not_defined_when_project_admin() throws Exception {
    logInAsProjectAdmin();
    propertyDb.insertProperties(newComponentPropertyDto(project).setKey("not-defined.secured").setValue("123"));
    ValuesWsResponse result = executeRequestForProjectProperties("not-defined.secured");
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("not-defined.secured");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 3 with ValuesWsResponse

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

the class LicensesPageTest method change_licenses.

@Test
public void change_licenses() {
    String EXAMPLE_LICENSE = "TmFtZTogRGV2ZWxvcHBlcnMKUGx1Z2luOiBhdXRvY29udHJvbApFeHBpcmVzOiAyMDEyLTA0LTAxCktleTogNjI5N2MxMzEwYzg2NDZiZTE5MDU1MWE4ZmZmYzk1OTBmYzEyYTIyMgo=";
    LicensesPage page = nav.logIn().asAdmin().openLicenses();
    LicenseItem licenseItem = page.getLicenseByKey("typed.license.secured");
    licenseItem.setLicense(EXAMPLE_LICENSE);
    ValuesWsResponse response = wsClient.settingsService().values(ValuesRequest.builder().setKeys("typed.license.secured").build());
    assertThat(response.getSettings(0).getValue()).isEqualTo(EXAMPLE_LICENSE);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) LicensesPage(pageobjects.licenses.LicensesPage) LicenseItem(pageobjects.licenses.LicenseItem) Test(org.junit.Test)

Example 4 with ValuesWsResponse

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

the class SettingsTest method getSetting.

@CheckForNull
private static Setting getSetting(String key, SettingsService settingsService) {
    ValuesWsResponse response = settingsService.values(ValuesRequest.builder().setKeys(key).build());
    List<Settings.Setting> settings = response.getSettingsList();
    return settings.isEmpty() ? null : settings.get(0);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Setting(org.sonarqube.ws.Settings.Setting) CheckForNull(javax.annotation.CheckForNull)

Example 5 with ValuesWsResponse

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

the class ValuesActionTest method return_license_with_hash_settings_when_authenticated_but_not_admin.

@Test
public void return_license_with_hash_settings_when_authenticated_but_not_admin() throws Exception {
    logIn();
    definitions.addComponents(asList(PropertyDefinition.builder("foo").build(), PropertyDefinition.builder("secret.secured").build(), PropertyDefinition.builder("commercial.plugin").type(LICENSE).build(), PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"), newGlobalPropertyDto().setKey("secret.secured").setValue("password"), newGlobalPropertyDto().setKey("commercial.plugin").setValue("ABCD"), 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("foo", "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)

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