Search in sources :

Example 6 with ProvenanceVerification

use of org.eclipse.winery.accountability.model.ProvenanceVerification in project winery by eclipse.

the class AccountabilityManagerImplTest method verifyManifest.

@ParameterizedTest(name = "{index} => ''{3}''")
@MethodSource("verifyManifestArguments")
public void verifyManifest(ModelProvenanceElement historyElement, ProvenanceVerification expectedVerification, AuthorizationInfo authorizationInfo, String description) throws Exception {
    String manifestId = "Tosca.meta";
    List<ModelProvenanceElement> historyElementList = Objects.nonNull(historyElement) ? Arrays.asList(historyElement) : null;
    Map<String, File> filesMap = new HashMap<>();
    filesMap.put(manifestId, new File(ClassLoader.getSystemResource(manifestId).toURI()));
    Map<String, ProvenanceVerification> verificationMap = new HashMap<>();
    provenance.verifyManifest(historyElementList, manifestId, filesMap, verificationMap, authorizationInfo);
    ProvenanceVerification verification = verificationMap.get(manifestId);
    assertEquals(expectedVerification, verification);
}
Also used : ProvenanceVerification(org.eclipse.winery.accountability.model.ProvenanceVerification) HashMap(java.util.HashMap) ModelProvenanceElement(org.eclipse.winery.accountability.model.ModelProvenanceElement) File(java.io.File) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 7 with ProvenanceVerification

use of org.eclipse.winery.accountability.model.ProvenanceVerification in project winery by eclipse.

the class CsarImporterValidationTest method testImportAndValidation.

@Test
public void testImportAndValidation() throws Exception {
    try (InputStream input = new FileInputStream("src/test/resources/csar/ServiceTemplateWithAllReqCapVariants.csar")) {
        CsarImportOptions options = new CsarImportOptions();
        options.setOverwrite(true);
        options.setAsyncWPDParsing(false);
        options.setValidate(true);
        ImportMetaInformation importMetaInformation = csarImporter.readCSAR(input, options);
        assertEquals(ProvenanceVerification.VERIFIED, importMetaInformation.verificationMap.remove("TOSCA-Metadata/TOSCA.meta"));
        for (Map.Entry<String, ProvenanceVerification> entry : importMetaInformation.verificationMap.entrySet()) {
            assertEquals(ProvenanceVerification.VERIFIED, entry.getValue());
        }
    }
}
Also used : ProvenanceVerification(org.eclipse.winery.accountability.model.ProvenanceVerification) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Map(java.util.Map) FileInputStream(java.io.FileInputStream) Test(org.junit.jupiter.api.Test)

Example 8 with ProvenanceVerification

use of org.eclipse.winery.accountability.model.ProvenanceVerification in project winery by eclipse.

the class CsarImporterValidationTest method testImportAndInvalidValidation.

@Test
public void testImportAndInvalidValidation() throws Exception {
    try (InputStream inputStream = new FileInputStream("src/test/resources/csar/ServiceTemplateWithAllReqCapVariants-Invalid.csar")) {
        CsarImportOptions options = new CsarImportOptions();
        options.setOverwrite(true);
        options.setAsyncWPDParsing(false);
        options.setValidate(true);
        ImportMetaInformation importMetaInformation = csarImporter.readCSAR(inputStream, options);
        ProvenanceVerification invalidDefinition = importMetaInformation.verificationMap.remove("Definitions/servicetemplates__ServiceTemplateWithAllReqCapVariants.tosca");
        assertEquals(ProvenanceVerification.INVALID, invalidDefinition);
        for (Map.Entry<String, ProvenanceVerification> entry : importMetaInformation.verificationMap.entrySet()) {
            assertEquals(ProvenanceVerification.VERIFIED, entry.getValue());
        }
    }
}
Also used : ProvenanceVerification(org.eclipse.winery.accountability.model.ProvenanceVerification) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Map(java.util.Map) FileInputStream(java.io.FileInputStream) Test(org.junit.jupiter.api.Test)

Example 9 with ProvenanceVerification

use of org.eclipse.winery.accountability.model.ProvenanceVerification in project winery by eclipse.

the class CsarImporterValidationTest method testImportOfCsarWithoutAuthorship.

@Test
public void testImportOfCsarWithoutAuthorship() throws Exception {
    try (InputStream inputStream = new FileInputStream("src/test/resources/csar/ProvenanceCsarWithoutAuthorizedAuthors_w1-wip1.csar")) {
        CsarImportOptions options = new CsarImportOptions();
        options.setOverwrite(true);
        options.setAsyncWPDParsing(false);
        options.setValidate(true);
        ImportMetaInformation importMetaInformation = csarImporter.readCSAR(inputStream, options);
        ProvenanceVerification verification = importMetaInformation.verificationMap.get("TOSCA-Metadata/TOSCA.meta");
        assertEquals(ProvenanceVerification.NO_AUTHORIZATION_DATA_AVAILABLE, verification);
    }
}
Also used : ProvenanceVerification(org.eclipse.winery.accountability.model.ProvenanceVerification) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) Test(org.junit.jupiter.api.Test)

Aggregations

ProvenanceVerification (org.eclipse.winery.accountability.model.ProvenanceVerification)9 HashMap (java.util.HashMap)5 File (java.io.File)4 Map (java.util.Map)4 ModelProvenanceElement (org.eclipse.winery.accountability.model.ModelProvenanceElement)4 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 Test (org.junit.jupiter.api.Test)3 TOSCAMetaFile (org.eclipse.winery.model.csar.toscametafile.TOSCAMetaFile)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ExecutionException (java.util.concurrent.ExecutionException)1