Browse Source

SONAR-20530 Set property to email type for validation

tags/10.3.0.82913
Eric Giffon 6 months ago
parent
commit
72140ea167

+ 1
- 1
gradle.properties View File

@@ -1,6 +1,6 @@
group=org.sonarsource.sonarqube
version=10.3
pluginApiVersion=10.1.0.809
pluginApiVersion=10.2.0.1908
description=Open source platform for continuous inspection of code quality
projectTitle=SonarQube
org.gradle.jvmargs=-Xmx2048m

+ 28
- 1
server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java View File

@@ -69,7 +69,6 @@ import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.groups.Tuple.tuple;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
import static org.sonar.db.user.UserTesting.newUserDto;
@@ -1138,6 +1137,34 @@ public class SetActionIT {
.containsOnly("key", "value", "values", "fieldValues", "component");
}

@Test
public void call_whenEmailPropertyValid_shouldSucceed() {
definitions.addComponent(PropertyDefinition
.builder("my.key")
.name("foo")
.description("desc")
.type(PropertyType.EMAIL)
.build());

callForGlobalSetting("my.key", "test@sonarsource.com");
assertGlobalSetting("my.key", "test@sonarsource.com");
}

@Test
public void call_whenEmailPropertyInvalid_shouldFail() {
definitions.addComponent(PropertyDefinition
.builder("my.key")
.name("foo")
.description("desc")
.type(PropertyType.EMAIL)
.build());
i18n.put("property.error.notEmail", "Not a valid email address");

assertThatThrownBy(() -> callForGlobalSetting("my.key", "test1@sonarsource.com,test2@sonarsource.com"))
.isInstanceOf(BadRequestException.class)
.hasMessage("Not a valid email address");
}

private void assertGlobalSetting(String key, String value) {
PropertyDto result = dbClient.propertiesDao().selectGlobalProperty(key);


+ 1
- 3
sonar-ws/src/main/protobuf/ws-settings.proto View File

@@ -83,6 +83,7 @@ enum Type {
LICENSE = 13;
JSON = 14;
FORMATTED_TEXT = 15;
EMAIL = 16;
}

// Response of GET api/settings/values
@@ -117,6 +118,3 @@ message FieldValues {
map<string, string> value = 1;
}
}




Loading…
Cancel
Save