diff --git a/Core/src/org/sleuthkit/autopsy/integrationtesting/ConfigurationModuleManager.java b/Core/src/org/sleuthkit/autopsy/integrationtesting/ConfigurationModuleManager.java index db529d31f7a323e74ab90594c3d8266191c4ed0b..9aabc396b1eb7e7703d2c5e3a056309c05e313df 100644 --- a/Core/src/org/sleuthkit/autopsy/integrationtesting/ConfigurationModuleManager.java +++ b/Core/src/org/sleuthkit/autopsy/integrationtesting/ConfigurationModuleManager.java @@ -29,7 +29,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.cxf.common.util.CollectionUtils; +import org.apache.commons.collections.CollectionUtils; import org.openide.util.Pair; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestModuleTemplate; diff --git a/Core/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTestService.java b/Core/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTestService.java index 53bee07bfc2a88b357fea36264f949e3217ec442..752959d5d334ad6202344b5b3c8ae3c09c209f44 100644 --- a/Core/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTestService.java +++ b/Core/src/org/sleuthkit/autopsy/integrationtesting/IntegrationTestService.java @@ -34,7 +34,7 @@ import java.util.stream.Stream; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; -import org.apache.cxf.common.util.CollectionUtils; +import org.apache.commons.collections.CollectionUtils; import org.openide.util.Lookup; import org.openide.util.Pair; import org.sleuthkit.autopsy.casemodule.Case; diff --git a/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java b/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java index fe8dd90873b47fd24a80077efb66a5884445e018..63bd700fab0c8e95f724533108dc091b89c7fcab 100644 --- a/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java +++ b/Core/src/org/sleuthkit/autopsy/integrationtesting/config/ConfigDeserializer.java @@ -38,7 +38,7 @@ import java.util.stream.IntStream; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; -import org.apache.cxf.common.util.CollectionUtils; +import org.apache.commons.collections.CollectionUtils; import org.sleuthkit.autopsy.integrationtesting.PathUtil; /** diff --git a/Core/src/org/sleuthkit/autopsy/testutils/TestUtilsException.java b/Core/src/org/sleuthkit/autopsy/testutils/TestUtilsException.java new file mode 100644 index 0000000000000000000000000000000000000000..a720c7c66fd4f699d11fe500cf25a3dfa2aa51d2 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/testutils/TestUtilsException.java @@ -0,0 +1,45 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier <at> sleuthkit <dot> org + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.sleuthkit.autopsy.testutils; + +/** + * Exception created from exercising parts of TestUtils. + */ +public class TestUtilsException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Main constructor that accepts a message. + * @param message The message. + */ + public TestUtilsException(String message) { + super(message); + } + + /** + * Main constructor that accepts a message and inner exception. + * @param message The message. + * @param innerException The inner exception. + */ + public TestUtilsException(String message, Throwable innerException) { + super(message, innerException); + } + +} diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java index bc208b7f2f5fad8099129e46fd2bea98d639dbc8..80ec6396772c28d772fb3c7508ce9b7ff6ccd80c 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java @@ -31,10 +31,6 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; -import org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher; -import org.sleuthkit.autopsy.commonpropertiessearch.AllIntraCaseCommonAttributeSearcher; -import org.sleuthkit.autopsy.commonpropertiessearch.CommonAttributeCountSearchResults; -import org.sleuthkit.autopsy.commonpropertiessearch.SingleIntraCaseCommonAttributeSearcher; import static org.sleuthkit.autopsy.commonpropertiessearch.IntraCaseTestUtils.*; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType; @@ -42,6 +38,7 @@ import org.sleuthkit.autopsy.modules.filetypeid.FileTypeIdModuleFactory; import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory; import org.sleuthkit.autopsy.testutils.IngestUtils; +import org.sleuthkit.autopsy.testutils.TestUtilsException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; @@ -80,7 +77,7 @@ public void setUp() { try { IngestUtils.runIngestJob(Case.getCurrentCaseThrows().getDataSources(), ingestJobSettings); - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (NoCurrentCaseException | TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithNoFileTypesIntraCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithNoFileTypesIntraCaseTest.java index 9556ef69f63ee46c853a61e3513ece5608ba21ee..c98be06942f29b26f6bc0cf6100316c1f42c2864 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithNoFileTypesIntraCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithNoFileTypesIntraCaseTest.java @@ -40,6 +40,7 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory; import org.sleuthkit.autopsy.testutils.IngestUtils; import static org.sleuthkit.autopsy.testutils.IngestUtils.getIngestModuleTemplate; +import org.sleuthkit.autopsy.testutils.TestUtilsException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; @@ -81,7 +82,7 @@ public void setUp() { try { IngestUtils.runIngestJob(Case.getCurrentCaseThrows().getDataSources(), ingestJobSettings); - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (NoCurrentCaseException | TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java index 014b08fe84bdaa59a7620f197276bb055af7106e..73c13f18e3792affe1cef23ee3bfac2b7f4bd02a 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java @@ -64,6 +64,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.RdbmsCentralRepoFactory; import org.sleuthkit.autopsy.coreutils.FileUtil; import org.sleuthkit.autopsy.modules.pictureanalyzer.PictureAnalyzerIngestModuleFactory; +import org.sleuthkit.autopsy.testutils.TestUtilsException; /** * Utilities for testing intercase correlation feature. @@ -254,16 +255,16 @@ void clearTestDir() { } } } - + Map<Long, String> getDataSourceMap() throws NoCurrentCaseException, TskCoreException, SQLException { return DataSourceLoader.getAllDataSources(); - } + } Map<String, Integer> getCaseMap() throws CentralRepoException { if (CentralRepository.isEnabled()) { Map<String, Integer> mapOfCaseIdsToCase = new HashMap<>(); - + for (CorrelationCase correlationCase : CentralRepository.getInstance().getCases()) { mapOfCaseIdsToCase.put(correlationCase.getDisplayName(), correlationCase.getID()); } @@ -300,7 +301,7 @@ void enableCentralRepo() throws CentralRepoException { RdbmsCentralRepoFactory centralRepoSchemaFactory = new RdbmsCentralRepoFactory(CentralRepoPlatforms.SQLITE, crSettings); centralRepoSchemaFactory.initializeDatabaseSchema(); centralRepoSchemaFactory.insertDefaultDatabaseContent(); - + crSettings.saveSettings(); CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.SQLITE); } @@ -313,10 +314,10 @@ void enableCentralRepo() throws CentralRepoException { * The length of caseNames and caseDataSourcePaths should be the same, and * cases should appear in the same order. * - * @param caseNames list case names - * @param caseDataSourcePaths two dimensional array listing the datasources - * in each case - * @param ingestJobSettings HashLookup FileType etc... + * @param caseNames list case names + * @param caseDataSourcePaths two dimensional array listing the datasources + * in each case + * @param ingestJobSettings HashLookup FileType etc... * @param caseReferenceToStore */ Case createCases(String[] caseNames, Path[][] caseDataSourcePaths, IngestJobSettings ingestJobSettings, String caseReferenceToStore) throws TskCoreException { @@ -359,19 +360,26 @@ Case createCases(String[] caseNames, Path[][] caseDataSourcePaths, IngestJobSett } private Case createCase(String caseName, IngestJobSettings ingestJobSettings, boolean keepAlive, Path... dataSetPaths) throws TskCoreException { - Case caze = CaseUtils.createAsCurrentCase(caseName); - for (Path dataSetPath : dataSetPaths) { - IngestUtils.addDataSource(this.imageDSProcessor, dataSetPath); - } - if (ingestJobSettings != null) { - IngestUtils.runIngestJob(caze.getDataSources(), ingestJobSettings); - } - if (keepAlive) { - return caze; - } else { - CaseUtils.closeCurrentCase(); - return null; + try { + Case caze = CaseUtils.createAsCurrentCase(caseName); + for (Path dataSetPath : dataSetPaths) { + IngestUtils.addDataSource(this.imageDSProcessor, dataSetPath); + } + if (ingestJobSettings != null) { + IngestUtils.runIngestJob(caze.getDataSources(), ingestJobSettings); + } + if (keepAlive) { + return caze; + } else { + CaseUtils.closeCurrentCase(); + return null; + } + } catch (TestUtilsException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex.getMessage()); } + + return null; } static boolean verifyInstanceCount(CommonAttributeCountSearchResults searchDomain, int instanceCount) { @@ -453,7 +461,12 @@ static int getInstanceCount(CommonAttributeCountSearchResults searchDomain, Stri * central repo db. */ void tearDown() { - CaseUtils.closeCurrentCase(); + try { + CaseUtils.closeCurrentCase(); + } catch (TestUtilsException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex.getMessage()); + } } /** diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseTestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseTestUtils.java index c784c631212f2f29e395b1460cb06ad66f4b4b5f..dee73e46f7a641cf50dad3c2a14562cc25851199 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseTestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseTestUtils.java @@ -36,6 +36,7 @@ import org.sleuthkit.autopsy.coreutils.TimeStampUtils; import org.sleuthkit.autopsy.testutils.CaseUtils; import org.sleuthkit.autopsy.testutils.IngestUtils; +import org.sleuthkit.autopsy.testutils.TestUtilsException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; @@ -98,23 +99,40 @@ void setUp() { } void addImageFour(final ImageDSProcessor imageDSProcessor) { - IngestUtils.addDataSource(imageDSProcessor, imagePath4); + addImage(imageDSProcessor, imagePath4); } void addImageThree(final ImageDSProcessor imageDSProcessor) { - IngestUtils.addDataSource(imageDSProcessor, imagePath3); + addImage(imageDSProcessor, imagePath3); } void addImageTwo(final ImageDSProcessor imageDSProcessor) { - IngestUtils.addDataSource(imageDSProcessor, imagePath2); + addImage(imageDSProcessor, imagePath2); } void addImageOne(final ImageDSProcessor imageDSProcessor) { - IngestUtils.addDataSource(imageDSProcessor, imagePath1); + addImage(imageDSProcessor, imagePath1); + } + + private void addImage(final ImageDSProcessor imageDSProcessor, Path path) { + try { + IngestUtils.addDataSource(imageDSProcessor, path); + } catch (TestUtilsException ex) { + failOnException(ex); + } } void createAsCurrentCase() { - CaseUtils.createAsCurrentCase(this.caseName + "_" + TimeStampUtils.createTimeStamp()); + try { + CaseUtils.createAsCurrentCase(this.caseName + "_" + TimeStampUtils.createTimeStamp()); + } catch (TestUtilsException ex) { + failOnException(ex); + } + } + + private void failOnException(Exception ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex.getMessage()); } Map<Long, String> getDataSourceMap() throws NoCurrentCaseException, TskCoreException, SQLException { @@ -122,7 +140,11 @@ Map<Long, String> getDataSourceMap() throws NoCurrentCaseException, TskCoreExcep } void tearDown() { - CaseUtils.closeCurrentCase(); + try { + CaseUtils.closeCurrentCase(); + } catch (TestUtilsException ex) { + failOnException(ex); + } } /** @@ -181,15 +203,15 @@ static boolean verifySingularInstanceExistance(List<AbstractFile> files, Map<Lon */ static Map<Long, String> mapFileInstancesToDataSources(CommonAttributeCountSearchResults metadata) { Map<Long, String> instanceIdToDataSource = new HashMap<>(); - for (Map.Entry<Integer, CommonAttributeValueList> entry : metadata.getMetadata().entrySet()) { - entry.getValue().displayDelayedMetadata(); - for (CommonAttributeValue md : entry.getValue().getMetadataList()) { - for (AbstractCommonAttributeInstance fim : md.getInstances()) { - instanceIdToDataSource.put(fim.getAbstractFileObjectId(), fim.getDataSource()); - } + for (Map.Entry<Integer, CommonAttributeValueList> entry : metadata.getMetadata().entrySet()) { + entry.getValue().displayDelayedMetadata(); + for (CommonAttributeValue md : entry.getValue().getMetadataList()) { + for (AbstractCommonAttributeInstance fim : md.getInstances()) { + instanceIdToDataSource.put(fim.getAbstractFileObjectId(), fim.getDataSource()); } } - return instanceIdToDataSource; + } + return instanceIdToDataSource; } static List<AbstractFile> getFiles(Set<Long> objectIds) { diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java index e2d636c4e9425708fcfb32774536dc27ce69852d..d6f9e58fa6f4b7fa912a7e88f97f605fef779e99 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java @@ -32,15 +32,13 @@ import org.sleuthkit.autopsy.casemodule.ImageDSProcessor; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; -import org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher; -import org.sleuthkit.autopsy.commonpropertiessearch.AllIntraCaseCommonAttributeSearcher; -import org.sleuthkit.autopsy.commonpropertiessearch.CommonAttributeCountSearchResults; import static org.sleuthkit.autopsy.commonpropertiessearch.IntraCaseTestUtils.*; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestModuleTemplate; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeIdModuleFactory; import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory; import org.sleuthkit.autopsy.testutils.IngestUtils; +import org.sleuthkit.autopsy.testutils.TestUtilsException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; @@ -90,7 +88,7 @@ public void setUp() { try { IngestUtils.runIngestJob(Case.getCurrentCaseThrows().getDataSources(), ingestJobSettings); - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (NoCurrentCaseException | TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/EmbeddedFileTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/EmbeddedFileTest.java index 6f8a59511530ef7ec6d8c129b76b934397d71f6b..c81d62a8cec0a852ffc793f03f268e5d8bdb4083 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/EmbeddedFileTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/EmbeddedFileTest.java @@ -38,6 +38,7 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory; import org.sleuthkit.autopsy.testutils.CaseUtils; import org.sleuthkit.autopsy.testutils.IngestUtils; +import org.sleuthkit.autopsy.testutils.TestUtilsException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardAttribute; @@ -67,22 +68,21 @@ public EmbeddedFileTest(String name) { @Override public void setUp() { + try { + openCase = CaseUtils.createAsCurrentCase(CASE_NAME); + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - openCase = CaseUtils.createAsCurrentCase(CASE_NAME); - ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - - IngestModuleTemplate embeddedTemplate = IngestUtils.getIngestModuleTemplate(new EmbeddedFileExtractorModuleFactory()); - IngestModuleTemplate hashLookupTemplate = IngestUtils.getIngestModuleTemplate(new HashLookupModuleFactory()); + IngestModuleTemplate embeddedTemplate = IngestUtils.getIngestModuleTemplate(new EmbeddedFileExtractorModuleFactory()); + IngestModuleTemplate hashLookupTemplate = IngestUtils.getIngestModuleTemplate(new HashLookupModuleFactory()); - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); - templates.add(embeddedTemplate); - templates.add(hashLookupTemplate); - IngestJobSettings ingestJobSettings = new IngestJobSettings(EmbeddedFileTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates); + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + templates.add(embeddedTemplate); + templates.add(hashLookupTemplate); + IngestJobSettings ingestJobSettings = new IngestJobSettings(EmbeddedFileTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates); - try { IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -90,7 +90,12 @@ public void setUp() { @Override public void tearDown() { - CaseUtils.closeCurrentCase(); + try { + CaseUtils.closeCurrentCase(); + } catch (TestUtilsException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex.getMessage()); + } } public void testAll() { @@ -102,7 +107,7 @@ public void testAll() { runTestEmbeddedFile(); runTestContent(); } - + private void runTestEncryptionAndZipBomb() { try { Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Starting"); diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java index 262e54774ffde28af61957f5ffefa8db22b93e13..8cd6822f23ca67e543ba37302843bd5d0d242eff 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java @@ -47,6 +47,7 @@ import org.sleuthkit.autopsy.testutils.CaseUtils; import org.sleuthkit.autopsy.testutils.IngestJobRunner; import org.sleuthkit.autopsy.testutils.IngestUtils; +import org.sleuthkit.autopsy.testutils.TestUtilsException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; @@ -57,9 +58,9 @@ */ public class IngestFileFiltersTest extends NbTestCase { - private final Path IMAGE_PATH = Paths.get(this.getDataDir().toString(),"IngestFilters_img1_v1.img"); + private final Path IMAGE_PATH = Paths.get(this.getDataDir().toString(), "IngestFilters_img1_v1.img"); private final Path ZIPFILE_PATH = Paths.get(this.getDataDir().toString(), "IngestFilters_local1_v1.zip"); - + public static Test suite() { NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(IngestFileFiltersTest.class). clusters(".*"). @@ -70,25 +71,30 @@ public static Test suite() { public IngestFileFiltersTest(String name) { super(name); } - + @Override public void tearDown() { - CaseUtils.closeCurrentCase(); + try { + CaseUtils.closeCurrentCase(); + } catch (TestUtilsException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex.getMessage()); + } } - + public void testBasicDir() { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); - Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testBasicDir"); - ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); + try { + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); + Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testBasicDir"); + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - HashMap<String, Rule> rule = new HashMap<>(); - rule.put("Rule", new Rule("testFileType", null, new MetaTypeCondition(MetaTypeCondition.Type.FILES), new ParentPathCondition("dir1"), null, null, null)); - //Filter for dir1 and no unallocated space - FilesSet dirFilter = new FilesSet("Filter", "Filter to find all files in dir1.", false, true, rule); + HashMap<String, Rule> rule = new HashMap<>(); + rule.put("Rule", new Rule("testFileType", null, new MetaTypeCondition(MetaTypeCondition.Type.FILES), new ParentPathCondition("dir1"), null, null, null)); + //Filter for dir1 and no unallocated space + FilesSet dirFilter = new FilesSet("Filter", "Filter to find all files in dir1.", false, true, rule); - try { - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, dirFilter); IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); @@ -96,9 +102,9 @@ public void testBasicDir() { List<AbstractFile> results = fileManager.findFiles("file.jpg", "dir1"); String mimeType = results.get(0).getMIMEType(); assertEquals("image/jpeg", mimeType); - + results = fileManager.findFiles("%%"); - + for (AbstractFile file : results) { //All files in dir1 should have MIME type, except '.' '..' and slack files if (file.getParentPath().equalsIgnoreCase("/dir1/")) { @@ -111,29 +117,29 @@ public void testBasicDir() { assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } } - + public void testExtAndDirWithOneRule() { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); - Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testExtAndDirWithOneRule"); - ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - - HashMap<String, Rule> rules = new HashMap<>(); - rules.put("Rule", new Rule("testExtAndDirWithOneRule", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), new ParentPathCondition("dir1"), null, null, null)); - //Build the filter that ignore unallocated space and with one rule - FilesSet filesExtDirsFilter = new FilesSet("Filter", "Filter to find all jpg files in dir1.", false, true, rules); - try { - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); + Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testExtAndDirWithOneRule"); + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); + + HashMap<String, Rule> rules = new HashMap<>(); + rules.put("Rule", new Rule("testExtAndDirWithOneRule", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), new ParentPathCondition("dir1"), null, null, null)); + //Build the filter that ignore unallocated space and with one rule + FilesSet filesExtDirsFilter = new FilesSet("Filter", "Filter to find all jpg files in dir1.", false, true, rules); + + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, filesExtDirsFilter); - IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); - FileManager fileManager = currentCase.getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); List<AbstractFile> results = fileManager.findFiles("%%"); assertEquals(62, results.size()); for (AbstractFile file : results) { @@ -146,38 +152,38 @@ public void testExtAndDirWithOneRule() { assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } } public void testExtAndDirWithTwoRules() { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); - Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testExtAndDirWithTwoRules"); - - ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - - HashMap<String, Rule> rules = new HashMap<>(); - rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - rules.put("rule2", new Rule("FindDir1Directory", null, new MetaTypeCondition(MetaTypeCondition.Type.FILES), new ParentPathCondition("dir1"), null, null, null)); - //Build the filter that ingnore unallocated space and with 2 rules - FilesSet filesExtDirsFilter = new FilesSet("Filter", "Filter to find all files in dir1 and all files with jpg extention.", false, true, rules); - try { - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); + Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testExtAndDirWithTwoRules"); + + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); + + HashMap<String, Rule> rules = new HashMap<>(); + rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + rules.put("rule2", new Rule("FindDir1Directory", null, new MetaTypeCondition(MetaTypeCondition.Type.FILES), new ParentPathCondition("dir1"), null, null, null)); + //Build the filter that ingnore unallocated space and with 2 rules + FilesSet filesExtDirsFilter = new FilesSet("Filter", "Filter to find all files in dir1 and all files with jpg extention.", false, true, rules); + + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, filesExtDirsFilter); - IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); - FileManager fileManager = currentCase.getServices().getFileManager(); - List<AbstractFile> results = fileManager.findFiles("%%"); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); + List<AbstractFile> results = fileManager.findFiles("%%"); assertEquals(62, results.size()); - for (AbstractFile file : results) { + for (AbstractFile file : results) { if (file.getNameExtension().equalsIgnoreCase("jpg")) { //All files with .jpg extension should have MIME type String errMsg = String.format("File %s (objId=%d) unexpectedly blocked by the file filter.", file.getName(), file.getId()); - assertTrue(errMsg, file.getMIMEType() != null && !file.getMIMEType().isEmpty()); - } else if (file.getParentPath().equalsIgnoreCase("/dir1/")) { + assertTrue(errMsg, file.getMIMEType() != null && !file.getMIMEType().isEmpty()); + } else if (file.getParentPath().equalsIgnoreCase("/dir1/")) { //All files in dir1 should have MIME type except '.' '..' slack files if (file.getName().equals(".") || file.getName().equals("..") || file.getType() == TskData.TSK_DB_FILES_TYPE_ENUM.SLACK) { String errMsg = String.format("File %s (objId=%d) unexpectedly passed by the file filter.", file.getName(), file.getId()); @@ -188,32 +194,32 @@ public void testExtAndDirWithTwoRules() { } } else { //All files that are not in dir1 or not with .jpg extension should not have MIME type String errMsg = String.format("File %s (objId=%d) unexpectedly passed by the file filter.", file.getName(), file.getId()); - assertTrue(errMsg, file.getMIMEType() == null); + assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } - } - + } + public void testFullFileNameRule() { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); - Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testFullFileNameRule"); - ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - - HashMap<String, Rule> rules = new HashMap<>(); - rules.put("rule", new Rule("FindFileWithFullName", new FullNameCondition("file.docx"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - //Build the filter to find file: file.docx - FilesSet fullNameFilter = new FilesSet("Filter", "Filter to find file.docx.", false, true, rules); - try { - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); + Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testFullFileNameRule"); + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); + + HashMap<String, Rule> rules = new HashMap<>(); + rules.put("rule", new Rule("FindFileWithFullName", new FullNameCondition("file.docx"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + //Build the filter to find file: file.docx + FilesSet fullNameFilter = new FilesSet("Filter", "Filter to find file.docx.", false, true, rules); + + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, fullNameFilter); - IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); - FileManager fileManager = currentCase.getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); List<AbstractFile> results = fileManager.findFiles("%%"); assertEquals(62, results.size()); for (AbstractFile file : results) { @@ -226,40 +232,40 @@ public void testFullFileNameRule() { assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } } public void testCarvingWithExtRuleAndUnallocSpace() { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); - Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testCarvingWithExtRuleAndUnallocSpace"); - ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - - HashMap<String, Rule> rules = new HashMap<>(); - rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - rules.put("rule2", new Rule("FindGifExtention", new ExtensionCondition("gif"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - - //Build the filter to find files with .jpg and .gif extension and unallocated space - FilesSet extensionFilter = new FilesSet("Filter", "Filter to files with .jpg and .gif extension.", false, false, rules); - try { - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); + Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testCarvingWithExtRuleAndUnallocSpace"); + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); + + HashMap<String, Rule> rules = new HashMap<>(); + rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + rules.put("rule2", new Rule("FindGifExtention", new ExtensionCondition("gif"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + + //Build the filter to find files with .jpg and .gif extension and unallocated space + FilesSet extensionFilter = new FilesSet("Filter", "Filter to files with .jpg and .gif extension.", false, false, rules); + + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); templates.add(IngestUtils.getIngestModuleTemplate(new PhotoRecCarverIngestModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, extensionFilter); - IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); FileManager fileManager = currentCase.getServices().getFileManager(); List<AbstractFile> results = fileManager.findFiles("%%"); - assertEquals(70, results.size()); + assertEquals(70, results.size()); int carvedJpgGifFiles = 0; for (AbstractFile file : results) { if (file.getNameExtension().equalsIgnoreCase("jpg") || file.getNameExtension().equalsIgnoreCase("gif")) { //Unalloc file and .jpg files in dir1, dir2, $CarvedFiles, root directory should have MIME type String errMsg = String.format("File %s (objId=%d) unexpectedly blocked by the file filter.", file.getName(), file.getId()); assertTrue(errMsg, file.getMIMEType() != null && !file.getMIMEType().isEmpty()); - + if (file.getParentPath().equalsIgnoreCase("/$CarvedFiles/")) { carvedJpgGifFiles++; } @@ -274,27 +280,27 @@ public void testCarvingWithExtRuleAndUnallocSpace() { //Make sure we have carved jpg/gif files assertEquals(2, carvedJpgGifFiles); - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } } - + public void testCarvingNoUnallocatedSpace() { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); - Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testCarvingNoUnallocatedSpace"); - ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); - - HashMap<String, Rule> rules = new HashMap<>(); - rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - rules.put("rule2", new Rule("FindGifExtention", new ExtensionCondition("gif"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - - //Build the filter to find files with .jpg and .gif extension - FilesSet extensionFilter = new FilesSet("Filter", "Filter to files with .jpg and .gif extension.", false, true, rules); - try { - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); + Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testCarvingNoUnallocatedSpace"); + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); + + HashMap<String, Rule> rules = new HashMap<>(); + rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + rules.put("rule2", new Rule("FindGifExtention", new ExtensionCondition("gif"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + + //Build the filter to find files with .jpg and .gif extension + FilesSet extensionFilter = new FilesSet("Filter", "Filter to files with .jpg and .gif extension.", false, true, rules); + + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); templates.add(IngestUtils.getIngestModuleTemplate(new PhotoRecCarverIngestModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates, extensionFilter); @@ -307,29 +313,29 @@ public void testCarvingNoUnallocatedSpace() { } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); - } - } catch (TskCoreException ex) { + } + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } } public void testEmbeddedJpg() { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); - Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testEmbeddedJpg"); - LocalFilesDSProcessor dataSourceProcessor = new LocalFilesDSProcessor(); - IngestUtils.addDataSource(dataSourceProcessor, ZIPFILE_PATH); - - //Build the filter to find jpg files - HashMap<String, Rule> rules = new HashMap<>(); - //Extension condition for jpg files - rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - //Extension condition for zip files, because we want test jpg extension filter for extracted files from a zip file - rules.put("rule2", new Rule("ZipExtention", new ExtensionCondition("zip"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); - FilesSet embeddedFilter = new FilesSet("Filter", "Filter to files with .jpg extension.", false, false, rules); - try { - ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "---- Starting ----"); + Case currentCase = CaseUtils.createAsCurrentCase("IngestFilter_testEmbeddedJpg"); + LocalFilesDSProcessor dataSourceProcessor = new LocalFilesDSProcessor(); + IngestUtils.addDataSource(dataSourceProcessor, ZIPFILE_PATH); + + //Build the filter to find jpg files + HashMap<String, Rule> rules = new HashMap<>(); + //Extension condition for jpg files + rules.put("rule1", new Rule("FindJpgExtention", new ExtensionCondition("jpg"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + //Extension condition for zip files, because we want test jpg extension filter for extracted files from a zip file + rules.put("rule2", new Rule("ZipExtention", new ExtensionCondition("zip"), new MetaTypeCondition(MetaTypeCondition.Type.FILES), null, null, null, null)); + FilesSet embeddedFilter = new FilesSet("Filter", "Filter to files with .jpg extension.", false, false, rules); + + ArrayList<IngestModuleTemplate> templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); templates.add(IngestUtils.getIngestModuleTemplate(new EmbeddedFileExtractorModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, embeddedFilter); @@ -354,7 +360,7 @@ public void testEmbeddedJpg() { } //Make sure 10 jpg files and 1 zip file have been typed assertEquals(11, numTypeJpgFiles); - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java index 6ac80bfb892128224164c31df0594a4e814d7340..005bc24b34eb0200b17970bd58383a19ddb82b63 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java @@ -39,6 +39,7 @@ import org.sleuthkit.autopsy.ingest.IngestModuleTemplate; import org.sleuthkit.autopsy.testutils.CaseUtils; import org.sleuthkit.autopsy.testutils.IngestUtils; +import org.sleuthkit.autopsy.testutils.TestUtilsException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardAttribute; @@ -63,7 +64,7 @@ public class EncryptionDetectionTest extends NbTestCase { private final Path PASSWORD_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "PasswordDetection_img1_v1.img"); private final Path VERACRYPT_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "VeracryptDetection_img1_v1.vhd"); private final Path SQLCIPHER_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "SqlCipherDetection_img1_v1.vhd"); - + public static Test suite() { NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(EncryptionDetectionTest.class). clusters(".*"). @@ -74,12 +75,17 @@ public static Test suite() { public EncryptionDetectionTest(String name) { super(name); } - + @Override public void tearDown() { - CaseUtils.closeCurrentCase(); + try { + CaseUtils.closeCurrentCase(); + } catch (TestUtilsException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex.getMessage()); + } } - + /** * Test the Encryption Detection module's volume encryption detection. */ @@ -89,7 +95,7 @@ public void testBitlockerEncryption() { Case openCase = CaseUtils.createAsCurrentCase(BITLOCKER_DETECTION_CASE_NAME); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, BITLOCKER_DETECTION_IMAGE_PATH); - + /* * Create ingest job settings and run ingest job. */ @@ -145,7 +151,7 @@ public void testBitlockerEncryption() { errorMessage = "Expected to find 'vol2', but no such volume exists."; assertEquals(errorMessage, true, vol2Found); - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -231,7 +237,7 @@ public void testPasswordProtection() { } } } - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -285,7 +291,7 @@ public void testVeraCryptSupport() { numberOfEncryptedContainers += file.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_SUSPECTED).size(); } assertEquals("Encrypted Container file should have one encyption suspected artifact", 1, numberOfEncryptedContainers); - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -349,10 +355,10 @@ public void testSqlCipherEncryption() { } } } - } catch (TskCoreException ex) { + } catch (TskCoreException | TestUtilsException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } - } - + } + } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/junitwrapped/CaseUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/junitwrapped/CaseUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..463c3e29857f749c9c625dd45c19203d7c34d587 --- /dev/null +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/junitwrapped/CaseUtils.java @@ -0,0 +1,16 @@ +package org.sleuthkit.autopsy.testutils.junitwrapped; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * + * @author gregd + */ +public class CaseUtils { + + private CaseUtils() { + } +}