summaryrefslogtreecommitdiffstats
path: root/csarvalidation
diff options
context:
space:
mode:
Diffstat (limited to 'csarvalidation')
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java41
-rw-r--r--csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java19
-rw-r--r--csarvalidation/src/test/resources/testR02454.csarbin0 -> 4952 bytes
4 files changed, 63 insertions, 1 deletions
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java b/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java
index 29c4bdf..5f4e053 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java
@@ -45,6 +45,10 @@ public class CommonConstants {
public static final String MAINSERV_TEMPLATE = "MainServiceTemplate.yaml";
+ public static final String TOSCA_SWIMAGE = "tosca.artifacts.nfv.SwImage";
+
+ public static final String TOSCA_IMAGE = "tosca.artifacts.Deployment.Image";
+
public static final String CSAR_SUFFIX = ".csar";
public static final String HTTP_HEADER_CONTENT_RANGE = "Content-Range";
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
index 88cd0e0..d27aa5a 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
@@ -108,6 +108,8 @@ public class CsarValidator {
String vms = validateMainService();
+ //String r02454 = r02454();
+
if((CommonConstants.SUCCESS_STR != vsm) && (CommonConstants.SUCCESS_STR != vms)) {
return vsm + " OR " + vms;
@@ -116,7 +118,11 @@ public class CsarValidator {
if(CommonConstants.SUCCESS_STR != vtm) {
return vtm;
}
-
+/*
+ if (CommonConstants.SUCCESS_STR != r02454) {
+ return r02454;
+ }
+*/
return CommonConstants.SUCCESS_STR;
}
@@ -291,12 +297,45 @@ public class CsarValidator {
if(!Paths.get(MAINSERV_TEMPLATE).isAbsolute()) {
mainservTemplate = csarFiles.get(FilenameUtils.getName(mainservTemplate));
}
+
if(StringUtils.isEmpty(mainservTemplate)) {
return "MainServiceTemplate does not exist in the package";
}
return CommonConstants.SUCCESS_STR;
}
+ /*
+ * @Author: Victor Gao
+ * @Description:
+ * @Date: 2018/9/18
+ * @Param: [filePath]
+ * @return: boolean
+ **/
+ public static String r02454() {
+ String mainservTemplate = MAINSERV_TEMPLATE;
+ mainservTemplate = csarFiles.get(FilenameUtils.getName(mainservTemplate));
+
+ //TODO: Fixme R3 only check the existence of swImage filed inside VNFD.
+ File file = new File(mainservTemplate);
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
+ String tempString = null;
+ while ((tempString = reader.readLine()) != null) {
+ if (tempString.contains((CommonConstants.TOSCA_SWIMAGE))) {
+ return CommonConstants.SUCCESS_STR;
+ }
+ }
+ } catch(IOException e2) {
+ return ("CSAR_META_VALIDATION" + ":" + "Exception caught while validateCsarMeta ! " + ErrorCodes.FILE_IO
+ + e2);
+ }
+
+ if(StringUtils.isEmpty(mainservTemplate)) {
+ return "Can not find the swImage inside Mainservicetemplate";
+ }
+
+ return "Can not find the swImage inside Mainservicetemplate";
+ }
+
private static String checkEntryFor(String fileWithPath, String attribute) throws IOException {
List<String> lines = Files.readAllLines(Paths.get(fileWithPath), UTF_8);
diff --git a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
index 5693ba6..f9a8d8a 100644
--- a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
+++ b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
@@ -58,6 +58,12 @@ public class CsarValidatorTest {
String packageId2 = UUID.randomUUID().toString();
+ private String cf = classLoader.getResource("testR02454.csar").getFile();
+
+ String sample = System.getProperty("file.separator") + cf.substring(1);
+
+ String pkgid = UUID.randomUUID().toString();
+
private String csarFile3 = classLoader.getResource("vIMS_NS.csar").getFile();
String sample3 = System.getProperty("file.separator") + csarFile3.substring(1);
@@ -127,17 +133,25 @@ public class CsarValidatorTest {
testValidateCsarIntegrity(csarValidator5);
testValidateToscaMeta(csarValidator5);
testValidateMainService(csarValidator5);
+
+ CsarValidator csarValidator6 = new CsarValidator(pkgid, sample);
+ testValidateCsarIntegrity(csarValidator6);
+ testValidateToscaMeta(csarValidator6);
+ testValidateMainService(csarValidator6);
+ testR02454(csarValidator6);
// Rel1 specific test case
String sample1Dir = sample1.replace(".csar", "");
String sample2Dir = sample2.replace(".csar", "");
String sample3Dir = sample3.replace(".csar", "");
String sample4Dir = sample4.replace(".csar", "");
String sample5Dir = sample5.replace(".csar", "");
+ String sampleDir = sample.replace(".csar", "");
boolean result = FileUtil.deleteDirectory(sample1Dir);
boolean result1 = FileUtil.deleteDirectory(sample2Dir);
boolean result2 = FileUtil.deleteDirectory(sample3Dir);
boolean result3 = FileUtil.deleteDirectory(sample4Dir);
boolean result4 = FileUtil.deleteDirectory(sample5Dir);
+ boolean result5 = FileUtil.deleteDirectory(sampleDir);
assertEquals(true, result == true && result1 == true && result2 == true && result3 == true && result4 == true);
}
@@ -200,4 +214,9 @@ public class CsarValidatorTest {
String result = CsarValidator.validateCsar();
assertEquals(true, result == CommonConstants.SUCCESS_STR);
}
+
+ private void testR02454(CsarValidator cv) {
+ String result = CsarValidator.r02454();
+ assertEquals(true, result == CommonConstants.SUCCESS_STR);
+ }
}
diff --git a/csarvalidation/src/test/resources/testR02454.csar b/csarvalidation/src/test/resources/testR02454.csar
new file mode 100644
index 0000000..2cf70eb
--- /dev/null
+++ b/csarvalidation/src/test/resources/testR02454.csar
Binary files differ