mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #3790 from dgrove727/3850_CaseUtilsImprovements_2a
Keep case directory when test fails.
This commit is contained in:
commit
d0308d2b91
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,7 +13,6 @@
|
|||||||
/Core/dist/
|
/Core/dist/
|
||||||
/Core/nbproject/*
|
/Core/nbproject/*
|
||||||
/Core/test/qa-functional/data/*
|
/Core/test/qa-functional/data/*
|
||||||
/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/.preserve
|
|
||||||
!/Core/nbproject/project.xml
|
!/Core/nbproject/project.xml
|
||||||
!/Core/nbproject/project.properties
|
!/Core/nbproject/project.properties
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import org.openide.util.Exceptions;
|
|||||||
import org.python.icu.impl.Assert;
|
import org.python.icu.impl.Assert;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.casemodule.ImageDSProcessor;
|
import org.sleuthkit.autopsy.casemodule.ImageDSProcessor;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
|
||||||
import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType;
|
import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType;
|
||||||
import org.sleuthkit.autopsy.modules.embeddedfileextractor.EmbeddedFileExtractorModuleFactory;
|
import org.sleuthkit.autopsy.modules.embeddedfileextractor.EmbeddedFileExtractorModuleFactory;
|
||||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory;
|
import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory;
|
||||||
@ -48,6 +47,8 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
public static final String HASH_VALUE = "098f6bcd4621d373cade4e832627b4f6";
|
public static final String HASH_VALUE = "098f6bcd4621d373cade4e832627b4f6";
|
||||||
private static final int DEEP_FOLDER_COUNT = 25;
|
private static final int DEEP_FOLDER_COUNT = 25;
|
||||||
private Case openCase;
|
private Case openCase;
|
||||||
|
|
||||||
|
private boolean testSucceeded;
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(EmbeddedFileTest.class).
|
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(EmbeddedFileTest.class).
|
||||||
@ -62,6 +63,8 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
testSucceeded = false;
|
||||||
|
|
||||||
openCase = CaseUtils.createAsCurrentCase(CASE_NAME);
|
openCase = CaseUtils.createAsCurrentCase(CASE_NAME);
|
||||||
ImageDSProcessor dataSourceProcessor = new ImageDSProcessor();
|
ImageDSProcessor dataSourceProcessor = new ImageDSProcessor();
|
||||||
IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH);
|
IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH);
|
||||||
@ -84,7 +87,7 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
CaseUtils.closeCurrentCase();
|
CaseUtils.closeCurrentCase(testSucceeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEncryption() {
|
public void testEncryption() {
|
||||||
@ -117,6 +120,7 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBigFolder() {
|
public void testBigFolder() {
|
||||||
@ -143,6 +147,7 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeepFolder() {
|
public void testDeepFolder() {
|
||||||
@ -165,6 +170,7 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEmbeddedFile() {
|
public void testEmbeddedFile() {
|
||||||
@ -190,6 +196,7 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testContent() {
|
public void testContent() {
|
||||||
@ -213,7 +220,9 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtension() {
|
public void testExtension() {
|
||||||
@ -225,7 +234,9 @@ public class EmbeddedFileTest extends NbTestCase {
|
|||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkEachFileInDeepFolder(AbstractFile file, StringBuffer dirReached, ArrayList<String> fileReached, int numOfDir) {
|
private void checkEachFileInDeepFolder(AbstractFile file, StringBuffer dirReached, ArrayList<String> fileReached, int numOfDir) {
|
||||||
|
@ -55,6 +55,8 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
private final Path IMAGE_PATH = Paths.get(this.getDataDir().toString(),"filter_test1.img");
|
private final Path IMAGE_PATH = Paths.get(this.getDataDir().toString(),"filter_test1.img");
|
||||||
private final Path ZIPFILE_PATH = Paths.get(this.getDataDir().toString(), "local_files_test.zip");
|
private final Path ZIPFILE_PATH = Paths.get(this.getDataDir().toString(), "local_files_test.zip");
|
||||||
|
|
||||||
|
private boolean testSucceeded;
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(IngestFileFiltersTest.class).
|
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(IngestFileFiltersTest.class).
|
||||||
clusters(".*").
|
clusters(".*").
|
||||||
@ -65,10 +67,15 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
public IngestFileFiltersTest(String name) {
|
public IngestFileFiltersTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUp() {
|
||||||
|
testSucceeded = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
CaseUtils.closeCurrentCase();
|
CaseUtils.closeCurrentCase(testSucceeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBasicDir() {
|
public void testBasicDir() {
|
||||||
@ -110,6 +117,7 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtAndDirWithOneRule() {
|
public void testExtAndDirWithOneRule() {
|
||||||
@ -144,6 +152,8 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtAndDirWithTwoRules() {
|
public void testExtAndDirWithTwoRules() {
|
||||||
@ -187,6 +197,8 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFullFileNameRule() {
|
public void testFullFileNameRule() {
|
||||||
@ -221,6 +233,8 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCarvingWithExtRuleAndUnallocSpace() {
|
public void testCarvingWithExtRuleAndUnallocSpace() {
|
||||||
@ -268,6 +282,8 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCarvingNoUnallocatedSpace() {
|
public void testCarvingNoUnallocatedSpace() {
|
||||||
@ -300,6 +316,8 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEmbeddedModule() {
|
public void testEmbeddedModule() {
|
||||||
@ -345,5 +363,7 @@ public class IngestFileFiltersTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,8 @@ public class EncryptionDetectionTest extends NbTestCase {
|
|||||||
private final Path BITLOCKER_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "encryption_detection_bitlocker_test.vhd");
|
private final Path BITLOCKER_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "encryption_detection_bitlocker_test.vhd");
|
||||||
private final Path PASSWORD_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "password_detection_test.img");
|
private final Path PASSWORD_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "password_detection_test.img");
|
||||||
private final Path VERACRYPT_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "veracrypt_detection_test.vhd");
|
private final Path VERACRYPT_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "veracrypt_detection_test.vhd");
|
||||||
|
|
||||||
|
private boolean testSucceeded;
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(EncryptionDetectionTest.class).
|
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(EncryptionDetectionTest.class).
|
||||||
@ -67,10 +69,15 @@ public class EncryptionDetectionTest extends NbTestCase {
|
|||||||
public EncryptionDetectionTest(String name) {
|
public EncryptionDetectionTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUp() {
|
||||||
|
testSucceeded = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
CaseUtils.closeCurrentCase();
|
CaseUtils.closeCurrentCase(testSucceeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,6 +148,8 @@ public class EncryptionDetectionTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,6 +236,8 @@ public class EncryptionDetectionTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -280,6 +291,8 @@ public class EncryptionDetectionTest extends NbTestCase {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testSucceeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Scanner;
|
|
||||||
import static junit.framework.Assert.assertFalse;
|
import static junit.framework.Assert.assertFalse;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@ -78,37 +77,25 @@ public final class CaseUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close and delete the current case. This will fail the test if the case
|
* Close the current case. This will fail the test if the case
|
||||||
* was unable to be closed.
|
* was unable to be closed.
|
||||||
*
|
*
|
||||||
* Note: This method will skip case deletion if '.preserve' exists in the
|
* @param deleteCase Delete the case after closure?
|
||||||
* 'org.sleuthkit.autopsy.testutils' package and includes the current case
|
|
||||||
* path.
|
|
||||||
*/
|
*/
|
||||||
public static void closeCurrentCase() {
|
public static void closeCurrentCase(boolean deleteCase) {
|
||||||
try {
|
try {
|
||||||
if (Case.isCaseOpen()) {
|
if (Case.isCaseOpen()) {
|
||||||
String currentCaseDirectory = Case.getCurrentCase().getCaseDirectory();
|
String currentCaseDirectory = Case.getCurrentCase().getCaseDirectory();
|
||||||
Case.closeCurrentCase();
|
Case.closeCurrentCase();
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
/*
|
// Seems like we need some time to close the case, so file handler later can delete the case directory.
|
||||||
* Look for the current case directory in '.preserved'. If
|
try {
|
||||||
* found, skip case deletion.
|
Thread.sleep(20000);
|
||||||
*/
|
} catch (InterruptedException ex) {
|
||||||
boolean deleteCase = true;
|
|
||||||
File preserveListFile = new File(
|
|
||||||
CaseUtils.class.getResource(PRESERVE_CASE_DATA_LIST_FILE_NAME).toExternalForm()
|
|
||||||
.substring(6)); // Use substring to remove "file:\" from path.
|
|
||||||
if (preserveListFile.exists()) {
|
|
||||||
Scanner scanner = new Scanner(preserveListFile);
|
|
||||||
while (scanner.hasNext()) {
|
|
||||||
if (scanner.nextLine().equalsIgnoreCase(currentCaseDirectory)) {
|
|
||||||
deleteCase = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteCase) {
|
if (deleteCase) {
|
||||||
deleteCaseDir(new File(currentCaseDirectory));
|
deleteCaseDir(new File(currentCaseDirectory));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user