瀏覽代碼

SONAR-20530 Set property to email type for validation

tags/10.3.0.82913
Eric Giffon 7 月之前
父節點
當前提交
72140ea167

+ 1
- 1
gradle.properties 查看文件

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

+ 28
- 1
server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java 查看文件

import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.groups.Tuple.tuple; 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.newComponentPropertyDto;
import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto; import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
import static org.sonar.db.user.UserTesting.newUserDto; import static org.sonar.db.user.UserTesting.newUserDto;
.containsOnly("key", "value", "values", "fieldValues", "component"); .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) { private void assertGlobalSetting(String key, String value) {
PropertyDto result = dbClient.propertiesDao().selectGlobalProperty(key); PropertyDto result = dbClient.propertiesDao().selectGlobalProperty(key);



+ 1
- 3
sonar-ws/src/main/protobuf/ws-settings.proto 查看文件

LICENSE = 13; LICENSE = 13;
JSON = 14; JSON = 14;
FORMATTED_TEXT = 15; FORMATTED_TEXT = 15;
EMAIL = 16;
} }


// Response of GET api/settings/values // Response of GET api/settings/values
map<string, string> value = 1; map<string, string> value = 1;
} }
} }




Loading…
取消
儲存