]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20530 Set property to email type for validation
authorEric Giffon <eric.giffon@sonarsource.com>
Fri, 20 Oct 2023 08:47:11 +0000 (10:47 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 23 Oct 2023 20:02:42 +0000 (20:02 +0000)
gradle.properties
server/sonar-webserver-webapi/src/it/java/org/sonar/server/setting/ws/SetActionIT.java
sonar-ws/src/main/protobuf/ws-settings.proto

index 3028170da828def81159d49cf0bf18a960778039..7f938f46cca745fe613266b82e62810342490fde 100644 (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
index 38700bccd84025ec47feb446b2a38725e49358a4..2b3cd448ebca45bed2d1ed297f1c8a7e71b97a0d 100644 (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);
 
index 295d89664af881fd6291524b59898bb6c8249a82..03c410001215ce28fcc78330b703911d9b927a68 100644 (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;
   }
 }
-
-
-