Skip to content
Snippets Groups Projects
Commit 7a8a3e68 authored by Greg DiCristofaro's avatar Greg DiCristofaro
Browse files

now injects test properties into system properties

parent 92b87b73
Branches
Tags
No related merge requests found
Showing
with 94 additions and 70 deletions
......@@ -97,7 +97,7 @@
</copy>
<copy file="${thirdparty.dir}/jdom/jdom-2.0.5.jar" todir="${ext.dir}" />
<copy file="${thirdparty.dir}/jdom/jdom-2.0.5-contrib.jar" todir="${ext.dir}" />
<copy file="${thirdparty.dir}/DatCon/3.6.9/DatCon.jar" todir="${ext.dir}" />
<copy file="${thirdparty.dir}/DatCon/3.6.9/DatCon.jar" todir="${ext.dir}" />
</target>
......@@ -118,14 +118,14 @@
tofile="${ext.dir}/sleuthkit-${TSK_VERSION}.jar"/>
<copy file="${env.TSK_HOME}/bindings/java/lib/sqlite-jdbc-3.25.2.jar"
tofile="${ext.dir}/sqlite-jdbc-3.25.2.jar"/>
<copy file="${env.TSK_HOME}/bindings/java/lib/postgresql-9.4.1211.jre7.jar"
tofile="${ext.dir}/postgresql-9.4.1211.jre7.jar"/>
<copy file="${env.TSK_HOME}/bindings/java/lib/postgresql-9.4.1211.jre7.jar"
tofile="${ext.dir}/postgresql-9.4.1211.jre7.jar"/>
<copy file="${env.TSK_HOME}/bindings/java/lib/mchange-commons-java-0.2.9.jar"
tofile="${ext.dir}/mchange-commons-java-0.2.9.jar"/>
<copy file="${env.TSK_HOME}/bindings/java/lib/c3p0-0.9.5.jar"
tofile="${ext.dir}/c3p0-0.9.5.jar"/>
<copy file="${env.TSK_HOME}/bindings/java/lib/SparseBitSet-1.1.jar"
tofile="${ext.dir}/SparseBitSet-1.1.jar"/>
tofile="${ext.dir}/SparseBitSet-1.1.jar"/>
<copy file="${env.TSK_HOME}/case-uco/java/dist/sleuthkit-caseuco-${TSK_VERSION}.jar"
tofile="${ext.dir}/sleuthkit-caseuco-${TSK_VERSION}.jar"/>
</target>
......@@ -139,7 +139,7 @@
<target name="getTestDataFiles">
<mkdir dir="${basedir}/test/qa-functional/data"/>
<get src="https://drive.google.com/uc?id=1gyKzqJHtaBjFBqeB29N5vSpf1oH9N0bV" dest="${test-input}/EmbeddedIM_img1_v2.vhd" skipexisting="true"/>
<get src="https://drive.google.com/uc?id=1gyKzqJHtaBjFBqeB29N5vSpf1oH9N0bV" dest="${test-input}/EmbeddedIM_img1_v2.vhd" skipexisting="true"/>
<get src="https://drive.google.com/uc?id=1gvvV797dKczkwpWII4hIryBXCc0w5zL-" dest="${test-input}/BitlockerDetection_img1_v1.vhd" skipexisting="true"/>
<get src="https://drive.google.com/uc?id=1lYzd--9YUB7yDccM7NPOo8PC1xxuOiKs" dest="${test-input}/SqlCipherDetection_img1_v1.vhd" skipexisting="true"/>
<get src="https://drive.google.com/uc?id=1QRNKs824kksiJLZ4qcs59Nytw0fJKEjb" dest="${test-input}/IngestFilters_img1_v1.img" skipexisting="true"/>
......@@ -173,6 +173,17 @@
<target name="init" depends="get-deps,harness.init"/>
<target name="test-init" depends="projectized-common.test-init">
<!--create test property for integration config file location-->
<property name="test.qa-functional.properties.integrationConfigFile" value="${integrationConfigFile}"/>
<!--map that to the qa functional test properties-->
<propertyset id="test.qa-functional.properties">
<propertyref prefix="test.qa-functional.properties."/>
<mapper type="glob" from="test.qa-functional.properties.*" to="*"/>
</propertyset>
</target>
<target name="clean" depends="projectized-common.clean">
<!--Override clean to delete jars, etc downloaded with Ivy,
or copied in from thirdparty folder. This way we don't end up with
......@@ -207,9 +218,9 @@
</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 -->
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="regression-test-manifest-classpath">
<manifestclasspath property="tem.classpath" jarfile="allJarsInUse.jar" maxParentLevels="5">
<classpath refid="test.qa-functional.run.cp"/>
......
......@@ -20,7 +20,6 @@ file.reference.commons-codec-1.11.jar=release\\modules\\ext\\commons-codec-1.11.
file.reference.commons-collections-3.2.2.jar=release\\modules\\ext\\commons-collections-3.2.2.jar
file.reference.commons-dbcp2-2.1.1.jar=release\\modules\\ext\\commons-dbcp2-2.1.1.jar
file.reference.commons-digester-1.8.1.jar=release\\modules\\ext\\commons-digester-1.8.1.jar
file.reference.commons-lang-2.6.jar=release\\modules\\ext\\commons-lang-2.6.jar
file.reference.commons-logging-1.2.jar=release\\modules\\ext\\commons-logging-1.2.jar
file.reference.commons-pool2-2.4.2.jar=release\\modules\\ext\\commons-pool2-2.4.2.jar
file.reference.commons-validator-1.6.jar=release\\modules\\ext\\commons-validator-1.6.jar
......
......@@ -687,10 +687,6 @@
<runtime-relative-path>ext/jython-standalone-2.7.0.jar</runtime-relative-path>
<binary-origin>release\modules\ext\jython-standalone-2.7.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/commons-lang-2.6.jar</runtime-relative-path>
<binary-origin>release\modules\ext\commons-lang-2.6.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/jsr305-3.0.2.jar</runtime-relative-path>
<binary-origin>release\modules\ext\jsr305-3.0.2.jar</binary-origin>
......
......@@ -16,6 +16,7 @@
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -23,7 +24,7 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
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.sleuthkit.autopsy.integrationtesting.PathUtil;
......@@ -34,20 +35,9 @@
*/
public class ConfigDeserializer {
private static final String JSON_EXT = ".json";
private static final String JSON_EXT = "json";
private static final Logger logger = Logger.getLogger(ConfigDeserializer.class.getName());
private static final ObjectMapper mapper = getMapper();
private static ObjectMapper getMapper() {
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.addDeserializer(
ParameterizedResourceConfig.class,
new ParameterizedResourceConfig.ParameterizedResourceConfigDeserializer());
mapper.registerModule(module);
return mapper;
}
private static final ObjectMapper mapper = new ObjectMapper();
public <T> T convertToObj(Map<String, Object> toConvert, Type clazz) {
GsonBuilder builder = new GsonBuilder();
......@@ -108,8 +98,8 @@ public List<TestSuiteConfig> getTestSuiteConfig(File rootDirectory, File configF
}
public List<TestSuiteConfig> getTestSuiteConfigs(File rootDirectory) {
File[] jsonFiles = rootDirectory.listFiles((File dir, String name) -> name.endsWith(JSON_EXT));
return Stream.of(jsonFiles)
Collection<File> jsonFiles = FileUtils.listFiles(rootDirectory, new String[]{JSON_EXT}, true);
return jsonFiles.stream()
.flatMap((file) -> getTestSuiteConfig(rootDirectory, file).stream())
.collect(Collectors.toList());
}
......@@ -131,12 +121,12 @@ private TestSuiteConfig validate(File rootDirectory, File file, int index, TestS
logger.log(Level.WARNING, String.format("Item in %s at index %d must contain a valid 'name', 'caseTypes', 'dataSources', and 'integrationTests'", file.toString(), index));
return null;
}
if (config.getRelativeOutputPath() == null) {
// taken from https://stackoverflow.com/questions/204784/how-to-construct-a-relative-path-in-java-from-two-absolute-paths-or-urls
String relative = rootDirectory.toURI().relativize(file.toURI()).getPath();
if (relative.endsWith(JSON_EXT)) {
relative = relative.substring(0, relative.length() - JSON_EXT.length());
if (relative.endsWith("." + JSON_EXT)) {
relative = relative.substring(0, relative.length() - ("." + JSON_EXT).length());
}
config.setRelativeOutputPath(relative);
}
......
......@@ -18,6 +18,9 @@
*/
package org.sleuthkit.autopsy.integrationtesting.config;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author gregd
......@@ -28,7 +31,13 @@ public class ConnectionConfig {
private final String userName;
private final String password;
public ConnectionConfig(String hostName, Integer port, String userName, String password) {
@JsonCreator
public ConnectionConfig(
@JsonProperty("hostName") String hostName,
@JsonProperty("port") Integer port,
@JsonProperty("userName") String userName,
@JsonProperty("password") String password) {
this.hostName = hostName;
this.port = port;
this.userName = userName;
......
......@@ -18,6 +18,9 @@
*/
package org.sleuthkit.autopsy.integrationtesting.config;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author gregd
......@@ -27,16 +30,18 @@ public class EnvConfig {
private final String rootCaseOutputPath;
private final String rootTestOutputPath;
private final String rootTestSuitesPath;
private final ConnectionConfig connectionInfo;
private String workingDirectory;
public EnvConfig(String rootCaseOutputPath,
String rootTestSuitesPath,
String rootTestOutputPath,
ConnectionConfig connectionInfo) {
@JsonCreator
public EnvConfig(
@JsonProperty("rootCaseOutputPath") String rootCaseOutputPath,
@JsonProperty("rootTestSuitesPath") String rootTestSuitesPath,
@JsonProperty("rootTestOutputPath") String rootTestOutputPath,
@JsonProperty("connectionInfo") ConnectionConfig connectionInfo) {
this.rootCaseOutputPath = rootCaseOutputPath;
this.rootTestOutputPath = rootTestOutputPath;
this.rootTestSuitesPath = rootTestSuitesPath;
......
......@@ -18,6 +18,8 @@
*/
package org.sleuthkit.autopsy.integrationtesting.config;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
......@@ -26,15 +28,18 @@
*/
public class IntegrationTestConfig {
private final List<TestSuiteConfig> testSuites;
private final EnvConfig envConfig;
public IntegrationTestConfig(List<TestSuiteConfig> testSuites, EnvConfig envConfig) {
@JsonCreator
public IntegrationTestConfig(
@JsonProperty("testSuites") List<TestSuiteConfig> testSuites,
@JsonProperty("envConfig") EnvConfig envConfig) {
this.testSuites = testSuites;
this.envConfig = envConfig;
}
/**
* @return The per-case configuration.
*/
......
......@@ -20,21 +20,30 @@
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.TextNode;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.sleuthkit.autopsy.integrationtesting.config.ParameterizedResourceConfig.ParameterizedResourceConfigDeserializer;
/**
*
* @author gregd
*/
@JsonDeserialize(using = ParameterizedResourceConfigDeserializer.class)
public class ParameterizedResourceConfig {
public static class ParameterizedResourceConfigDeserializer extends StdDeserializer<ParameterizedResourceConfig> {
private static TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
};
public ParameterizedResourceConfigDeserializer() {
this(null);
}
......@@ -46,10 +55,18 @@ public ParameterizedResourceConfigDeserializer(Class<?> vc) {
@Override
public ParameterizedResourceConfig deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonNode node = jp.getCodec().readTree(jp);
if (node.isTextual()) {
return new ParameterizedResourceConfig(node.asText());
if (node == null) {
return null;
} else if (node instanceof TextNode) {
return new ParameterizedResourceConfig(((TextNode) node).textValue());
} else {
return ctxt.readValue(jp, ParameterizedResourceConfig.class);
String resource = (node.get("resource") != null) ? node.get("resource").asText() : null;
Map<String, Object> parameters = (node.get("parameters") != null) ?
node.get("parameters").traverse().readValueAs(Map.class) :
null;
return new ParameterizedResourceConfig(resource, parameters);
}
}
}
......
......@@ -18,12 +18,15 @@
*/
package org.sleuthkit.autopsy.integrationtesting.config;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* Configuration in IntegrationTests per case.
*/
public class TestSuiteConfig {
private final String name;
private final String description;
private final List<String> dataSources;
......@@ -32,7 +35,15 @@ public class TestSuiteConfig {
private final IntegrationCaseType caseTypes;
private String relativeOutputPath;
public TestSuiteConfig(String name, String description, List<String> dataSources, List<ParameterizedResourceConfig> configurationModules, TestingConfig integrationTests, IntegrationCaseType caseTypes) {
@JsonCreator
public TestSuiteConfig(
@JsonProperty("name") String name,
@JsonProperty("description") String description,
@JsonProperty("dataSources") List<String> dataSources,
@JsonProperty("configurationModules") List<ParameterizedResourceConfig> configurationModules,
@JsonProperty("integrationTests") TestingConfig integrationTests,
@JsonProperty("caseTypes") IntegrationCaseType caseTypes) {
this.name = name;
this.description = description;
this.dataSources = dataSources;
......@@ -72,6 +83,5 @@ public String getRelativeOutputPath() {
public void setRelativeOutputPath(String relativeOutputPath) {
this.relativeOutputPath = relativeOutputPath;
}
}
......@@ -18,6 +18,7 @@
*/
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.HashMap;
......@@ -37,11 +38,10 @@ public class TestingConfig {
private final Map<String, ParameterizedResourceConfig> excludeAllExcept;
private final Set<String> includeAllExcept;
@JsonCreator
public TestingConfig(
@JsonProperty("excludeAllExcept")
List<ParameterizedResourceConfig> excludeAllExcept,
@JsonProperty("includeAllExcept")
List<String> includeAllExcept) {
@JsonProperty("excludeAllExcept") List<ParameterizedResourceConfig> excludeAllExcept,
@JsonProperty("includeAllExcept") List<String> includeAllExcept) {
List<ParameterizedResourceConfig> safeExcludeAllExcept = ((excludeAllExcept == null) ? Collections.emptyList() : excludeAllExcept);
this.excludeAllExcept = safeExcludeAllExcept
......
......@@ -19,7 +19,6 @@
<!-- Autopsy -->
<dependency conf="autopsy->default" org="org.apache.solr" name="solr-solrj" rev="4.9.1"/>
<dependency conf="autopsy->default" org="commons-lang" name="commons-lang" rev="2.4"/>
<dependency conf="autopsy->default" org="commons-validator" name="commons-validator" rev="1.5.1"/>
<dependency conf="autopsy->default" org="com.optimaize.languagedetector" name="language-detector" rev="0.6"/>
......
......@@ -2,8 +2,6 @@ file.reference.annotations-12.0.jar=release\\modules\\ext\\annotations-12.0.jar
file.reference.commons-beanutils-1.9.2.jar=release\\modules\\ext\\commons-beanutils-1.9.2.jar
file.reference.commons-collections-3.2.2.jar=release\\modules\\ext\\commons-collections-3.2.2.jar
file.reference.commons-digester-1.8.1.jar=release\\modules\\ext\\commons-digester-1.8.1.jar
file.reference.commons-io-2.3.jar=release\\modules\\ext\\commons-io-2.3.jar
file.reference.commons-lang-2.4.jar=release\\modules\\ext\\commons-lang-2.4.jar
file.reference.commons-logging-1.2.jar=release\\modules\\ext\\commons-logging-1.2.jar
file.reference.commons-validator-1.5.1.jar=release\\modules\\ext\\commons-validator-1.5.1.jar
file.reference.guava-18.0.jar=release\\modules\\ext\\guava-18.0.jar
......
......@@ -262,10 +262,6 @@
<runtime-relative-path>ext/commons-validator-1.5.1.jar</runtime-relative-path>
<binary-origin>release\modules\ext\commons-validator-1.5.1.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/commons-lang-2.4.jar</runtime-relative-path>
<binary-origin>release\modules\ext\commons-lang-2.4.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/commons-logging-1.2.jar</runtime-relative-path>
<binary-origin>release\modules\ext\commons-logging-1.2.jar</binary-origin>
......@@ -286,10 +282,6 @@
<runtime-relative-path>ext/commons-beanutils-1.9.2.jar</runtime-relative-path>
<binary-origin>release\modules\ext\commons-beanutils-1.9.2.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/commons-io-2.3.jar</runtime-relative-path>
<binary-origin>release\modules\ext\commons-io-2.3.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/wstx-asl-3.2.7.jar</runtime-relative-path>
<binary-origin>release\modules\ext\wstx-asl-3.2.7.jar</binary-origin>
......
......@@ -14,7 +14,6 @@ file.reference.commons-codec-1.13.jar=release\\modules\\ext\\commons-codec-1.13.
file.reference.commons-compress-1.19.jar=release\\modules\\ext\\commons-compress-1.19.jar
file.reference.commons-csv-1.7.jar=release\\modules\\ext\\commons-csv-1.7.jar
file.reference.commons-exec-1.3.jar=release\\modules\\ext\\commons-exec-1.3.jar
file.reference.commons-io-2.6.jar=release\\modules\\ext\\commons-io-2.6.jar
file.reference.commons-math3-3.6.1.jar=release\\modules\\ext\\commons-math3-3.6.1.jar
file.reference.curvesapi-1.06.jar=release\\modules\\ext\\curvesapi-1.06.jar
file.reference.cxf-core-3.3.4.jar=release\\modules\\ext\\cxf-core-3.3.4.jar
......
......@@ -426,10 +426,6 @@
<runtime-relative-path>ext/bcmail-jdk15on-1.64.jar</runtime-relative-path>
<binary-origin>release\modules\ext\bcmail-jdk15on-1.64.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/commons-io-2.6.jar</runtime-relative-path>
<binary-origin>release\modules\ext\commons-io-2.6.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/cxf-rt-rs-client-3.3.4.jar</runtime-relative-path>
<binary-origin>release\modules\ext\cxf-rt-rs-client-3.3.4.jar</binary-origin>
......
......@@ -7,7 +7,6 @@
</configurations>
<dependencies>
<dependency conf="autopsy->default" org="org.apache.commons" name="commons-lang3" rev="3.8.1"/>
<dependency conf="autopsy->default" org="org.apache.james" name="apache-mime4j-core" rev="0.8.0"/>
<dependency conf="autopsy->default" org="org.apache.james" name="apache-mime4j-dom" rev="0.8.0"/>
<dependency conf="autopsy->default" org="org.apache.james" name="apache-mime4j-mbox-iterator" rev="0.8.0"/>
......
file.reference.apache-mime4j-core-0.8.0-SNAPSHOT.jar=release/modules/ext/apache-mime4j-core-0.8.0-SNAPSHOT.jar
file.reference.apache-mime4j-dom-0.8.0-SNAPSHOT.jar=release/modules/ext/apache-mime4j-dom-0.8.0-SNAPSHOT.jar
file.reference.apache-mime4j-mbox-iterator-0.8.0-SNAPSHOT.jar=release/modules/ext/apache-mime4j-mbox-iterator-0.8.0-SNAPSHOT.jar
file.reference.commons-lang3-3.8.1.jar=release/modules/ext/commons-lang3-3.8.1.jar
file.reference.apache-mime4j-core-0.8.0.jar=release/modules/ext/apache-mime4j-core-0.8.0-SNAPSHOT.jar
file.reference.apache-mime4j-dom-0.8.0.jar=release/modules/ext/apache-mime4j-dom-0.8.0-SNAPSHOT.jar
file.reference.apache-mime4j-mbox-iterator-0.8.0.jar=release/modules/ext/apache-mime4j-mbox-iterator-0.8.0-SNAPSHOT.jar
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment