dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.10.0.1456'
dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.11.0.3905'
dependency 'org.sonarsource.slang:sonar-scala-plugin:1.11.0.3905'
- dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.11.0.290'
+ dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.12.0.310'
dependency 'org.sonarsource.xml:sonar-xml-plugin:2.6.1.3686'
dependency 'org.sonarsource.iac:sonar-iac-plugin:1.9.2.2279'
dependency 'org.sonarsource.text:sonar-text-plugin:1.1.0.282'
import org.sonar.db.component.ComponentDto;
import org.sonar.db.permission.GlobalPermission;
import org.sonar.db.property.PropertyDto;
+import org.sonar.markdown.Markdown;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.user.UserSession;
import org.sonarqube.ws.Settings;
import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.sonar.api.CoreProperties.SERVER_ID;
import static org.sonar.api.CoreProperties.SERVER_STARTTIME;
+import static org.sonar.api.PropertyType.FORMATTED_TEXT;
import static org.sonar.api.PropertyType.PROPERTY_SET;
import static org.sonar.api.web.UserRole.USER;
import static org.sonar.server.setting.ws.PropertySetExtractor.extractPropertySetKeys;
}
if (definition.type().equals(PROPERTY_SET)) {
valueBuilder.setFieldValues(createFieldValuesBuilder(filterVisiblePropertySets(setting.getPropertySets())));
+ } else if (definition.type().equals(FORMATTED_TEXT)) {
+ valueBuilder.setValues(createFormattedTextValuesBuilder(value));
} else if (definition.multiValues()) {
valueBuilder.setValues(createValuesBuilder(value));
} else {
return Settings.Values.newBuilder().addAllValues(values);
}
+ private Settings.Values.Builder createFormattedTextValuesBuilder(String value) {
+ List<String> values = List.of(value, Markdown.convertToHtml(value));
+ return Settings.Values.newBuilder().addAllValues(values);
+ }
+
private Settings.FieldValues.Builder createFieldValuesBuilder(List<Map<String, String>> fieldValues) {
Settings.FieldValues.Builder builder = Settings.FieldValues.newBuilder();
for (Map<String, String> propertySetMap : fieldValues) {
assertThat(value.getInherited()).isFalse();
}
+ @Test
+ public void return_formatted_values() {
+ logIn();
+ String propertyKey = "sonar.login.message";
+ definitions.addComponent(PropertyDefinition
+ .builder(propertyKey)
+ .type(PropertyType.FORMATTED_TEXT)
+ .build());
+ db.properties().insertProperties(null, null, null, null, newGlobalPropertyDto().setKey(propertyKey).setValue("[link](https://link.com)"));
+
+ ValuesWsResponse result = executeRequestForGlobalProperties(propertyKey);
+
+ assertThat(result.getSettingsList()).hasSize(1);
+ Settings.Setting value = result.getSettings(0);
+ assertThat(value.getKey()).isEqualTo(propertyKey);
+ assertThat(value.getValues().getValuesList())
+ .hasSize(2)
+ .containsExactly("[link](https://link.com)", "<a href=\"https://link.com\" target=\"_blank\">link</a>");
+ }
+
@Test
public void return_multi_values() {
logIn();