aboutsummaryrefslogtreecommitdiffstats
path: root/common-app-api/src
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java4
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java18
2 files changed, 21 insertions, 1 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
index dfecf927d8..fbc5e9de95 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
@@ -83,6 +83,7 @@ public class ValidationUtils {
public static final Pattern CLEAN_FILENAME_PATTERN = Pattern.compile("[\\x00-\\x1f\\x80-\\x9f\\x5c/<?>\\*:|\"/]+");
+ public static final Pattern YANG_MODULE_3GPP_PATTERN = Pattern.compile("^(_3gpp).*$");
public static final Pattern DASH_PATTERN = Pattern.compile("[-]+");
public static final Pattern UNDERSCORE_PATTERN = Pattern.compile("[_]+");
public static final Pattern PLUS_PATTERN = Pattern.compile("[+]+");
@@ -465,7 +466,8 @@ public class ValidationUtils {
str = normaliseWhitespace(str);
str = SPACE_PATTERN.matcher(str).replaceAll("-");
str = DASH_PATTERN.matcher(str).replaceAll("-");
- str = StringUtils.strip(str, "-_ .");
+ if (!YANG_MODULE_3GPP_PATTERN.matcher(str).matches())
+ str = StringUtils.strip(str, "-_ .");
return str;
}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java
index 2d5122a13f..e7aad96f60 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java
@@ -724,6 +724,24 @@ public class ValidationUtilsTest {
}
@Test
+ public void validateNormalizeFileNameFor3gppYangModule() {
+ final String testName = "_3gpptestfile";
+
+ String result = ValidationUtils.normalizeFileName(testName);
+
+ assertEquals(result, testName);
+ }
+
+ @Test
+ public void validateNormalizeFileNameStripLeadingUnderscore() {
+ final String testName = "_testfile";
+
+ String result = ValidationUtils.normalizeFileName(testName);
+
+ assertEquals(result, "testfile");
+ }
+
+ @Test
public void checkValidateUrlReturnsTrueIfURLIsValid() {
final String testUrl = "http://test.co/valid/url/";