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() {
logIn();
definitions.addComponents(asList(PropertyDefinition.builder("defaultProperty").defaultValue("default").build(), PropertyDefinition.builder("globalProperty").build()));
propertyDb.insertProperties(null, null, null, null, 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);
}
use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class ValuesActionTest method return_secured_settings_in_property_set_when_system_admin.
@Test
public void return_secured_settings_in_property_set_when_system_admin() {
logInAsAdmin();
definitions.addComponent(PropertyDefinition.builder("foo").type(PropertyType.PROPERTY_SET).fields(asList(PropertyFieldDefinition.build("key").name("Key").build(), PropertyFieldDefinition.build("secret.secured").name("Secured").build())).build());
propertyDb.insertPropertySet("foo", null, ImmutableMap.of("key", "key1", "secret.secured", "123456"));
ValuesWsResponse result = executeRequestForGlobalProperties();
assertFieldValues(result.getSettings(0), ImmutableMap.of("key", "key1", "secret.secured", "123456"));
}
use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class ValuesActionTest method return_secured_settings_even_if_not_defined_when_project_admin.
@Test
public void return_secured_settings_even_if_not_defined_when_project_admin() {
logInAsProjectAdmin();
propertyDb.insertProperties(null, project.getKey(), project.name(), project.qualifier(), newComponentPropertyDto(project).setKey("not-defined.secured").setValue("123"));
ValuesWsResponse result = executeRequestForProjectProperties("not-defined.secured");
assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).isEmpty();
assertThat(result.getSetSecuredSettingsList()).containsOnly("not-defined.secured");
}
use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class ValuesActionTest method global_secured_properties_require_system_admin_permission.
@Test
public void global_secured_properties_require_system_admin_permission() {
PropertyDefinition securedDef = PropertyDefinition.builder("my.password.secured").build();
PropertyDefinition standardDef = PropertyDefinition.builder("my.property").build();
definitions.addComponents(asList(securedDef, standardDef));
propertyDb.insertProperties(null, null, null, null, newGlobalPropertyDto().setKey(securedDef.key()).setValue("securedValue"), newGlobalPropertyDto().setKey(standardDef.key()).setValue("standardValue"));
// anonymous
WsActionTester tester = newTester();
ValuesWsResponse response = executeRequest(tester, null, securedDef.key(), standardDef.key());
assertThat(response.getSettingsList()).extracting(Settings.Setting::getKey).containsExactly("my.property");
// only scan global permission
userSession.logIn().addPermission(GlobalPermission.SCAN);
response = executeRequest(tester, null, securedDef.key(), standardDef.key());
assertThat(response.getSetSecuredSettingsList()).contains("my.password.secured");
// global administrator
userSession.logIn().addPermission(GlobalPermission.ADMINISTER);
response = executeRequest(tester, null, securedDef.key(), standardDef.key());
assertThat(response.getSetSecuredSettingsList()).contains("my.password.secured");
// system administrator
userSession.logIn().setSystemAdministrator();
response = executeRequest(tester, null, securedDef.key(), standardDef.key());
assertThat(response.getSetSecuredSettingsList()).contains("my.password.secured");
}
use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.
the class ValuesActionTest method do_not_return_secured_settings_in_property_set_when_not_authenticated.
@Test
public void do_not_return_secured_settings_in_property_set_when_not_authenticated() {
definitions.addComponent(PropertyDefinition.builder("foo").type(PropertyType.PROPERTY_SET).fields(asList(PropertyFieldDefinition.build("key").name("Key").build(), PropertyFieldDefinition.build("secret.secured").name("Secured").build())).build());
propertyDb.insertPropertySet("foo", null, ImmutableMap.of("key", "key1", "secret.secured", "123456"));
ValuesWsResponse result = executeRequestForGlobalProperties();
assertFieldValues(result.getSettings(0), ImmutableMap.of("key", "key1"));
}
Aggregations