summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/test
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2019-07-03 13:48:25 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2019-07-08 12:42:31 +0200
commitb67f6263e48bfcf51c157a9cd7fe774353cc5f38 (patch)
treefb70dc757c5c4534d8c55e0096ea33c901eb4d44 /csarvalidation/src/test
parentd0c919b17b851d54f0588e18bad071643f95e4e8 (diff)
Option 1 - pnf only
Change-Id: I9af3bb9b0682d7babed16042c5cac948db5dd822 Issue-ID: VNFSDK-396 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
Diffstat (limited to 'csarvalidation/src/test')
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java19
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java86
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java46
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java22
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java79
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/security/ShaHashCodeGeneratorTest.java54
-rw-r--r--csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf18
-rw-r--r--csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoBeginMarker.mf41
-rw-r--r--csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoEndMarker.mf41
-rw-r--r--csarvalidation/src/test/resources/pnf/MainServiceTemplateCMSSectionNotAtTheEnd.mf41
-rw-r--r--csarvalidation/src/test/resources/pnf/MainServiceTemplateWithBrokenSourcesSection.mf37
-rw-r--r--csarvalidation/src/test/resources/pnf/dummyPnfv2.csarbin4038 -> 4451 bytes
-rw-r--r--csarvalidation/src/test/resources/pnf/r787966/csar-option1-invalid.csarbin0 -> 5737 bytes
-rw-r--r--csarvalidation/src/test/resources/pnf/r787966/csar-option1-valid.csarbin0 -> 6571 bytes
14 files changed, 465 insertions, 19 deletions
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
index 810ef0f..bc27ed1 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
@@ -18,6 +18,7 @@ package org.onap.cvc.csar;
import com.google.common.collect.Lists;
import org.junit.Test;
+import org.onap.cvc.csar.parser.SourcesParser;
import java.util.List;
import java.util.Map;
@@ -26,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PnfCSARArchiveTest {
- public static final String SOURCE_TAG = "Source";
+ private static final String SOURCE_TAG = "Source";
@Test
public void shouldUseDataStoredInManifestMfFileToConfigurePnfCSARArchive() throws Exception {
@@ -41,8 +42,10 @@ public class PnfCSARArchiveTest {
// then
PnfCSARArchive.PnfManifest manifest = (PnfCSARArchive.PnfManifest) pnfCSARArchive.getManifest();
verifyThatMetadataWasSet(manifest);
+ verifyThatCmsSectionWasSet(manifest);
verifyThatSourcesSectionWasSet(manifest);
verifyThatNonManoArtifactsWereSet(manifest);
+ assertThat(pnfCSARArchive.getErrors().size()).isEqualTo(0);
}
}
@@ -57,8 +60,18 @@ public class PnfCSARArchiveTest {
private void verifyThatSourcesSectionWasSet(PnfCSARArchive.PnfManifest manifest) {
- List<String> sources = manifest.getSources();
- assertThat(sources).contains("Definitions/MainServiceTemplate.yaml", "Definitions/etsi_nfv_sol001_vnfd_2_5_1_types.yaml");
+ List<SourcesParser.Source> sources = manifest.getSources();
+ assertThat(sources).contains(
+ new SourcesParser.Source("MRF.yaml", "SHA-256", "09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943"),
+ new SourcesParser.Source("scripts/install.sh", "SHA-256", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"),
+ new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165")
+ );
+ }
+
+ private void verifyThatCmsSectionWasSet(PnfCSARArchive.PnfManifest manifest) {
+
+ String cms = manifest.getCms();
+ assertThat(cms).isEqualTo("MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcNAQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUMdvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=");
}
private void verifyThatNonManoArtifactsWereSet(PnfCSARArchive.PnfManifest manifest) {
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
index 09a2706..3ba37aa 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
@@ -19,10 +19,10 @@ import com.google.common.collect.Lists;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.Test;
+import org.onap.cvc.csar.parser.SourcesParser;
import java.io.File;
import java.io.IOException;
-import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
@@ -34,7 +34,7 @@ public class PnfManifestParserTest {
private PnfManifestParser pnfManifestParser;
@Before
- public void setUp() throws URISyntaxException, IOException {
+ public void setUp() throws IOException {
pnfManifestParser = PnfManifestParser.getInstance(new File("./src/test/resources/pnf/MainServiceTemplate.mf"));
}
@@ -42,7 +42,7 @@ public class PnfManifestParserTest {
public void shouldFetchMetadataFromFile() {
Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> metadataListPair = pnfManifestParser.fetchMetadata();
CSARArchive.Manifest.Metadata metadata = metadataListPair.getKey();
- List<CSARArchive.CSARError> errors= metadataListPair.getValue();
+ List<CSARArchive.CSARError> errors = metadataListPair.getValue();
assertThat(metadata.getProductName()).isEqualTo("RadioNode");
assertThat(metadata.getProviderId()).isEqualTo("Ericsson");
@@ -55,21 +55,41 @@ public class PnfManifestParserTest {
@Test
public void shouldFetchSourcesSectionFromFile() {
- Pair<List<String>, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchSourcesSection();
- List<String> sources = sourcesPair.getKey();
+ Pair<List<SourcesParser.Source>, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchSourcesSection();
+ List<SourcesParser.Source> sources = sourcesPair.getKey();
List<CSARArchive.CSARError> errors = sourcesPair.getValue();
- assertThat(sources).contains("Definitions/MainServiceTemplate.yaml", "Definitions/etsi_nfv_sol001_vnfd_2_5_1_types.yaml");
+ assertThat(sources).contains(
+ new SourcesParser.Source("MRF.yaml", "SHA-256", "09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943"),
+ new SourcesParser.Source("scripts/install.sh", "SHA-256", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"),
+ new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", "36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165")
+ );
assertThat(errors.size()).isEqualTo(0);
}
+ @Test
+ public void shouldFetchSourcesFromBrokenFile() throws IOException {
+
+ pnfManifestParser = PnfManifestParser.getInstance(new File("./src/test/resources/pnf/MainServiceTemplateWithBrokenSourcesSection.mf"));
+ Pair<List<SourcesParser.Source>, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchSourcesSection();
+ List<SourcesParser.Source> sources = sourcesPair.getKey();
+ List<CSARArchive.CSARError> errors = sourcesPair.getValue();
+
+ assertThat(sources).contains(
+ new SourcesParser.Source("MRF.yaml", "SHA-256", "09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943"),
+ new SourcesParser.Source("some_file.sh", "", ""),
+ new SourcesParser.Source("scripts/install.sh", "", "d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b"),
+ new SourcesParser.Source("https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh", "SHA-256", ""));
+ assertThat(errors.size()).isEqualTo(0);
+ }
+
@Test
public void shouldFetchNonManoArtifactsFromFile() {
Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> mapListPair = pnfManifestParser.fetchNonManoArtifacts().get();
Map<String, Map<String, List<String>>> nonManoArtifacts = mapListPair.getKey();
- List<CSARArchive.CSARError> errors= mapListPair.getValue();
+ List<CSARArchive.CSARError> errors = mapListPair.getValue();
assertThat(nonManoArtifacts.get("onap_ves_events").get("source"))
.isEqualTo(Lists.newArrayList("Artifacts/Events/VES_registration.yml")
@@ -90,4 +110,56 @@ public class PnfManifestParserTest {
);
assertThat(errors.size()).isEqualTo(0);
}
+
+
+ @Test
+ public void shouldFetchCMS() {
+
+ Pair<String, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchCMS();
+ String cms = sourcesPair.getKey();
+ List<CSARArchive.CSARError> errors = sourcesPair.getValue();
+
+ assertThat(cms).isEqualTo(
+ "MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN" +
+ "AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM" +
+ "dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0="
+ );
+ assertThat(errors.size()).isEqualTo(0);
+ }
+
+ @Test
+ public void shouldReportAnErrorWhenCMSSectionDoesNotHaveEndingMarker() throws IOException {
+ pnfManifestParser = PnfManifestParser.getInstance(new File("./src/test/resources/pnf/MainServiceTemplateBrokenCMSNoEndMarker.mf"));
+ Pair<String, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchCMS();
+ String cms = sourcesPair.getKey();
+ List<CSARArchive.CSARError> errors = sourcesPair.getValue();
+
+ assertThat(cms).isEmpty();
+ assertThat(errors.size()).isEqualTo(1);
+ assertThat(errors.get(0).getMessage()).isEqualTo("Invalid. Entry [Unable to find END CMS marker!]");
+ }
+
+ @Test
+ public void shouldReturnEmptyCmsWhenBeginMarkerDoesNotExist() throws IOException {
+ pnfManifestParser = PnfManifestParser.getInstance(new File("./src/test/resources/pnf/MainServiceTemplateBrokenCMSNoBeginMarker.mf"));
+ Pair<String, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchCMS();
+ String cms = sourcesPair.getKey();
+ List<CSARArchive.CSARError> errors = sourcesPair.getValue();
+
+ assertThat(cms).isEmpty();
+ assertThat(errors.size()).isEqualTo(1);
+ assertThat(errors.get(0).getMessage()).isEqualTo("Invalid. Entry [Unable to find BEGIN CMS marker!]");
+ }
+
+
+ @Test
+ public void shouldReportAnErrorWhenCMSIsNotAtTheEndOfFile() throws IOException {
+ pnfManifestParser = PnfManifestParser.getInstance(new File("./src/test/resources/pnf/MainServiceTemplateCMSSectionNotAtTheEnd.mf"));
+ Pair<String, List<CSARArchive.CSARError>> sourcesPair = pnfManifestParser.fetchCMS();
+
+ List<CSARArchive.CSARError> errors = sourcesPair.getValue();
+
+ assertThat(errors.size()).isEqualTo(1);
+ assertThat(errors.get(0).getMessage()).isEqualTo("Invalid. Entry [CMS section is not at the end of file!]");
+ }
} \ No newline at end of file
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
index 3d46334..c409efc 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
@@ -18,6 +18,10 @@ package org.onap.cvc.csar;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Test;
+import org.onap.cvc.csar.parser.CmsParser;
+import org.onap.cvc.csar.parser.MetadataParser;
+import org.onap.cvc.csar.parser.NonManoArtifactsParser;
+import org.onap.cvc.csar.parser.SourcesParser;
import java.util.List;
import java.util.stream.Collectors;
@@ -26,6 +30,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PnfMetadataParserTest {
+ private static final String FILE_NAME = "fileName";
+
@Test
public void shouldReportAnErrorWhenMetadataSectionIsNotAvailable() {
// given
@@ -38,7 +44,13 @@ public class PnfMetadataParserTest {
// when
- PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
+ PnfManifestParser pnfManifestParser = new PnfManifestParser(
+ lines,
+ new MetadataParser(FILE_NAME),
+ new SourcesParser(FILE_NAME),
+ new NonManoArtifactsParser(),
+ new CmsParser(FILE_NAME)
+ );
Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchMetadata();
//then
@@ -64,7 +76,13 @@ public class PnfMetadataParserTest {
);
// when
- PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
+ PnfManifestParser pnfManifestParser = new PnfManifestParser(
+ lines,
+ new MetadataParser(FILE_NAME),
+ new SourcesParser(FILE_NAME),
+ new NonManoArtifactsParser(),
+ new CmsParser(FILE_NAME)
+ );
Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchMetadata();
//then
@@ -93,7 +111,13 @@ public class PnfMetadataParserTest {
);
// when
- PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
+ PnfManifestParser pnfManifestParser = new PnfManifestParser(
+ lines,
+ new MetadataParser(FILE_NAME),
+ new SourcesParser(FILE_NAME),
+ new NonManoArtifactsParser(),
+ new CmsParser(FILE_NAME)
+ );
Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchMetadata();
//then
@@ -118,7 +142,13 @@ public class PnfMetadataParserTest {
);
// when
- PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
+ PnfManifestParser pnfManifestParser = new PnfManifestParser(
+ lines,
+ new MetadataParser(FILE_NAME),
+ new SourcesParser(FILE_NAME),
+ new NonManoArtifactsParser(),
+ new CmsParser(FILE_NAME)
+ );
Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchMetadata();
//then
@@ -142,7 +172,13 @@ public class PnfMetadataParserTest {
);
// when
- PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
+ PnfManifestParser pnfManifestParser = new PnfManifestParser(
+ lines,
+ new MetadataParser(FILE_NAME),
+ new SourcesParser(FILE_NAME),
+ new NonManoArtifactsParser(),
+ new CmsParser(FILE_NAME)
+ );
Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchMetadata();
//then
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
index 92733bb..388a98f 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
@@ -18,6 +18,10 @@ package org.onap.cvc.csar;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Test;
+import org.onap.cvc.csar.parser.CmsParser;
+import org.onap.cvc.csar.parser.MetadataParser;
+import org.onap.cvc.csar.parser.NonManoArtifactsParser;
+import org.onap.cvc.csar.parser.SourcesParser;
import java.util.List;
import java.util.Map;
@@ -27,6 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class PnfNonManoArtifactsParserTest {
+ private static final String FILE_NAME = "fileName";
+
@Test
public void shouldDoNotReportAnErrorWhenNonManoArtifactSectionIsNotAvailable() {
// given
@@ -39,7 +45,13 @@ public class PnfNonManoArtifactsParserTest {
// when
- PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
+ PnfManifestParser pnfManifestParser = new PnfManifestParser(
+ lines,
+ new MetadataParser(FILE_NAME),
+ new SourcesParser(FILE_NAME),
+ new NonManoArtifactsParser(),
+ new CmsParser(FILE_NAME)
+ );
Optional<Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>>> nonManoArtifacts =
pnfManifestParser.fetchNonManoArtifacts();
@@ -65,7 +77,13 @@ public class PnfNonManoArtifactsParserTest {
);
// when
- PnfManifestParser pnfManifestParser = new PnfManifestParser(lines, "fileName");
+ PnfManifestParser pnfManifestParser = new PnfManifestParser(
+ lines,
+ new MetadataParser(FILE_NAME),
+ new SourcesParser(FILE_NAME),
+ new NonManoArtifactsParser(),
+ new CmsParser(FILE_NAME)
+ );
Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> data = pnfManifestParser.fetchNonManoArtifacts().get();
//then
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java
new file mode 100644
index 0000000..eccfe4b
--- /dev/null
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/VTPValidateCSARR787966IntegrationTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2019 Nokia
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.onap.cvc.csar.cc.sol004;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.cvc.csar.CSARArchive;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.configureTestCase;
+import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.convertToMessagesList;
+
+
+public class VTPValidateCSARR787966IntegrationTest {
+
+ private VTPValidateCSARR787966 testCase;
+
+ @Before
+ public void setUp() {
+ testCase = new VTPValidateCSARR787966();
+ }
+
+ @Test
+ public void shouldReturnProperRequestNumber() {
+ assertThat(testCase.getVnfReqsNo()).isEqualTo("R787966");
+ }
+
+ @Test
+ public void shouldValidateProperCsar() throws Exception {
+
+ // given
+ configureTestCase(testCase, "pnf/r787966/csar-option1-valid.csar");
+
+ // when
+ testCase.execute();
+
+ // then
+ List<CSARArchive.CSARError> errors = testCase.getErrors();
+ assertThat(errors.size()).isEqualTo(0);
+ }
+
+ @Test
+ public void shouldReportErrorsForInvalidCsar() throws Exception {
+
+ // given
+ configureTestCase(testCase, "pnf/r787966/csar-option1-invalid.csar");
+
+ // when
+ testCase.execute();
+
+ // then
+ List<CSARArchive.CSARError> errors = testCase.getErrors();
+ assertThat(errors.size()).isEqualTo(3);
+ assertThat(convertToMessagesList(errors)).contains(
+ "Unable to find CMS section in manifest!",
+ "Source 'Definitions/MainServiceTemplate.yaml' has wrong hash!",
+ "Source 'Artifacts/Other/my_script.csh' has hash, but unable to find algorithm tag!"
+ );
+ }
+
+
+} \ No newline at end of file
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/security/ShaHashCodeGeneratorTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/security/ShaHashCodeGeneratorTest.java
new file mode 100644
index 0000000..1ea5dd5
--- /dev/null
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/security/ShaHashCodeGeneratorTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2019 Nokia
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.onap.cvc.csar.security;
+
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.security.NoSuchAlgorithmException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ShaHashCodeGeneratorTest {
+
+ private ShaHashCodeGenerator shaHashCodeGenerator;
+
+ @Before
+ public void setUp(){
+ shaHashCodeGenerator = new ShaHashCodeGenerator();
+ }
+
+ @Test
+ public void shouldGenerateHashCodeSHA256() throws NoSuchAlgorithmException {
+
+ final String hashCode = shaHashCodeGenerator.generateSha256("test".getBytes());
+
+ assertThat(hashCode).isEqualTo(shaHashCodeGenerator.generateSha256("test".getBytes()));
+ assertThat(hashCode).isNotEqualTo(shaHashCodeGenerator.generateSha256("Test".getBytes()));
+ }
+
+ @Test
+ public void shouldGenerateHashCodeSHA512() throws NoSuchAlgorithmException {
+
+ final String hashCode = shaHashCodeGenerator.generateSha512("test".getBytes());
+
+ assertThat(hashCode).isEqualTo(shaHashCodeGenerator.generateSha512("test".getBytes()));
+ assertThat(hashCode).isNotEqualTo(shaHashCodeGenerator.generateSha512("Test".getBytes()));
+ }
+} \ No newline at end of file
diff --git a/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf b/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf
index 4ffa857..6987eb1 100644
--- a/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf
+++ b/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf
@@ -5,8 +5,17 @@ metadata:
pnfd_release_date_time: 2019-01-14T11:25:00+00:00
#The manifest file shall include a list of all files contained in or referenced from the VNF package with their location
-source: Definitions/MainServiceTemplate.yaml
-source: Definitions/etsi_nfv_sol001_vnfd_2_5_1_types.yaml
+Source: MRF.yaml
+Algorithm: SHA-256
+Hash: 09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943
+
+Source: scripts/install.sh
+Algorithm: SHA-256
+Hash: d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b
+
+Source: https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
non_mano_artifact_sets:
@@ -25,3 +34,8 @@ non_mano_artifact_sets:
source: Artifacts/Other/installation_guide.txt
source: Artifacts/Other/review_log.txt
+-----BEGIN CMS-----
+MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN
+AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM
+dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=
+-----END CMS----- \ No newline at end of file
diff --git a/csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoBeginMarker.mf b/csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoBeginMarker.mf
new file mode 100644
index 0000000..071588b
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoBeginMarker.mf
@@ -0,0 +1,41 @@
+metadata:
+ pnfd_name: RadioNode
+ pnfd_provider: Ericsson
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-01-14T11:25:00+00:00
+
+#The manifest file shall include a list of all files contained in or referenced from the VNF package with their location
+Source: MRF.yaml
+Algorithm: SHA-256
+Hash: 09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943
+
+Source: scripts/install.sh
+Algorithm: SHA-256
+Hash: d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b
+
+Source: https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN
+AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM
+dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=
+-----END CMS-----
+
+non_mano_artifact_sets:
+
+ onap_ves_events:
+ source: Artifacts/Events/VES_registration.yml
+
+ onap_pm_dictionary:
+ source: Artifacts/Measurements/PM_Dictionary.yaml
+
+ onap_yang_module:
+ source: Artifacts/Yang_module/Yang_module.yaml
+
+ onap_others:
+ source: Artifacts/scripts/install.sh
+ source: Artifacts/Informational/user_guide.txt
+ source: Artifacts/Other/installation_guide.txt
+ source: Artifacts/Other/review_log.txt
+
diff --git a/csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoEndMarker.mf b/csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoEndMarker.mf
new file mode 100644
index 0000000..66f93b8
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/MainServiceTemplateBrokenCMSNoEndMarker.mf
@@ -0,0 +1,41 @@
+metadata:
+ pnfd_name: RadioNode
+ pnfd_provider: Ericsson
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-01-14T11:25:00+00:00
+
+#The manifest file shall include a list of all files contained in or referenced from the VNF package with their location
+Source: MRF.yaml
+Algorithm: SHA-256
+Hash: 09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943
+
+Source: scripts/install.sh
+Algorithm: SHA-256
+Hash: d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b
+
+Source: https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+-----BEGIN CMS-----
+MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN
+AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM
+dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=
+
+non_mano_artifact_sets:
+
+ onap_ves_events:
+ source: Artifacts/Events/VES_registration.yml
+
+ onap_pm_dictionary:
+ source: Artifacts/Measurements/PM_Dictionary.yaml
+
+ onap_yang_module:
+ source: Artifacts/Yang_module/Yang_module.yaml
+
+ onap_others:
+ source: Artifacts/scripts/install.sh
+ source: Artifacts/Informational/user_guide.txt
+ source: Artifacts/Other/installation_guide.txt
+ source: Artifacts/Other/review_log.txt
+
diff --git a/csarvalidation/src/test/resources/pnf/MainServiceTemplateCMSSectionNotAtTheEnd.mf b/csarvalidation/src/test/resources/pnf/MainServiceTemplateCMSSectionNotAtTheEnd.mf
new file mode 100644
index 0000000..95890ae
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/MainServiceTemplateCMSSectionNotAtTheEnd.mf
@@ -0,0 +1,41 @@
+metadata:
+ pnfd_name: RadioNode
+ pnfd_provider: Ericsson
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-01-14T11:25:00+00:00
+
+#The manifest file shall include a list of all files contained in or referenced from the VNF package with their location
+Source: MRF.yaml
+Algorithm: SHA-256
+Hash: 09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943
+
+Source: scripts/install.sh
+Algorithm: SHA-256
+Hash: d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b
+
+Source: https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh
+Algorithm: SHA-256
+Hash: 36f945953929812aca2701b114b068c71bd8c95ceb3609711428c26325649165
+
+-----BEGIN CMS-----
+MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN
+AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM
+dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=
+-----END CMS-----
+
+non_mano_artifact_sets:
+
+ onap_ves_events:
+ source: Artifacts/Events/VES_registration.yml
+
+ onap_pm_dictionary:
+ source: Artifacts/Measurements/PM_Dictionary.yaml
+
+ onap_yang_module:
+ source: Artifacts/Yang_module/Yang_module.yaml
+
+ onap_others:
+ source: Artifacts/scripts/install.sh
+ source: Artifacts/Informational/user_guide.txt
+ source: Artifacts/Other/installation_guide.txt
+ source: Artifacts/Other/review_log.txt
diff --git a/csarvalidation/src/test/resources/pnf/MainServiceTemplateWithBrokenSourcesSection.mf b/csarvalidation/src/test/resources/pnf/MainServiceTemplateWithBrokenSourcesSection.mf
new file mode 100644
index 0000000..c649d11
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/MainServiceTemplateWithBrokenSourcesSection.mf
@@ -0,0 +1,37 @@
+metadata:
+ pnfd_name: RadioNode
+ pnfd_provider: Ericsson
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-01-14T11:25:00+00:00
+
+#The manifest file shall include a list of all files contained in or referenced from the VNF package with their location
+Source: MRF.yaml
+Algorithm: SHA-256
+Hash: 09e5a788acb180162c51679ae4c998039fa6644505db2415e35107d1ee213943
+
+Source: scripts/install.sh
+Hash: d0e7828293355a07c2dccaaa765c80b507e60e6167067c950dc2e6b0da0dbd8b
+
+Source: https://www.vendor_org.com/MRF/v4.1/scripts/scale/scale.sh
+Algorithm: SHA-256
+
+Source: some_file.sh
+
+
+non_mano_artifact_sets:
+
+ onap_ves_events:
+ source: Artifacts/Events/VES_registration.yml
+
+ onap_pm_dictionary:
+ source: Artifacts/Measurements/PM_Dictionary.yaml
+
+ onap_yang_module:
+ source: Artifacts/Yang_module/Yang_module.yaml
+
+ onap_others:
+ source: Artifacts/scripts/install.sh
+ source: Artifacts/Informational/user_guide.txt
+ source: Artifacts/Other/installation_guide.txt
+ source: Artifacts/Other/review_log.txt
+
diff --git a/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar b/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar
index bf2d912..b4afde4 100644
--- a/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar
+++ b/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar
Binary files differ
diff --git a/csarvalidation/src/test/resources/pnf/r787966/csar-option1-invalid.csar b/csarvalidation/src/test/resources/pnf/r787966/csar-option1-invalid.csar
new file mode 100644
index 0000000..8433043
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/r787966/csar-option1-invalid.csar
Binary files differ
diff --git a/csarvalidation/src/test/resources/pnf/r787966/csar-option1-valid.csar b/csarvalidation/src/test/resources/pnf/r787966/csar-option1-valid.csar
new file mode 100644
index 0000000..385595d
--- /dev/null
+++ b/csarvalidation/src/test/resources/pnf/r787966/csar-option1-valid.csar
Binary files differ