From 62f5ad6b806d0bda1bb918061a5aa4b5b4dbe8b8 Mon Sep 17 00:00:00 2001 From: "bilal.iqbal" Date: Mon, 25 Mar 2019 14:31:14 +0000 Subject: Change SOL004 baseline from v2.5.1 to v2.6.1 Change-Id: Ic524e25a5f0a9952dd0a2c578034c60e51c7a290 Issue-ID: SDC-2190 Signed-off-by: bilal.iqbal --- .../impl/VendorSoftwareProductManagerImpl.java | 4 +- .../validation/SOL004MetaDirectoryValidator.java | 112 +++++++++++++-------- .../OrchestrationTemplateProcessCsarHandler.java | 2 +- .../SOL004MetaDirectoryValidatorTest.java | 109 ++++++++++++-------- .../csar/validation/TestConstants.java | 8 -- .../csar/validation/ValidatorFactoryTest.java | 29 +++--- .../metafile/metaFileWithMultipleBlocks.meta | 8 +- .../vspmanager.csar/metadata/ValidETSItosca.meta | 4 +- 8 files changed, 161 insertions(+), 115 deletions(-) (limited to 'openecomp-be/backend') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java index 5be982bede..49ec30eed7 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java @@ -17,7 +17,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl; import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.candidateDataNotProcessedOrAbortedErrorBuilder; @@ -664,7 +664,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa private InputStream getManifest(FileContentHandler handler) throws IOException { ToscaMetadata metadata = getMetadata(handler); - return getManifestInputStream(handler, metadata.getMetaEntries().get(TOSCA_META_ENTRY_MANIFEST)); + return getManifestInputStream(handler, metadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_MANIFEST)); } private ToscaMetadata getMetadata(FileContentHandler handler) throws IOException { diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java index a76acf5177..893fb7032d 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java @@ -23,6 +23,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validati import org.openecomp.core.converter.ServiceTemplateReaderService; import org.openecomp.core.impl.services.ServiceTemplateReaderServiceImpl; import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.common.utils.SdcCommon; import org.openecomp.sdc.datatypes.error.ErrorLevel; @@ -41,6 +42,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -51,14 +53,15 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA; import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_VNF_METADATA; import static org.openecomp.sdc.tosca.csar.CSARConstants.NON_FILE_IMPORT_ATTRIBUTES; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_MANIFEST_FILE_EXT; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CERTIFICATE; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_FILE_VERSION_ENTRY; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_CREATED_BY_ENTRY; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_CSAR_VERSION_ENTRY; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_CHANGE_LOG; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_LICENSES; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST; -import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_TESTS; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_LICENSES; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_TESTS; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_FILE_VERSION; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_PNF; @@ -66,7 +69,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_TYPE_VNF; /** * Validates the contents of the package to ensure it complies with the "CSAR with TOSCA-Metadata directory" structure - * as defined in ETSI GS NFV-SOL 004 v2.5.1. + * as defined in ETSI GS NFV-SOL 004 v2.6.1. * */ @@ -74,6 +77,8 @@ class SOL004MetaDirectoryValidator implements Validator{ private static final Logger LOGGER = LoggerFactory.getLogger(SOL004MetaDirectoryValidator.class); + private static final String MANIFEST_SOURCE = "Source"; + private static final String MANIFEST_NON_MANO_SOURCE = "Non-MANO Source"; private final List errorsByFile = new ArrayList<>(); private final Set verifiedImports = new HashSet<>(); @@ -100,14 +105,15 @@ class SOL004MetaDirectoryValidator implements Validator{ private void verifyManifestNameAndExtension(ToscaMetadata toscaMetadata) { Map entries = toscaMetadata.getMetaEntries(); - String manifestFileName = getFileName(entries.get(TOSCA_META_ENTRY_MANIFEST)); - String manifestExtension = getFileExtension(entries.get(TOSCA_META_ENTRY_MANIFEST)); + String manifestFileName = getFileName(entries.get(TOSCA_META_ETSI_ENTRY_MANIFEST)); + String manifestExtension = getFileExtension(entries.get(TOSCA_META_ETSI_ENTRY_MANIFEST)); String mainDefinitionFileName= getFileName(entries.get(TOSCA_META_ENTRY_DEFINITIONS)); if(!(TOSCA_MANIFEST_FILE_EXT).equals(manifestExtension)){ reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_EXT.getErrorMessage()); } if(!mainDefinitionFileName.equals(manifestFileName)){ - reportError(ErrorLevel.ERROR, Messages.MANIFEST_INVALID_NAME.getErrorMessage()); + reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_NAME.getErrorMessage(), + manifestFileName, mainDefinitionFileName)); } } @@ -136,31 +142,54 @@ class SOL004MetaDirectoryValidator implements Validator{ private void handleMetadataEntries(FileContentHandler contentHandler, List folderList, ToscaMetadata toscaMetadata) { for(Map.Entry entry: toscaMetadata.getMetaEntries().entrySet()){ - String key = (String) entry.getKey(); - String value = (String) entry.getValue(); - switch (key){ - case TOSCA_META_FILE_VERSION_ENTRY: - case TOSCA_META_CSAR_VERSION_ENTRY: - case TOSCA_META_CREATED_BY_ENTRY: - verifyMetadataEntryVersions(key, value); - break; - case TOSCA_META_ENTRY_DEFINITIONS: - validateDefinitionFile(contentHandler, value); - break; - case TOSCA_META_ENTRY_MANIFEST: - validateManifestFile(contentHandler, value); - break; - case TOSCA_META_ENTRY_CHANGE_LOG: - validateChangeLog(contentHandler, value); - break; - case TOSCA_META_ENTRY_TESTS: - case TOSCA_META_ENTRY_LICENSES: - validateOtherEntries(folderList, value); - break; - default: - errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR, String.format(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry))); - LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry); - break; + handleEntry(contentHandler, folderList, toscaMetadata, entry); + } + } + + private void handleEntry(FileContentHandler contentHandler, List folderList, ToscaMetadata toscaMetadata, Map.Entry entry) { + String key = (String) entry.getKey(); + String value = (String) entry.getValue(); + switch (key){ + case TOSCA_META_FILE_VERSION_ENTRY: + case TOSCA_META_CSAR_VERSION_ENTRY: + case TOSCA_META_CREATED_BY_ENTRY: + verifyMetadataEntryVersions(key, value); + break; + case TOSCA_META_ENTRY_DEFINITIONS: + validateDefinitionFile(contentHandler, value); + break; + case TOSCA_META_ETSI_ENTRY_MANIFEST: + validateManifestFile(contentHandler, value); + break; + case TOSCA_META_ETSI_ENTRY_CHANGE_LOG: + validateChangeLog(contentHandler, value); + break; + case TOSCA_META_ETSI_ENTRY_TESTS: + case TOSCA_META_ETSI_ENTRY_LICENSES: + validateOtherEntries(folderList, entry, contentHandler, toscaMetadata); + break; + case TOSCA_META_ETSI_ENTRY_CERTIFICATE: + validateOtherEntries(folderList, value); + break; + default: + errorsByFile.add(new ErrorMessage(ErrorLevel.ERROR, String.format(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry))); + LOGGER.warn(Messages.METADATA_UNSUPPORTED_ENTRY.getErrorMessage(), entry); + break; + } + } + + private void validateOtherEntries(List folderList, Map.Entry entry, FileContentHandler contentHandler, ToscaMetadata toscaMetadata) { + String manifestFile = toscaMetadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_MANIFEST); + if(verifyFileExists(contentHandler.getFileList(), manifestFile)){ + Manifest onboardingManifest = new SOL004ManifestOnboarding(); + onboardingManifest.parse(contentHandler.getFileContent(manifestFile)); + Optional resourceType = onboardingManifest.getType(); + if(resourceType.isPresent() && resourceType.get() == ResourceTypeEnum.VF){ + String value = (String) entry.getValue(); + validateOtherEntries(folderList, value); + }else{ + String key = (String) entry.getKey(); + reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_INVALID_PNF_METADATA.getErrorMessage(), key)); } } @@ -225,7 +254,8 @@ class SOL004MetaDirectoryValidator implements Validator{ filePath = parentDir + "/" + filePath; } if(!verifyFileExists(existingFiles, filePath)){ - reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(), (String) o)); + reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_IMPORT_FILE.getErrorMessage(), filePath, + parentDir)); return null; } return filePath; @@ -237,7 +267,7 @@ class SOL004MetaDirectoryValidator implements Validator{ } } }else { - reportError(ErrorLevel.ERROR, Messages.INVALID_IMPORT_STATEMENT.getErrorMessage()); + reportError(ErrorLevel.ERROR, String.format(Messages.INVALID_IMPORT_STATEMENT.getErrorMessage(), parentDir)); } return null; } @@ -271,7 +301,7 @@ class SOL004MetaDirectoryValidator implements Validator{ } } }else { - reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_NOT_EXIST.getErrorMessage(), filePath)); + reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_NOT_FOUND.getErrorMessage(), filePath)); } } @@ -318,9 +348,9 @@ class SOL004MetaDirectoryValidator implements Validator{ private void verifySourcesExists(Set exitingFiles, Manifest onboardingManifest) { List sources = filterSources(onboardingManifest.getSources()); Map> nonManoArtifacts = onboardingManifest.getNonManoSources(); - verifyFilesExist(exitingFiles, sources); + verifyFilesExist(exitingFiles, sources, MANIFEST_SOURCE); for (Map.Entry entry : nonManoArtifacts.entrySet()) { - verifyFilesExist(exitingFiles, filterSources((List)entry.getValue())); + verifyFilesExist(exitingFiles, filterSources((List)entry.getValue()), MANIFEST_NON_MANO_SOURCE); } } @@ -344,10 +374,10 @@ class SOL004MetaDirectoryValidator implements Validator{ return folderList.contains(folderPath + "/"); } - private void verifyFilesExist(Set existingFiles, List sources){ + private void verifyFilesExist(Set existingFiles, List sources, String type){ for(String file: sources){ if(!verifyFileExists(existingFiles, file)){ - reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_ARTIFACT.getErrorMessage(), file)); + reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_MANIFEST_SOURCE.getErrorMessage(), type, file)); } } @@ -355,7 +385,7 @@ class SOL004MetaDirectoryValidator implements Validator{ private void validateChangeLog(FileContentHandler contentHandler, String filePath){ if(!verifyFileExists(contentHandler.getFileList(), filePath)){ - reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_ARTIFACT.getErrorMessage(), filePath)); + reportError(ErrorLevel.ERROR, String.format(Messages.MISSING_METADATA_FILES.getErrorMessage(), filePath)); } } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java index 7be3eb9fdb..665c63d64c 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java @@ -51,7 +51,7 @@ import java.util.*; public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler { private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class); - private static final String SDC_ONBOARDED_PACKAGE_DIR = "ONBOARDED_PACKAGE/"; + private static final String SDC_ONBOARDED_PACKAGE_DIR = "Deployment/ONBOARDED_PACKAGE/"; private static final String EXT_SEPARATOR = "."; private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface(); private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager(); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java index 8584d482b4..93c8b23268 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java @@ -14,6 +14,14 @@ import java.util.List; import java.util.Map; import static org.junit.Assert.assertTrue; +import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CERTIFICATE; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_LICENSES; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_TESTS; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.*; public class SOL004MetaDirectoryValidatorTest { @@ -30,9 +38,9 @@ public class SOL004MetaDirectoryValidatorTest { "TOSCA-Meta-File-Version: 1.0\n"+ "CSAR-Version: 1.1\n"+ "Created-by: Vendor\n"+ - "Entry-Definitions: Definitions/MainServiceTemplate.yaml\n"+ - "Entry-Manifest: Definitions/MainServiceTemplate.mf\n"+ - "Entry-Change-Log: Artifacts/changeLog.text\n"; + TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.yaml\n"+ + TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.mf\n"+ + TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + "Artifacts/changeLog.text\n"; } @Test @@ -41,7 +49,7 @@ public class SOL004MetaDirectoryValidatorTest { String metaFileWithInvalidEntry = "TOSCA-Meta-File-Version: \n" + "Entry-Definitions: Definitions/MainServiceTemplate.yaml"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFileWithInvalidEntry.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFileWithInvalidEntry.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(TestConstants.SAMPLE_DEFINITION_FILE_PATH)); Map> errors = sol004MetaDirectoryValidator.validateContent(handler, Collections.emptyList()); @@ -60,10 +68,10 @@ public class SOL004MetaDirectoryValidatorTest { folderList.add("Files/Licenses/"); metaFile = metaFile + - "Entry-Tests: "+ entryTestFilePath + "\n" + - "Entry-Licenses: "+ entryLicenseFilePath +"\n"; + TOSCA_META_ETSI_ENTRY_TESTS + SEPERATOR_MF_ATTRIBUTE + entryTestFilePath + "\n" + + TOSCA_META_ETSI_ENTRY_LICENSES + SEPERATOR_MF_ATTRIBUTE + entryLicenseFilePath +"\n"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH)); @@ -81,7 +89,7 @@ public class SOL004MetaDirectoryValidatorTest { metaFile = "Entry-Events: Definitions/events.log"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); Map> errors = sol004MetaDirectoryValidator.validateContent(handler, Collections.emptyList()); List errorMessages = errors.get(SdcCommon.UPLOAD_FILE); assertTrue(errors.size() == 1 && errorMessages.size() == 1); @@ -95,12 +103,12 @@ public class SOL004MetaDirectoryValidatorTest { String metaFile = "TOSCA-Meta-File-Version: " + Integer.MAX_VALUE + "\nCSAR-Version: " + Integer.MAX_VALUE + - "\nCreated-by: Bilal Iqbal" + - "\nEntry-Definitions: Definitions/MainServiceTemplate.yaml" + - "\nEntry-Manifest: Definitions/MainServiceTemplate.mf"+ - "\nEntry-Change-Log: Artifacts/changeLog.text"; + "\nCreated-by: Bilal Iqbal\n" + + TOSCA_META_ENTRY_DEFINITIONS+ SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.yaml\n" + + TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.mf\n"+ + TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + "Artifacts/changeLog.text"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(TestConstants.SAMPLE_DEFINITION_FILE_PATH)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH)); @@ -113,15 +121,11 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenTOSCAMetaFile_withNonExistentFileReferenced_thenErrorsReturned(){ - metaFile = metaFile + - "Entry-Tests: Files/Tests\n" + - "Entry-License: Files/Licenses\n"; - - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); Map> errors = sol004MetaDirectoryValidator.validateContent(handler, Collections.emptyList()); List errorMessages = errors.get(SdcCommon.UPLOAD_FILE); - assertTrue(errors.size() == 1 && errorMessages.size() == 5); + assertTrue(errors.size() == 1 && errorMessages.size() == 3); } @@ -131,7 +135,7 @@ public class SOL004MetaDirectoryValidatorTest { String definitionFileWithValidImports = "/validation.files/definition/definitionFileWithValidImports.yaml"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH)); handler.addFile(SAMPLE_SOURCE, "".getBytes()); @@ -149,7 +153,7 @@ public class SOL004MetaDirectoryValidatorTest { byte [] sampleDefinitionFile2 = ValidatorUtil.getFileResource("/validation.files/definition/sampleDefinitionFile2.yaml"); byte [] sampleDefinitionFile3 = ValidatorUtil.getFileResource("/validation.files/definition/sampleDefinitionFile3.yaml"); - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH)); handler.addFile(SAMPLE_SOURCE, "".getBytes()); @@ -166,7 +170,7 @@ public class SOL004MetaDirectoryValidatorTest { String definitionFileWithInvalidImports = "/validation.files/definition/definitionFileWithInvalidImport.yaml"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH)); handler.addFile(SAMPLE_SOURCE, "".getBytes()); @@ -180,7 +184,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenDefinitionFile_whenReferencedImportDoesNotExist_thenErrorIsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH)); handler.addFile(SAMPLE_SOURCE, "".getBytes()); @@ -198,7 +202,7 @@ public class SOL004MetaDirectoryValidatorTest { String definitionFileWithInvalidYAML = "/validation.files/definition/invalidDefinitionFile.yaml"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_MANIFEST_FILE_PATH)); handler.addFile(SAMPLE_SOURCE, "".getBytes()); @@ -215,7 +219,7 @@ public class SOL004MetaDirectoryValidatorTest { String nonManoSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/validManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -231,7 +235,7 @@ public class SOL004MetaDirectoryValidatorTest { public void testGivenManifestFile_withNonExistentSourceFile_thenErrorIsReturned() throws IOException{ String nonManoSource = "Artifacts/Deployment/Measurements/PM_Dictionary.yaml"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/validManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -246,7 +250,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withInvalidData_thenErrorIsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/invalidManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -260,7 +264,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestAndDefinitionFile_withSameNames_thenNoErrorReturned() throws IOException { - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -276,11 +280,11 @@ public class SOL004MetaDirectoryValidatorTest { "TOSCA-Meta-File-Version: 1.0\n"+ "CSAR-Version: 1.1\n"+ "Created-by: Vendor\n"+ - "Entry-Definitions: Definitions/MainServiceTemplate.yaml\n"+ - "Entry-Manifest: Definitions/MainServiceTemplate2.mf\n"+ - "Entry-Change-Log: Artifacts/changeLog.text\n"; + TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.yaml\n"+ + TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE +"Definitions/MainServiceTemplate2.mf\n"+ + TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE +"Artifacts/changeLog.text\n"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile("Definitions/MainServiceTemplate2.mf", ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -298,10 +302,10 @@ public class SOL004MetaDirectoryValidatorTest { "CSAR-Version: 1.1\n"+ "Created-by: Vendor\n"+ "Entry-Definitions: Definitions/MainServiceTemplate.yaml\n"+ - "Entry-Manifest: Definitions/MainServiceTemplate.txt\n"+ - "Entry-Change-Log: Artifacts/changeLog.text\n"; + TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + "Definitions/MainServiceTemplate.txt\n"+ + TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + "Artifacts/changeLog.text\n"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile("Definitions/MainServiceTemplate.txt", ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -314,7 +318,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withValidVnfMetadata_thenNoErrorsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -325,7 +329,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withValidPnfMetadata_thenNoErrorsReturned() throws IOException { - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest2.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -337,7 +341,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withMetadataContainingMixedPnfVnfMetadata_thenErrorIsReturned() throws IOException { - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -350,7 +354,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withMetadataMissingPnfOrVnfMandatoryEntries_thenErrorIsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata2.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -361,7 +365,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withMetadataMissingMandatoryPnfEntries_thenErrorIsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata4.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -373,7 +377,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withMetadataMissingMandatoryVnfEntries_thenErrorIsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata5.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -385,7 +389,7 @@ public class SOL004MetaDirectoryValidatorTest { @Test public void testGivenManifestFile_withMetadataEntriesExceedingTheLimit_thenErrorIsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/manifestInvalidMetadata3.mf")); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); @@ -394,6 +398,27 @@ public class SOL004MetaDirectoryValidatorTest { assertExpectedErrors("Manifest with more than 4 metadata entries should return error", errors, 2); } + @Test + public void testGivenManifestFile_withPnfMetadataAndVfEntries_thenErrorIsReturned() throws IOException { + + List folderList = new ArrayList<>(); + folderList.add("Files/Certificates/"); + + metaFile = metaFile + + TOSCA_META_ETSI_ENTRY_TESTS + SEPERATOR_MF_ATTRIBUTE + "Files/Tests\n" + + TOSCA_META_ETSI_ENTRY_LICENSES + SEPERATOR_MF_ATTRIBUTE + "Files/Licenses\n" + + TOSCA_META_ETSI_ENTRY_CERTIFICATE + SEPERATOR_MF_ATTRIBUTE + "Files/Certificates"; + + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_MANIFEST_FILEPATH, ValidatorUtil.getFileResource("/validation.files/manifest/sampleManifest2.mf")); + handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes()); + handler.addFile(TOSCA_DEFINITION_FILEPATH, ValidatorUtil.getFileResource(SAMPLE_DEFINITION_FILE_PATH)); + + Map> errors = sol004MetaDirectoryValidator.validateContent(handler, folderList); + assertExpectedErrors("Tosca.meta should not have entries applicable only to VF", errors, 2); + + } + private void assertExpectedErrors( String testCase, Map> errors, int expectedErrors){ if(expectedErrors > 0){ List errorMessages = errors.get(SdcCommon.UPLOAD_FILE); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java index 0a88ebc37d..ce338df5d0 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/TestConstants.java @@ -7,17 +7,9 @@ class TestConstants { public static final String SAMPLE_SOURCE = "Artifacts/Deployment/Events/RadioNode_pnf_v1.yaml"; public static final String SAMPLE_DEFINITION_FILE_PATH = "/validation.files/definition/sampleDefinitionFile.yaml"; public static final String SAMPLE_MANIFEST_FILE_PATH = "/validation.files/manifest/sampleManifest.mf"; - - public static final String ENTRY_DEFINITIONS = "Entry-Definitions"; - public static final String ENTRY_MANIFEST = "Entry-Manifest"; - public static final String ENTRY_CHANGE_LOG = "Entry-Change-Log"; - - public static final String ENTRY_SEPARATOR = ":"; - public static final String TOSCA_DEFINITION_FILEPATH = "Definitions/MainServiceTemplate.yaml"; public static final String TOSCA_MANIFEST_FILEPATH = "Definitions/MainServiceTemplate.mf"; public static final String TOSCA_CHANGELOG_FILEPATH = "Artifacts/changeLog.text"; - public static final String TOSCA_METADATA_FILEPATH = "TOSCA-Metadata/TOSCA.meta"; private TestConstants(){ diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java index 287662283c..3f42c5715c 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ValidatorFactoryTest.java @@ -3,19 +3,18 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validati import org.junit.Before; import org.junit.Test; import org.openecomp.core.utilities.file.FileContentHandler; - import java.io.IOException; import java.nio.charset.StandardCharsets; import static org.junit.Assert.assertEquals; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_CHANGE_LOG; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_DEFINITIONS; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_MANIFEST; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.ENTRY_SEPARATOR; +import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST; +import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_CHANGELOG_FILEPATH; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_DEFINITION_FILEPATH; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_MANIFEST_FILEPATH; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.TOSCA_METADATA_FILEPATH; public class ValidatorFactoryTest { @@ -33,7 +32,7 @@ public class ValidatorFactoryTest { @Test(expected = IOException.class) public void testGivenEmptyMetaFile_thenIOExceptionIsThrown() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -43,7 +42,7 @@ public class ValidatorFactoryTest { @Test public void testGivenEmptyBlock0_thenONAPCsarValidatorIsReturned() throws IOException{ - handler.addFile(TOSCA_METADATA_FILEPATH, " ".getBytes(StandardCharsets.UTF_8)); + handler.addFile(TOSCA_META_PATH_FILE_NAME, " ".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); @@ -55,8 +54,8 @@ public class ValidatorFactoryTest { @Test public void testGivenNonSOL004MetaDirectoryCompliantMetaFile_thenONAPCSARValidatorIsReturned() throws IOException{ metaFile = metaFile + - ENTRY_DEFINITIONS + ENTRY_SEPARATOR + TOSCA_DEFINITION_FILEPATH; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + TOSCA_DEFINITION_FILEPATH; + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); assertEquals(ONAPCsarValidator.class, ValidatorFactory.getValidator(handler).getClass()); } @@ -65,10 +64,10 @@ public class ValidatorFactoryTest { public void testGivenSOL004MetaDirectoryCompliantMetafile_thenONAPCsarValidatorIsReturned() throws IOException{ metaFile = metaFile + - ENTRY_DEFINITIONS + ENTRY_SEPARATOR + TOSCA_DEFINITION_FILEPATH + "\n" - + ENTRY_MANIFEST + ENTRY_SEPARATOR + TOSCA_MANIFEST_FILEPATH + "\n" - + ENTRY_CHANGE_LOG + ENTRY_SEPARATOR + TOSCA_CHANGELOG_FILEPATH + "\n"; - handler.addFile(TOSCA_METADATA_FILEPATH, metaFile.getBytes(StandardCharsets.UTF_8)); + TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE + TOSCA_DEFINITION_FILEPATH + "\n" + + TOSCA_META_ETSI_ENTRY_MANIFEST + SEPERATOR_MF_ATTRIBUTE + TOSCA_MANIFEST_FILEPATH + "\n" + + TOSCA_META_ETSI_ENTRY_CHANGE_LOG + SEPERATOR_MF_ATTRIBUTE + TOSCA_CHANGELOG_FILEPATH + "\n"; + handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8)); assertEquals(SOL004MetaDirectoryValidator.class, ValidatorFactory.getValidator(handler).getClass()); } @@ -76,7 +75,7 @@ public class ValidatorFactoryTest { @Test public void testGivenMultiBlockMetadataWithSOL00CompliantMetaFile_thenSOL004MetaDirectoryValidatorReturned() throws IOException { - handler.addFile(TOSCA_METADATA_FILEPATH, ValidatorUtil.getFileResource("/validation.files/metafile/metaFileWithMultipleBlocks.meta")); + handler.addFile(TOSCA_META_PATH_FILE_NAME, ValidatorUtil.getFileResource("/validation.files/metafile/metaFileWithMultipleBlocks.meta")); handler.addFile(TOSCA_DEFINITION_FILEPATH, "".getBytes()); handler.addFile(TOSCA_CHANGELOG_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); handler.addFile(TOSCA_MANIFEST_FILEPATH, "".getBytes(StandardCharsets.UTF_8)); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta index 38440a2133..ce2a10a724 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/validation.files/metafile/metaFileWithMultipleBlocks.meta @@ -2,9 +2,9 @@ TOSCA-Meta-File-Version: 1.0 CSAR-Version: 1.1 Created-by: Bilal Iqbal Entry-Definitions: Definitions/MainServiceTemplate.yml -Entry-Manifest: Definitions/MainServiceTemplate.mf -Entry-Change-Log: Definitions/changeLog.text +ETSI-Entry-Manifest: Definitions/MainServiceTemplate.mf +ETSI-Entry-Change-Log: Definitions/changeLog.text Entry-Definitions: Definitions/MainServiceTemplate2.yml -Entry-Manifest: Definitions/MainServiceTemplate2.mf -Entry-Change-Log: Definitions/changeLog2.text \ No newline at end of file +ETSI-Entry-Manifest: Definitions/MainServiceTemplate2.mf +ETSI-Entry-Change-Log: Definitions/changeLog2.text \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta index 0d74a150b1..8a51a625f2 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta @@ -2,5 +2,5 @@ TOSCA-Meta-File-Version: 1.0 CSAR-Version: 1.1 Created-By: Sergey Sachkov Entry-Definitions: Definitions/MainServiceTemplate.yaml -Entry-Manifest: MainServiceTemplate.mf -Entry-Change-Log: change.log +ETSI-Entry-Manifest: MainServiceTemplate.mf +ETSI-Entry-Change-Log: change.log -- cgit 1.2.3-korg