mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
refactor and working through components
This commit is contained in:
parent
96246e3fec
commit
c7c23babcc
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.datasourcesummary;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary;
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary.TopDomainsResult;
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.IntegrationTest;
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.IntegrationTests;
|
||||||
|
import org.sleuthkit.datamodel.Content;
|
||||||
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
import org.openide.util.lookup.ServiceProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the UserActivitySummary class.
|
||||||
|
*/
|
||||||
|
@ServiceProvider(service = IntegrationTests.class)
|
||||||
|
public class UserActivitySummaryTests implements IntegrationTests {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs UserActivitySummary.getRecentDomains for all data sources found in
|
||||||
|
* the current case.
|
||||||
|
*
|
||||||
|
* @return A map where the key is the data source name and the value are the
|
||||||
|
* results of that method.
|
||||||
|
*/
|
||||||
|
@IntegrationTest
|
||||||
|
public Map<String, List<TopDomainsResult>> getRecentDomainsTest()
|
||||||
|
throws NoCurrentCaseException, TskCoreException, SleuthkitCaseProviderException {
|
||||||
|
|
||||||
|
UserActivitySummary userActivitySummary = new UserActivitySummary();
|
||||||
|
Map<String, List<TopDomainsResult>> toRet = new HashMap<>();
|
||||||
|
for (Content c : Case.getCurrentCaseThrows().getDataSources()) {
|
||||||
|
if (c instanceof DataSource) {
|
||||||
|
DataSource ds = (DataSource) c;
|
||||||
|
List<TopDomainsResult> thisResult = userActivitySummary.getRecentDomains(ds, 10);
|
||||||
|
toRet.put(ds.getName(), thisResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toRet;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//...other tests for other methods in the class...
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
OpenIDE-Module-Name=Integration Testing
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation similar to Junit's @Test for outputing results as a part of an
|
||||||
|
* integration test.
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface IntegrationTest {
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic interface for integration test suite.
|
||||||
|
*/
|
||||||
|
public interface IntegrationTests {
|
||||||
|
/**
|
||||||
|
* Allows for a test to perform any necessary setup.
|
||||||
|
*/
|
||||||
|
default void setup() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for a test to perform any necessary disposing of resources.
|
||||||
|
*/
|
||||||
|
default void tearDown() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for this suite of tests to perform any necessary setup.
|
||||||
|
*/
|
||||||
|
default void setupClass() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for this suite of tests to dispose of resources.
|
||||||
|
*/
|
||||||
|
default void tearDownClass() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,287 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.config.IntegrationTestConfig;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.apache.cxf.common.util.CollectionUtils;
|
||||||
|
import org.netbeans.junit.NbModuleSuite;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
|
import org.openide.util.Lookup;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case.CaseType;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.CaseActionException;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.ImageDSProcessor;
|
||||||
|
import org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor;
|
||||||
|
import org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException;
|
||||||
|
import org.sleuthkit.autopsy.datasourceprocessors.DataSourceProcessorUtility;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestJobSettings;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestModuleTemplate;
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.config.CaseConfig;
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.config.IntegrationCaseType;
|
||||||
|
import org.sleuthkit.autopsy.modules.encryptiondetection.EncryptionDetectionModuleFactory;
|
||||||
|
import org.sleuthkit.autopsy.modules.encryptiondetection.EncryptionDetectionTest;
|
||||||
|
import org.sleuthkit.autopsy.testutils.CaseUtils;
|
||||||
|
import org.sleuthkit.autopsy.testutils.IngestUtils;
|
||||||
|
import org.sleuthkit.datamodel.Content;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main entry point for running integration tests. Handles processing
|
||||||
|
* parameters, ingesting data sources for cases, and running items implementing
|
||||||
|
* IntegrationTests.
|
||||||
|
*/
|
||||||
|
public class MainTestRunner extends TestCase {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(MainTestRunner.class.getName()); // DO NOT USE AUTOPSY LOGGER
|
||||||
|
private static final String CONFIG_FILE_KEY = "CONFIG_FILE_KEY";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor required by JUnit
|
||||||
|
*/
|
||||||
|
public MainTestRunner(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates suite from particular test cases.
|
||||||
|
*/
|
||||||
|
public static Test suite() {
|
||||||
|
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(MainTestRunner.class).
|
||||||
|
clusters(".*").
|
||||||
|
enableModules(".*");
|
||||||
|
|
||||||
|
return NbModuleSuite.create(conf.addTest("runIntegrationTests"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runIntegrationTests() {
|
||||||
|
String configFile = System.getProperty(CONFIG_FILE_KEY);
|
||||||
|
IntegrationTestConfig config;
|
||||||
|
try {
|
||||||
|
config = getConfigFromFile(configFile);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
logger.log(Level.WARNING, "There was an error processing integration test config at " + configFile, ex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config == null) {
|
||||||
|
logger.log(Level.WARNING, "No properly formatted config found at " + configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(config.getCases())) {
|
||||||
|
for (CaseConfig caseConfig : config.getCases()) {
|
||||||
|
for (CaseType caseType : IntegrationCaseType.getCaseTypes(caseConfig.getCaseTypes())) {
|
||||||
|
Case autopsyCase = runIngest(caseConfig, caseType);
|
||||||
|
if (autopsyCase == null || autopsyCase != Case.getCurrentCase()) {
|
||||||
|
logger.log(Level.WARNING,
|
||||||
|
String.format("Case was not properly ingested or setup correctly for environment. Case is %s and current case is %s.",
|
||||||
|
autopsyCase, Case.getCurrentCase()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String caseName = autopsyCase.getName();
|
||||||
|
|
||||||
|
runIntegrationTests(config, caseConfig, caseType);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Case.closeCurrentCase();
|
||||||
|
} catch (CaseActionException ex) {
|
||||||
|
logger.log(Level.WARNING, "There was an error while trying to close current case: {0}", caseName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Case runIngest(CaseConfig caseConfig, CaseType caseType) {
|
||||||
|
Case openCase = null;
|
||||||
|
switch (caseType) {
|
||||||
|
case SINGLE_USER_CASE:
|
||||||
|
openCase = CaseUtils.createAsCurrentCase(caseConfig.getCaseName());
|
||||||
|
break;
|
||||||
|
case MULTI_USER_CASE:
|
||||||
|
// TODO
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown case type: " + caseType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (openCase == null) {
|
||||||
|
logger.log(Level.WARNING, String.format("No case could be created for %s of type %s.", caseConfig.getCaseName(), caseType));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
addDataSourcesToCase(caseConfig.getDataSourceResources(), caseConfig.getCaseName());
|
||||||
|
try {
|
||||||
|
IngestUtils.runIngestJob(openCase.getDataSources(), getIngestSettings(caseConfig));
|
||||||
|
} catch (TskCoreException ex) {
|
||||||
|
logger.log(Level.WARNING, String.format("There was an error while ingesting datasources for case %s", caseConfig.getCaseName()), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return openCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void addDataSourcesToCase(List<String> pathStrings, String caseName) {
|
||||||
|
for (String strPath : pathStrings) {
|
||||||
|
Path path = Paths.get(strPath);
|
||||||
|
List<AutoIngestDataSourceProcessor> processors = null;
|
||||||
|
try {
|
||||||
|
processors = DataSourceProcessorUtility.getOrderedListOfDataSourceProcessors(path);
|
||||||
|
} catch (AutoIngestDataSourceProcessorException ex) {
|
||||||
|
logger.log(Level.WARNING, String.format("There was an error while adding data source: %s to case %s", strPath, caseName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(processors)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IngestUtils.addDataSource(processors.get(0), path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntegrationTestConfig getConfigFromFile(String filePath) throws IOException {
|
||||||
|
ObjectMapper om = new ObjectMapper();
|
||||||
|
try (FileInputStream jsonSrc = new FileInputStream(filePath)) {
|
||||||
|
return om.readValue(jsonSrc, IntegrationTestConfig.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IngestJobSettings getIngestSettings(CaseConfig caseConfig) {
|
||||||
|
// TODO
|
||||||
|
ImageDSProcessor dataSourceProcessor = new ImageDSProcessor();
|
||||||
|
IngestUtils.addDataSource(dataSourceProcessor, BITLOCKER_DETECTION_IMAGE_PATH);
|
||||||
|
IngestModuleFactory ingestModuleFactory = new EncryptionDetectionModuleFactory();
|
||||||
|
IngestModuleIngestJobSettings settings = ingestModuleFactory.getDefaultIngestJobSettings();
|
||||||
|
IngestModuleTemplate template = new IngestModuleTemplate(ingestModuleFactory, settings);
|
||||||
|
template.setEnabled(true);
|
||||||
|
List<IngestModuleTemplate> templates = new ArrayList<>();
|
||||||
|
templates.add(template);
|
||||||
|
IngestJobSettings ingestJobSettings = new IngestJobSettings(EncryptionDetectionTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runIntegrationTests(IntegrationTestConfig config, CaseConfig caseConfig, CaseType caseType) {
|
||||||
|
// this will capture output results
|
||||||
|
OutputResults results = new OutputResults();
|
||||||
|
|
||||||
|
// run through each ConsumerIntegrationTest
|
||||||
|
for (IntegrationTests testGroup : Lookup.getDefault().lookupAll(IntegrationTests.class)) {
|
||||||
|
|
||||||
|
// if test should not be included in results, skip it.
|
||||||
|
if (!caseConfig.getTestConfig().hasIncludedTest(testGroup.getClass().getCanonicalName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Method> testMethods = getIntegrationTestMethods(testGroup);
|
||||||
|
if (CollectionUtils.isEmpty(testMethods)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
testGroup.setupClass();
|
||||||
|
for (Method testMethod : testMethods) {
|
||||||
|
runIntegrationTestMethod(results, testGroup, testMethod);
|
||||||
|
}
|
||||||
|
testGroup.tearDownClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the results for the case to a file
|
||||||
|
serializeFile(results, config.getRootTestOutputPath(), caseConfig.getCaseName(), getCaseTypeId(caseType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCaseTypeId(CaseType caseType) {
|
||||||
|
if (caseType == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (caseType) {
|
||||||
|
case SINGLE_USER_CASE:
|
||||||
|
return "singleUser";
|
||||||
|
case MULTI_USER_CASE:
|
||||||
|
return "multiUser";
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown case type: " + caseType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runIntegrationTestMethod(OutputResults results, IntegrationTests testGroup, Method testMethod) {
|
||||||
|
testGroup.setup();
|
||||||
|
|
||||||
|
// run the test method and get the results
|
||||||
|
Object serializableResult = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
serializableResult = testMethod.invoke(testGroup);
|
||||||
|
} catch (IllegalAccessException | IllegalArgumentException ex) {
|
||||||
|
logger.log(Level.WARNING,
|
||||||
|
String.format("test method %s in %s could not be properly invoked",
|
||||||
|
testMethod.getName(), testGroup.getClass().getCanonicalName()),
|
||||||
|
ex);
|
||||||
|
|
||||||
|
serializableResult = ex;
|
||||||
|
} catch (InvocationTargetException ex) {
|
||||||
|
serializableResult = ex.getCause();
|
||||||
|
}
|
||||||
|
|
||||||
|
testGroup.tearDown();
|
||||||
|
|
||||||
|
// add the results and capture the package, class,
|
||||||
|
// and method of the test for easy location of failed tests
|
||||||
|
results.addResult(
|
||||||
|
testGroup.getClass().getPackage().getName(),
|
||||||
|
testGroup.getClass().getSimpleName(),
|
||||||
|
testMethod.getName(),
|
||||||
|
serializableResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Method> getIntegrationTestMethods(IntegrationTests testGroup) {
|
||||||
|
return Stream.of(testGroup.getClass().getMethods())
|
||||||
|
.filter((method) -> method.getAnnotation(IntegrationTest.class) != null)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void serializeFile(OutputResults results, String outputFolder, String caseName, String caseType) {
|
||||||
|
String outputExtension = ".yml";
|
||||||
|
Path outputPath = Paths.get(outputFolder, String.format("%s-%s%s", caseName, caseType, outputExtension));
|
||||||
|
ObjectMapper om = new ObjectMapper(new YAMLFactory());
|
||||||
|
|
||||||
|
try {
|
||||||
|
om.writeValue(outputPath.toFile(), results.getSerializableData());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
logger.log(Level.WARNING, "There was an error writing results to outputPath: " + outputPath, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration Test results for a case to be written to disk in a text format.
|
||||||
|
*/
|
||||||
|
public class OutputResults {
|
||||||
|
|
||||||
|
private static class ExceptionObject {
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
private final String stackTrace;
|
||||||
|
private final ExceptionObject innerException;
|
||||||
|
|
||||||
|
ExceptionObject(Throwable t) {
|
||||||
|
this.message = t.getMessage();
|
||||||
|
this.stackTrace = ExceptionUtils.getStackTrace(t);
|
||||||
|
this.innerException = (t.getCause() == null) ? null : new ExceptionObject(t.getCause());
|
||||||
|
}
|
||||||
|
|
||||||
|
String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getStackTrace() {
|
||||||
|
return stackTrace;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExceptionObject getInnerException() {
|
||||||
|
return innerException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Map<String, Map<String, Map<String, Object>>> data = new HashMap<>();
|
||||||
|
|
||||||
|
private static <K, V> V getOrCreate(Map<K, V> map, K key, Supplier<V> onNotPresent) {
|
||||||
|
V curValue = map.get(key);
|
||||||
|
if (curValue == null) {
|
||||||
|
curValue = onNotPresent.get();
|
||||||
|
map.put(key, curValue);
|
||||||
|
}
|
||||||
|
return curValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addResult(String pkgName, String className, String methodName, Object result) {
|
||||||
|
Map<String, Map<String, Object>> packageClasses = getOrCreate(data, pkgName, () -> new HashMap<>());
|
||||||
|
Map<String, Object> classMethods = getOrCreate(packageClasses, className, () -> new HashMap<>());
|
||||||
|
Object toWrite = result instanceof Throwable ? new ExceptionObject((Throwable) result) : result;
|
||||||
|
classMethods.put(methodName, toWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getSerializableData() {
|
||||||
|
return Collections.unmodifiableMap(data);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration in IntegrationTests per case.
|
||||||
|
*/
|
||||||
|
public class CaseConfig {
|
||||||
|
private final String caseName;
|
||||||
|
private final List<String> dataSourceResources;
|
||||||
|
private final String ingestProfilePath;
|
||||||
|
private final String ingestModuleSettingsPath;
|
||||||
|
private final IntegrationCaseType caseTypes;
|
||||||
|
private final TestingConfig testConfig;
|
||||||
|
|
||||||
|
public CaseConfig(String caseName, List<String> dataSourceResources,
|
||||||
|
String ingestProfilePath, String ingestModuleSettingsPath,
|
||||||
|
IntegrationCaseType caseTypes, TestingConfig testConfig) {
|
||||||
|
this.caseName = caseName;
|
||||||
|
this.dataSourceResources = dataSourceResources;
|
||||||
|
this.ingestProfilePath = ingestProfilePath;
|
||||||
|
this.ingestModuleSettingsPath = ingestModuleSettingsPath;
|
||||||
|
this.caseTypes = caseTypes;
|
||||||
|
this.testConfig = testConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCaseName() {
|
||||||
|
return caseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDataSourceResources() {
|
||||||
|
return dataSourceResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIngestProfilePath() {
|
||||||
|
return ingestProfilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIngestModuleSettingsPath() {
|
||||||
|
return ingestModuleSettingsPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegrationCaseType getCaseTypes() {
|
||||||
|
return caseTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestingConfig getTestConfig() {
|
||||||
|
return testConfig;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case.CaseType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The case types to create for this case.
|
||||||
|
*/
|
||||||
|
public enum IntegrationCaseType {
|
||||||
|
multiUser, singleUser, both;
|
||||||
|
|
||||||
|
public static List<CaseType> getCaseTypes(IntegrationCaseType integrationCaseType) {
|
||||||
|
if (integrationCaseType == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (integrationCaseType) {
|
||||||
|
case multiUser: return Arrays.asList(CaseType.MULTI_USER_CASE);
|
||||||
|
case singleUser: return Arrays.asList(CaseType.SINGLE_USER_CASE);
|
||||||
|
case both: return Arrays.asList(CaseType.MULTI_USER_CASE, CaseType.SINGLE_USER_CASE);
|
||||||
|
default: throw new IllegalArgumentException("Unknown integration case type: " + integrationCaseType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for running Integration Tests including things like ingest
|
||||||
|
* parameters, datasource locations, cases to create, tests to run, etc.
|
||||||
|
*/
|
||||||
|
public class IntegrationTestConfig {
|
||||||
|
private final String rootCaseOutputPath;
|
||||||
|
private final String rootTestOutputPath;
|
||||||
|
private final List<CaseConfig> cases;
|
||||||
|
|
||||||
|
public IntegrationTestConfig(String rootCaseOutputPath,
|
||||||
|
String rootTestOutputPath, List<CaseConfig> cases) {
|
||||||
|
this.rootCaseOutputPath = rootCaseOutputPath;
|
||||||
|
this.rootTestOutputPath = rootTestOutputPath;
|
||||||
|
this.cases = cases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRootCaseOutputPath() {
|
||||||
|
return rootCaseOutputPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRootTestOutputPath() {
|
||||||
|
return rootTestOutputPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CaseConfig> getCases() {
|
||||||
|
return cases;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for which integration test suites to run.
|
||||||
|
*/
|
||||||
|
public class TestingConfig {
|
||||||
|
private final Set<String> excludeAllExcept;
|
||||||
|
private final Set<String> includeAllExcept;
|
||||||
|
|
||||||
|
private static Set<String> convert(List<String> orig) {
|
||||||
|
if (orig == null) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
return orig.stream()
|
||||||
|
.map((item) -> item.toUpperCase())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public TestingConfig(@JsonProperty() List<String> excludeAllExcept, @JsonProperty() List<String> includeAllExcept) {
|
||||||
|
this.excludeAllExcept = convert(excludeAllExcept);
|
||||||
|
this.includeAllExcept = convert(includeAllExcept);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getExcludeAllExcept() {
|
||||||
|
return excludeAllExcept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getIncludeAllExcept() {
|
||||||
|
return includeAllExcept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasIncludedTest(String itemType) {
|
||||||
|
if (itemType == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(includeAllExcept)) {
|
||||||
|
if (includeAllExcept.contains(itemType.toUpperCase())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(excludeAllExcept)) {
|
||||||
|
return excludeAllExcept.contains(itemType.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
5
IntegrationTesting/README.txt
Normal file
5
IntegrationTesting/README.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
This folder contains the Test module that is used to drive Autopsy. It
|
||||||
|
relies on NetBeans libraries to drive the UI. The test folder in the
|
||||||
|
root directory contains scripts and gold standard files to compare
|
||||||
|
against. That folder is where you should run regression tests from.
|
||||||
|
|
95
IntegrationTesting/build.xml
Normal file
95
IntegrationTesting/build.xml
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
|
||||||
|
<!-- for some information on what you could do (e.g. targets to override). -->
|
||||||
|
<!-- If you delete this file and reopen the project it will be recreated. -->
|
||||||
|
<project name="org.sleuthkit.autopsy.integrationtesting" default="netbeans" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project org.sleuthkit.autopsy.integrationtesting.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<property name="regression" value="qa-functional"/>
|
||||||
|
|
||||||
|
<target name="check-args">
|
||||||
|
<fail message="Missing required argument: img_path" unless="img_path"/>
|
||||||
|
<fail message="Missing required argument: gold_path" unless="gold_path"/>
|
||||||
|
<fail message="Missing required argument: out_path" unless="out_path"/>
|
||||||
|
<fail message="Missing required argument: known_bad_path" unless="known_bad_path"/>
|
||||||
|
<fail message="Missing required argument: nsrl_path" unless="nsrl_path"/>
|
||||||
|
<fail message="Missing required argument: keyword_path" unless="keyword_path"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- use manifestclasspath (http://ant.apache.org/manual/Tasks/manifestclasspath.html) to put all the jar files that we need for junit/regression test
|
||||||
|
to a single jar file: allJarsInUse.jar. Then we put this new jar to classpath for testing program to avoid command line Java classpath too long problem.
|
||||||
|
Note: Started from ant 1.10, maxParentLevels are enforced. If you get error from manifestclasspath complaines 'No suitable relative path from ...' then it's time to
|
||||||
|
increase your maxParentLevels -->
|
||||||
|
<target name="manifest-classpath">
|
||||||
|
<manifestclasspath property="tem.classpath" jarfile="allJarsInUse.jar" maxParentLevels="5">
|
||||||
|
<classpath refid="test.${regression}.run.cp"/>
|
||||||
|
</manifestclasspath>
|
||||||
|
<jar destfile="allJarsInUse.jar" basedir="build/classes">
|
||||||
|
<manifest>
|
||||||
|
<attribute name="Class-Path" value="${tem.classpath}"/>
|
||||||
|
</manifest>
|
||||||
|
</jar>
|
||||||
|
<path id="test.classpath">
|
||||||
|
<pathelement path="allJarsInUse.jar"/>
|
||||||
|
</path>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="regression-test" depends="check-args,init,test-init,test-build, manifest-classpath" if="exists.test.qa-functional.src.dir">
|
||||||
|
<test test.type="${regression}"/>
|
||||||
|
<delete file="allJarsInUse.jar"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<macrodef name="test">
|
||||||
|
<attribute name="test.type"/>
|
||||||
|
<attribute name="disable.apple.ui" default="false"/>
|
||||||
|
|
||||||
|
<sequential>
|
||||||
|
<property name="test.config" value="default"/>
|
||||||
|
<property name="test.config.default.includes" value="**/*Test.class"/>
|
||||||
|
<property name="test.config.${test.config}.includes" value="NOTHING"/>
|
||||||
|
<metaproperty name="test.includes" value="test.config.${test.config}.includes"/>
|
||||||
|
<property name="test.config.${test.config}.excludes" value=""/>
|
||||||
|
<metaproperty name="test.excludes" value="test.config.${test.config}.excludes"/>
|
||||||
|
<mkdir dir="${build.test.@{test.type}.results.dir}"/>
|
||||||
|
<junit fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}">
|
||||||
|
<batchtest todir="${build.test.@{test.type}.results.dir}">
|
||||||
|
<fileset dir="${build.test.@{test.type}.classes.dir}" includes="${test.includes}" excludes="${test.excludes}"/>
|
||||||
|
</batchtest>
|
||||||
|
<classpath refid="test.classpath"/>
|
||||||
|
<syspropertyset refid="test.@{test.type}.properties"/>
|
||||||
|
<jvmarg line="${test.bootclasspath.prepend.args}"/>
|
||||||
|
<jvmarg line="${test.run.args}"/>
|
||||||
|
<!-- should be in sync with project.properties and build.xml of autopsy main project -->
|
||||||
|
<!-- disable for now, causes issues with Java 7 -->
|
||||||
|
<!-- <jvmarg line="-J-Xms24m -J-Xmx512m -J-XX:MaxPermSize=128M -J-Xverify:none"/> -->
|
||||||
|
<sysproperty key="img_path" value="${img_path}"/>
|
||||||
|
<sysproperty key="gold_path" value="${gold_path}"/>
|
||||||
|
<sysproperty key="out_path" value="${out_path}"/>
|
||||||
|
<sysproperty key="known_bad_path" value="${known_bad_path}"/>
|
||||||
|
<sysproperty key="nsrl_path" value="${nsrl_path}"/>
|
||||||
|
<sysproperty key="keyword_path" value="${keyword_path}"/>
|
||||||
|
<sysproperty key="dbHost" value="${dbHost}"/>
|
||||||
|
<sysproperty key="dbPort" value="${dbPort}"/>
|
||||||
|
<sysproperty key="dbUserName" value="${dbUserName}"/>
|
||||||
|
<sysproperty key="dbPassword" value="${dbPassword}"/>
|
||||||
|
<sysproperty key="solrHost" value="${solrHost}"/>
|
||||||
|
<sysproperty key="solrPort" value="${solrPort}"/>
|
||||||
|
<sysproperty key="messageServiceHost" value="${messageServiceHost}"/>
|
||||||
|
<sysproperty key="messageServicePort" value="${messageServicePort}"/>
|
||||||
|
<sysproperty key="isMultiUser" value="${isMultiUser}"/>
|
||||||
|
<!--needed to have tests NOT to steal focus when running, works in latest apple jdk update only.-->
|
||||||
|
<sysproperty key="apple.awt.UIElement" value="@{disable.apple.ui}"/>
|
||||||
|
<formatter type="brief" usefile="false"/>
|
||||||
|
<formatter type="xml"/>
|
||||||
|
</junit>
|
||||||
|
<fail message="Some tests failed; see details above.">
|
||||||
|
<condition>
|
||||||
|
<and>
|
||||||
|
<isset property="tests.failed"/>
|
||||||
|
<isfalse value="${continue.after.failing.tests}"/>
|
||||||
|
</and>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
</project>
|
18
IntegrationTesting/ivy.xml
Normal file
18
IntegrationTesting/ivy.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
<ivy-module version="2.0">
|
||||||
|
<info organisation="org.sleuthkit.autopsy" module="integrationtesting"/>
|
||||||
|
<configurations >
|
||||||
|
<!-- module dependencies -->
|
||||||
|
<conf name="autopsy"/>
|
||||||
|
|
||||||
|
<!-- Solr server dependencies -->
|
||||||
|
<conf name="integrationtesting"/>
|
||||||
|
</configurations>
|
||||||
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.yaml/snakeyaml -->
|
||||||
|
<dependency org="org.yaml" name="snakeyaml" rev="1.27"/>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||||
|
<dependency org="com.google.code.gson" name="gson" rev="2.8.6"/>
|
||||||
|
</dependencies>
|
||||||
|
</ivy-module>
|
9
IntegrationTesting/ivysettings.xml
Normal file
9
IntegrationTesting/ivysettings.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<ivysettings>
|
||||||
|
<settings defaultResolver="main"/>
|
||||||
|
<resolvers>
|
||||||
|
<chain name="main">
|
||||||
|
<ibiblio name="central" root="https://repo1.maven.org/maven2" m2compatible="true"/>
|
||||||
|
<ibiblio name="maven.restlet.org" root="http://maven.restlet.com" m2compatible="true" />
|
||||||
|
</chain>
|
||||||
|
</resolvers>
|
||||||
|
</ivysettings>
|
6
IntegrationTesting/manifest.mf
Normal file
6
IntegrationTesting/manifest.mf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
AutoUpdate-Show-In-Client: false
|
||||||
|
OpenIDE-Module: org.sleuthkit.autopsy.integrationtesting/3
|
||||||
|
OpenIDE-Module-Implementation-Version: 11
|
||||||
|
OpenIDE-Module-Localizing-Bundle: org/sleuthkit/autopsy/integrationtesting/Bundle.properties
|
||||||
|
|
45
IntegrationTesting/nbproject/build-impl.xml
Normal file
45
IntegrationTesting/nbproject/build-impl.xml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||||
|
*** EDIT ../build.xml INSTEAD ***
|
||||||
|
-->
|
||||||
|
<project name="org.sleuthkit.autopsy.integrationtesting-impl" basedir="..">
|
||||||
|
<fail message="Please build using Ant 1.7.1 or higher.">
|
||||||
|
<condition>
|
||||||
|
<not>
|
||||||
|
<antversion atleast="1.7.1"/>
|
||||||
|
</not>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
<property file="nbproject/private/suite-private.properties"/>
|
||||||
|
<property file="nbproject/suite.properties"/>
|
||||||
|
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
|
||||||
|
<property file="${suite.dir}/nbproject/private/platform-private.properties"/>
|
||||||
|
<property file="${suite.dir}/nbproject/platform.properties"/>
|
||||||
|
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
|
||||||
|
<attribute name="name"/>
|
||||||
|
<attribute name="value"/>
|
||||||
|
<sequential>
|
||||||
|
<property name="@{name}" value="${@{value}}"/>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
|
||||||
|
<attribute name="property"/>
|
||||||
|
<attribute name="value"/>
|
||||||
|
<sequential>
|
||||||
|
<property name="@{property}" value="@{value}"/>
|
||||||
|
</sequential>
|
||||||
|
</macrodef>
|
||||||
|
<property file="${user.properties.file}"/>
|
||||||
|
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
|
||||||
|
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
|
||||||
|
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
|
||||||
|
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
|
||||||
|
<condition>
|
||||||
|
<not>
|
||||||
|
<contains string="${cluster.path.evaluated}" substring="platform"/>
|
||||||
|
</not>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
<import file="${harness.dir}/build.xml"/>
|
||||||
|
</project>
|
6
IntegrationTesting/nbproject/project.properties
Normal file
6
IntegrationTesting/nbproject/project.properties
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
javac.source=1.8
|
||||||
|
javac.compilerargs=-Xlint -Xlint:-serial
|
||||||
|
license.file=../LICENSE-2.0.txt
|
||||||
|
nbm.homepage=http://www.sleuthkit.org/autopsy/
|
||||||
|
nbm.needs.restart=true
|
||||||
|
spec.version.base=1.3
|
114
IntegrationTesting/nbproject/project.xml
Normal file
114
IntegrationTesting/nbproject/project.xml
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.apisupport.project</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
|
||||||
|
<code-name-base>org.sleuthkit.autopsy.integrationtesting</code-name-base>
|
||||||
|
<suite-component/>
|
||||||
|
<module-dependencies>
|
||||||
|
<dependency>
|
||||||
|
<code-name-base>org.netbeans.libs.junit4</code-name-base>
|
||||||
|
<build-prerequisite/>
|
||||||
|
<compile-dependency/>
|
||||||
|
<run-dependency>
|
||||||
|
<specification-version>1.14</specification-version>
|
||||||
|
</run-dependency>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.jellytools.platform</code-name-base>
|
||||||
|
<build-prerequisite/>
|
||||||
|
<compile-dependency/>
|
||||||
|
<run-dependency>
|
||||||
|
<release-version>3</release-version>
|
||||||
|
<specification-version>3.28.1</specification-version>
|
||||||
|
</run-dependency>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.jemmy</code-name-base>
|
||||||
|
<build-prerequisite/>
|
||||||
|
<compile-dependency/>
|
||||||
|
<run-dependency>
|
||||||
|
<release-version>3</release-version>
|
||||||
|
<specification-version>3.26.1</specification-version>
|
||||||
|
</run-dependency>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
|
||||||
|
<build-prerequisite/>
|
||||||
|
<compile-dependency/>
|
||||||
|
<run-dependency>
|
||||||
|
<release-version>1</release-version>
|
||||||
|
<specification-version>1.86.1</specification-version>
|
||||||
|
</run-dependency>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<code-name-base>org.openide.util.lookup</code-name-base>
|
||||||
|
<build-prerequisite/>
|
||||||
|
<compile-dependency/>
|
||||||
|
<run-dependency>
|
||||||
|
<specification-version>8.40</specification-version>
|
||||||
|
</run-dependency>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<code-name-base>org.sleuthkit.autopsy.core</code-name-base>
|
||||||
|
<build-prerequisite/>
|
||||||
|
<compile-dependency/>
|
||||||
|
<run-dependency>
|
||||||
|
<release-version>10</release-version>
|
||||||
|
<specification-version>10.22</specification-version>
|
||||||
|
</run-dependency>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<code-name-base>org.sleuthkit.autopsy.keywordsearch</code-name-base>
|
||||||
|
<build-prerequisite/>
|
||||||
|
<compile-dependency/>
|
||||||
|
<run-dependency>
|
||||||
|
<release-version>6</release-version>
|
||||||
|
<specification-version>6.6</specification-version>
|
||||||
|
</run-dependency>
|
||||||
|
</dependency>
|
||||||
|
</module-dependencies>
|
||||||
|
<test-dependencies>
|
||||||
|
<test-type>
|
||||||
|
<name>qa-functional</name>
|
||||||
|
<test-dependency>
|
||||||
|
<code-name-base>org.netbeans.libs.junit4</code-name-base>
|
||||||
|
<compile-dependency/>
|
||||||
|
</test-dependency>
|
||||||
|
<test-dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.jellytools.java</code-name-base>
|
||||||
|
<compile-dependency/>
|
||||||
|
</test-dependency>
|
||||||
|
<test-dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.jellytools.platform</code-name-base>
|
||||||
|
<compile-dependency/>
|
||||||
|
</test-dependency>
|
||||||
|
<test-dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.jemmy</code-name-base>
|
||||||
|
<compile-dependency/>
|
||||||
|
</test-dependency>
|
||||||
|
<test-dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
|
||||||
|
<recursive/>
|
||||||
|
<compile-dependency/>
|
||||||
|
</test-dependency>
|
||||||
|
</test-type>
|
||||||
|
<test-type>
|
||||||
|
<name>unit</name>
|
||||||
|
<test-dependency>
|
||||||
|
<code-name-base>org.netbeans.libs.junit4</code-name-base>
|
||||||
|
<compile-dependency/>
|
||||||
|
</test-dependency>
|
||||||
|
<test-dependency>
|
||||||
|
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
|
||||||
|
<recursive/>
|
||||||
|
<compile-dependency/>
|
||||||
|
</test-dependency>
|
||||||
|
</test-type>
|
||||||
|
</test-dependencies>
|
||||||
|
<public-packages>
|
||||||
|
<package>org.sleuthkit.autopsy.integrationtesting</package>
|
||||||
|
</public-packages>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
1
IntegrationTesting/nbproject/suite.properties
Normal file
1
IntegrationTesting/nbproject/suite.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
suite.dir=${basedir}/..
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.datasourcesummary;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.SleuthkitCaseProvider.SleuthkitCaseProviderException;
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary;
|
||||||
|
import org.sleuthkit.autopsy.datasourcesummary.datamodel.UserActivitySummary.TopDomainsResult;
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.IntegrationTest;
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.IntegrationTests;
|
||||||
|
import org.sleuthkit.datamodel.Content;
|
||||||
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
import org.openide.util.lookup.ServiceProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the UserActivitySummary class.
|
||||||
|
*/
|
||||||
|
@ServiceProvider(service = IntegrationTests.class)
|
||||||
|
public class UserActivitySummaryTests implements IntegrationTests {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs UserActivitySummary.getRecentDomains for all data sources found in
|
||||||
|
* the current case.
|
||||||
|
*
|
||||||
|
* @return A map where the key is the data source name and the value are the
|
||||||
|
* results of that method.
|
||||||
|
*/
|
||||||
|
@IntegrationTest
|
||||||
|
public Map<String, List<TopDomainsResult>> getRecentDomainsTest()
|
||||||
|
throws NoCurrentCaseException, TskCoreException, SleuthkitCaseProviderException {
|
||||||
|
|
||||||
|
UserActivitySummary userActivitySummary = new UserActivitySummary();
|
||||||
|
Map<String, List<TopDomainsResult>> toRet = new HashMap<>();
|
||||||
|
for (Content c : Case.getCurrentCaseThrows().getDataSources()) {
|
||||||
|
if (c instanceof DataSource) {
|
||||||
|
DataSource ds = (DataSource) c;
|
||||||
|
List<TopDomainsResult> thisResult = userActivitySummary.getRecentDomains(ds, 10);
|
||||||
|
toRet.put(ds.getName(), thisResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toRet;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//...other tests for other methods in the class...
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
OpenIDE-Module-Name=Integration Testing
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation similar to Junit's @Test for outputing results as a part of an
|
||||||
|
* integration test.
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface IntegrationTest {
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic interface for integration test suite.
|
||||||
|
*/
|
||||||
|
public interface IntegrationTests {
|
||||||
|
/**
|
||||||
|
* Allows for a test to perform any necessary setup.
|
||||||
|
*/
|
||||||
|
default void Setup() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for a test to perform any necessary disposing of resources.
|
||||||
|
*/
|
||||||
|
default void TearDown() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for this suite of tests to perform any necessary setup.
|
||||||
|
*/
|
||||||
|
default void SetupClass() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for this suite of tests to dispose of resources.
|
||||||
|
*/
|
||||||
|
default void TeadDownClass() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting;
|
||||||
|
|
||||||
|
import org.sleuthkit.autopsy.integrationtesting.config.IntegrationTestConfig;
|
||||||
|
import java.lang.invoke.MethodHandles.Lookup;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.netbeans.junit.NbModuleSuite;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.ImageDSProcessor;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestJobSettings;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestModuleTemplate;
|
||||||
|
import org.sleuthkit.autopsy.modules.encryptiondetection.EncryptionDetectionModuleFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main entry point for running integration tests. Handles processing
|
||||||
|
* parameters, ingesting data sources for cases, and running items implementing
|
||||||
|
* IntegrationTests.
|
||||||
|
*/
|
||||||
|
public class MainTestRunner extends TestCase {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(MainTestRunner.class.getName()); // DO NOT USE AUTOPSY LOGGER
|
||||||
|
private static final String CONFIG_FILE_KEY = "CONFIG_FILE_KEY";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor required by JUnit
|
||||||
|
*/
|
||||||
|
public MainTestRunner(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates suite from particular test cases.
|
||||||
|
*/
|
||||||
|
public static Test suite() {
|
||||||
|
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(MainTestRunner.class).
|
||||||
|
clusters(".*").
|
||||||
|
enableModules(".*");
|
||||||
|
|
||||||
|
return NbModuleSuite.create(conf.addTest("runIntegrationTests"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void runIntegrationTests() {
|
||||||
|
// String configFile = System.getProperty(CONFIG_FILE_KEY);
|
||||||
|
// IntegrationTestConfig config = getFromConfigFile(configFile);
|
||||||
|
// // Set up NetBeans environment
|
||||||
|
// Case autopsyCase = runIngest(config);
|
||||||
|
// runConsumerIntegrationTests(config);
|
||||||
|
// Case.closeCurrentCase();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private Case runIngest(IntegrationTestConfig config) {
|
||||||
|
// Case openCase = CaseUtils.createAsCurrentCase(BITLOCKER_DETECTION_CASE_NAME);
|
||||||
|
// ImageDSProcessor dataSourceProcessor = new ImageDSProcessor();
|
||||||
|
// IngestUtils.addDataSource(dataSourceProcessor, BITLOCKER_DETECTION_IMAGE_PATH);
|
||||||
|
// IngestModuleFactory ingestModuleFactory = new EncryptionDetectionModuleFactory();
|
||||||
|
// IngestModuleIngestJobSettings settings = ingestModuleFactory.getDefaultIngestJobSettings();
|
||||||
|
// IngestModuleTemplate template = new IngestModuleTemplate(ingestModuleFactory, settings);
|
||||||
|
// template.setEnabled(true);
|
||||||
|
// List<IngestModuleTemplate> templates = new ArrayList<>();
|
||||||
|
// templates.add(template);
|
||||||
|
// IngestJobSettings ingestJobSettings = new IngestJobSettings(EncryptionDetectionTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates);
|
||||||
|
// IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings);
|
||||||
|
// return openCase;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void runIntegrationTests(IntegrationTestConfig config) {
|
||||||
|
// // this will capture output results
|
||||||
|
// OutputResults results = new OutputResults();
|
||||||
|
//
|
||||||
|
// // run through each ConsumerIntegrationTest
|
||||||
|
// for (IntegrationTests testGroup
|
||||||
|
// : Lookup.getAll(ConsumerIntegrationTests.class)) {
|
||||||
|
//
|
||||||
|
// // if test should not be included in results, skip it.
|
||||||
|
// if (!testParams.hasIncludedTest(testGroup.getClass())) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (Method testMethod : getAllTestMethods(testGroup)) {
|
||||||
|
//
|
||||||
|
// // run the test method and get the results
|
||||||
|
// Object serializableResult = null;
|
||||||
|
// try {
|
||||||
|
// Object serializableResult = testMethod.run();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// serializableResult = e;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // add the results and capture the package, class,
|
||||||
|
// // and method of the test for easy location of failed tests
|
||||||
|
// results.addResult(
|
||||||
|
// testGroup.getPackage(),
|
||||||
|
// testGroup.getSimpleName(),
|
||||||
|
// testMethod.getName(),
|
||||||
|
// serializableResult);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // write the results for the case to a file
|
||||||
|
// serializeFile(testParams.getOutputPath(),
|
||||||
|
// skCase.getName(),
|
||||||
|
// results);
|
||||||
|
// }
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration in IntegrationTests per case.
|
||||||
|
*/
|
||||||
|
public class CaseConfig {
|
||||||
|
private final String caseName;
|
||||||
|
private final List<String> dataSourceResources;
|
||||||
|
private final String ingestProfilePath;
|
||||||
|
private final String ingestModuleSettingsPath;
|
||||||
|
private final IntegrationCaseType caseTypes;
|
||||||
|
private final TestingConfig testConfig;
|
||||||
|
|
||||||
|
public CaseConfig(String caseName, List<String> dataSourceResources,
|
||||||
|
String ingestProfilePath, String ingestModuleSettingsPath,
|
||||||
|
IntegrationCaseType caseTypes, TestingConfig testConfig) {
|
||||||
|
this.caseName = caseName;
|
||||||
|
this.dataSourceResources = dataSourceResources;
|
||||||
|
this.ingestProfilePath = ingestProfilePath;
|
||||||
|
this.ingestModuleSettingsPath = ingestModuleSettingsPath;
|
||||||
|
this.caseTypes = caseTypes;
|
||||||
|
this.testConfig = testConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCaseName() {
|
||||||
|
return caseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDataSourceResources() {
|
||||||
|
return dataSourceResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIngestProfilePath() {
|
||||||
|
return ingestProfilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIngestModuleSettingsPath() {
|
||||||
|
return ingestModuleSettingsPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegrationCaseType getCaseTypes() {
|
||||||
|
return caseTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestingConfig getTestConfig() {
|
||||||
|
return testConfig;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The case types to create for this case.
|
||||||
|
*/
|
||||||
|
public enum IntegrationCaseType {
|
||||||
|
multiUser, singleUser, both
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for running Integration Tests including things like ingest
|
||||||
|
* parameters, datasource locations, cases to create, tests to run, etc.
|
||||||
|
*/
|
||||||
|
public class IntegrationTestConfig {
|
||||||
|
private final String rootCaseOutputPath;
|
||||||
|
private final String rootTestOutputPath;
|
||||||
|
private final CaseConfig cases;
|
||||||
|
|
||||||
|
public IntegrationTestConfig(String rootCaseOutputPath,
|
||||||
|
String rootTestOutputPath, CaseConfig cases) {
|
||||||
|
this.rootCaseOutputPath = rootCaseOutputPath;
|
||||||
|
this.rootTestOutputPath = rootTestOutputPath;
|
||||||
|
this.cases = cases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRootCaseOutputPath() {
|
||||||
|
return rootCaseOutputPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRootTestOutputPath() {
|
||||||
|
return rootTestOutputPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaseConfig getCases() {
|
||||||
|
return cases;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2020 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.integrationtesting.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for which integration test suites to run.
|
||||||
|
*/
|
||||||
|
public class TestingConfig {
|
||||||
|
private final List<String> excludeAllExcept;
|
||||||
|
private final List<String> includeAllExcept;
|
||||||
|
|
||||||
|
public TestingConfig(List<String> excludeAllExcept, List<String> includeAllExcept) {
|
||||||
|
this.excludeAllExcept = excludeAllExcept;
|
||||||
|
this.includeAllExcept = includeAllExcept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getExcludeAllExcept() {
|
||||||
|
return excludeAllExcept;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getIncludeAllExcept() {
|
||||||
|
return includeAllExcept;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2011-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.integrationtesting;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import org.netbeans.jemmy.Timeouts;
|
||||||
|
import org.netbeans.junit.NbModuleSuite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test expects the following system properties to be set: img_path: The
|
||||||
|
* fully qualified path to the image file (if split, the first file) out_path:
|
||||||
|
* The location where the case will be stored nsrl_path: Path to the nsrl
|
||||||
|
* database known_bad_path: Path to a database of known bad hashes keyword_path:
|
||||||
|
* Path to a keyword list xml file ignore_unalloc: Boolean whether to ignore
|
||||||
|
* unallocated space or not
|
||||||
|
*
|
||||||
|
* Without these properties set, the test will fail to run correctly. To run
|
||||||
|
* this test correctly, you should use the script 'regression.py' located in the
|
||||||
|
* 'script' directory of the Testing module.
|
||||||
|
*/
|
||||||
|
public class RegressionTest extends TestCase {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(RegressionTest.class.getName()); // DO NOT USE AUTOPSY LOGGER
|
||||||
|
private static final AutopsyTestCases autopsyTests = new AutopsyTestCases(Boolean.parseBoolean(System.getProperty("isMultiUser")));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor required by JUnit
|
||||||
|
*/
|
||||||
|
public RegressionTest(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates suite from particular test cases.
|
||||||
|
*/
|
||||||
|
public static Test suite() {
|
||||||
|
// run tests with specific configuration
|
||||||
|
File img_path = new File(AutopsyTestCases.getEscapedPath(System.getProperty("img_path")));
|
||||||
|
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(RegressionTest.class).
|
||||||
|
clusters(".*").
|
||||||
|
enableModules(".*");
|
||||||
|
if (img_path.isFile()) {
|
||||||
|
conf = conf.addTest("testNewCaseWizardOpen",
|
||||||
|
"testNewCaseWizard",
|
||||||
|
"testStartAddImageFileDataSource",
|
||||||
|
"testConfigureIngest1",
|
||||||
|
"testConfigureHash",
|
||||||
|
"testConfigureIngest2",
|
||||||
|
"testConfigureSearch",
|
||||||
|
"testAddSourceWizard1",
|
||||||
|
"testIngest",
|
||||||
|
"testExpandDataSourcesTree", //After do ingest, before generate report, we expand Data Sources node
|
||||||
|
"testGenerateReportToolbar",
|
||||||
|
"testGenerateReportButton");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img_path.isDirectory()) {
|
||||||
|
conf = conf.addTest("testNewCaseWizardOpen",
|
||||||
|
"testNewCaseWizard",
|
||||||
|
"testStartAddLogicalFilesDataSource",
|
||||||
|
"testConfigureIngest1",
|
||||||
|
"testConfigureHash",
|
||||||
|
"testConfigureIngest2",
|
||||||
|
"testConfigureSearch",
|
||||||
|
"testAddSourceWizard1",
|
||||||
|
"testIngest",
|
||||||
|
"testExpandDataSourcesTree",
|
||||||
|
"testGenerateReportToolbar",
|
||||||
|
"testGenerateReportButton");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NbModuleSuite.create(conf);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called before each test case.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setUp() {
|
||||||
|
logger.info("######## " + AutopsyTestCases.getEscapedPath(System.getProperty("img_path")) + " #######");
|
||||||
|
Timeouts.setDefault("ComponentOperator.WaitComponentTimeout", 1000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called after each test case.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void tearDown() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNewCaseWizardOpen() {
|
||||||
|
autopsyTests.testNewCaseWizardOpen("Welcome");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNewCaseWizard() {
|
||||||
|
autopsyTests.testNewCaseWizard();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartAddImageFileDataSource() {
|
||||||
|
autopsyTests.testStartAddImageFileDataSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartAddLogicalFilesDataSource() {
|
||||||
|
autopsyTests.testStartAddLogicalFilesDataSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAddSourceWizard1() {
|
||||||
|
autopsyTests.testAddSourceWizard1();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureIngest1() {
|
||||||
|
autopsyTests.testConfigureIngest1();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureHash() {
|
||||||
|
autopsyTests.testConfigureHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureIngest2() {
|
||||||
|
autopsyTests.testConfigureIngest2();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureSearch() {
|
||||||
|
autopsyTests.testConfigureSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIngest() {
|
||||||
|
autopsyTests.testIngest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testExpandDataSourcesTree() {
|
||||||
|
autopsyTests.testExpandDataSourcesTree();
|
||||||
|
}
|
||||||
|
public void testGenerateReportToolbar() {
|
||||||
|
autopsyTests.testGenerateReportToolbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGenerateReportButton() throws IOException {
|
||||||
|
autopsyTests.testGenerateReportButton();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user