use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class ValuesActionTest method return_project_settings_from_definitions_when_component_and_no_keys.
@Test
public void return_project_settings_from_definitions_when_component_and_no_keys() throws Exception {
logInAsProjectAdmin();
definitions.addComponents(asList(PropertyDefinition.builder("foo").onQualifiers(PROJECT).build(), PropertyDefinition.builder("secret.secured").onQualifiers(PROJECT).build(), PropertyDefinition.builder("plugin.license.secured").onQualifiers(PROJECT).type(LICENSE).build()));
propertyDb.insertProperties(newComponentPropertyDto(project).setKey("foo").setValue("one"), newComponentPropertyDto(project).setKey("secret.secured").setValue("password"), newComponentPropertyDto(project).setKey("plugin.license.secured").setValue("ABCD"));
ValuesWsResponse result = executeRequestForProjectProperties();
assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("foo", "secret.secured", "plugin.license.secured");
}
use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class ValuesActionTest method does_not_returned_secured_and_license_settings_in_property_set_when_not_authenticated.
@Test
public void does_not_returned_secured_and_license_settings_in_property_set_when_not_authenticated() throws Exception {
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"));
}
use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class ValuesActionTest method return_secured_and_license_settings_when_system_admin.
@Test
public void return_secured_and_license_settings_when_system_admin() throws Exception {
logInAsAdmin();
definitions.addComponents(asList(PropertyDefinition.builder("foo").build(), PropertyDefinition.builder("secret.secured").build(), PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"), newGlobalPropertyDto().setKey("secret.secured").setValue("password"), 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", "secret.secured", "plugin.license.secured", "sonar.plugin.licenseHash.secured");
}
use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class DefaultSettingsLoader method load.
@Override
public Map<String, String> load(@Nullable String componentKey) {
String url = "api/settings/values.protobuf";
Profiler profiler = Profiler.create(LOG);
if (componentKey != null) {
url += "?component=" + ScannerUtils.encodeForUrl(componentKey);
profiler.startInfo("Load settings for component '" + componentKey + "'");
} else {
profiler.startInfo("Load global settings");
}
try (InputStream is = wsClient.call(new GetRequest(url)).contentStream()) {
ValuesWsResponse values = ValuesWsResponse.parseFrom(is);
profiler.stopInfo();
return toMap(values.getSettingsList());
} catch (IOException e) {
throw new IllegalStateException("Failed to load server settings", e);
}
}
Aggregations