mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
2102: refactor the regression tests
This commit is contained in:
parent
06e075b377
commit
dc12508768
@ -6,6 +6,41 @@
|
|||||||
<code-name-base>org.sleuthkit.autopsy.testing</code-name-base>
|
<code-name-base>org.sleuthkit.autopsy.testing</code-name-base>
|
||||||
<suite-component/>
|
<suite-component/>
|
||||||
<module-dependencies>
|
<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>
|
<dependency>
|
||||||
<code-name-base>org.sleuthkit.autopsy.core</code-name-base>
|
<code-name-base>org.sleuthkit.autopsy.core</code-name-base>
|
||||||
<build-prerequisite/>
|
<build-prerequisite/>
|
||||||
@ -63,7 +98,9 @@
|
|||||||
</test-dependency>
|
</test-dependency>
|
||||||
</test-type>
|
</test-type>
|
||||||
</test-dependencies>
|
</test-dependencies>
|
||||||
<public-packages/>
|
<public-packages>
|
||||||
|
<package>org.sleuthkit.autopsy.testing</package>
|
||||||
|
</public-packages>
|
||||||
</data>
|
</data>
|
||||||
</configuration>
|
</configuration>
|
||||||
</project>
|
</project>
|
||||||
|
290
Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java
Executable file
290
Testing/src/org/sleuthkit/autopsy/testing/AutopsyTestCases.java
Executable file
@ -0,0 +1,290 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.sleuthkit.autopsy.testing;
|
||||||
|
|
||||||
|
import java.awt.AWTException;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.text.JTextComponent;
|
||||||
|
import org.netbeans.jellytools.MainWindowOperator;
|
||||||
|
import org.netbeans.jellytools.NbDialogOperator;
|
||||||
|
import org.netbeans.jellytools.WizardOperator;
|
||||||
|
import org.netbeans.jemmy.Timeout;
|
||||||
|
import org.netbeans.jemmy.operators.JButtonOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JCheckBoxOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JComboBoxOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JDialogOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JFileChooserOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JLabelOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JListOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JTabbedPaneOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JTableOperator;
|
||||||
|
import org.netbeans.jemmy.operators.JTextFieldOperator;
|
||||||
|
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||||
|
|
||||||
|
public class AutopsyTestCases {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(AutopsyTestCases.class.getName());
|
||||||
|
private long start;
|
||||||
|
/**
|
||||||
|
* This method is used to escape file/directory path. Example:
|
||||||
|
* \\NetworkLocation\foo\bar get escaped to \\\\NetworkLocation\foo\bar so
|
||||||
|
* that it can be used as intended.
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
*
|
||||||
|
* @return escaped path the the file/directory location.
|
||||||
|
*/
|
||||||
|
public static String getEscapedPath(String path) {
|
||||||
|
if (path.startsWith("\\\\")) { //already has escaped to \\\\NetworkLocation
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
if (path.startsWith("\\")) {
|
||||||
|
return "\\" + path;
|
||||||
|
} else {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AutopsyTestCases () {
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNewCaseWizardOpen(String title) {
|
||||||
|
logger.info("New Case");
|
||||||
|
NbDialogOperator nbdo = new NbDialogOperator(title);
|
||||||
|
JButtonOperator jbo = new JButtonOperator(nbdo, 0); // the "New Case" button
|
||||||
|
jbo.pushNoBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNewCaseWizard() {
|
||||||
|
logger.info("New Case Wizard");
|
||||||
|
WizardOperator wo = new WizardOperator("New Case Information");
|
||||||
|
JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 1);
|
||||||
|
jtfo0.typeText("AutopsyTestCase"); // Name the case "AutopsyTestCase"
|
||||||
|
JTextFieldOperator jtfo1 = new JTextFieldOperator(wo, 2);
|
||||||
|
jtfo1.typeText(getEscapedPath(System.getProperty("out_path")));
|
||||||
|
wo.btNext().clickMouse();
|
||||||
|
JTextFieldOperator jtfo2 = new JTextFieldOperator(wo, 0);
|
||||||
|
jtfo2.typeText("000"); // Set the case number
|
||||||
|
JTextFieldOperator jtfo3 = new JTextFieldOperator(wo, 1);
|
||||||
|
jtfo3.typeText("Examiner 1"); // Set the case examiner
|
||||||
|
start = System.currentTimeMillis();
|
||||||
|
wo.btFinish().clickMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartAddImageFileDataSource() {
|
||||||
|
logger.info("Starting Add Image process");
|
||||||
|
WizardOperator wo = new WizardOperator("Add Data");
|
||||||
|
JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 0);
|
||||||
|
String img_path = getEscapedPath(System.getProperty("img_path"));
|
||||||
|
String imageDir = img_path;
|
||||||
|
((JTextComponent) jtfo0.getSource()).setText(imageDir);
|
||||||
|
JComboBoxOperator comboBoxOperator = new JComboBoxOperator(wo, 1);
|
||||||
|
comboBoxOperator.setSelectedItem("(GMT-5:00) America/New_York");
|
||||||
|
wo.btNext().clickMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testStartAddLogicalFilesDataSource() {
|
||||||
|
logger.info("Starting Add Logical Files process");
|
||||||
|
WizardOperator wo = new WizardOperator("Add Data");
|
||||||
|
JComboBoxOperator comboBoxOperator = new JComboBoxOperator(wo);
|
||||||
|
// select the item indexed 2 (Logical Files) from the drop-down list.
|
||||||
|
comboBoxOperator.selectItem(2);
|
||||||
|
JButtonOperator addButtonOperator = new JButtonOperator(wo, "Add");
|
||||||
|
addButtonOperator.pushNoBlock();
|
||||||
|
JFileChooserOperator fileChooserOperator = new JFileChooserOperator();
|
||||||
|
fileChooserOperator.setCurrentDirectory(new File(getEscapedPath(System.getProperty("img_path"))));
|
||||||
|
// set the current directory one level above the directory containing logicalFileSet folder.
|
||||||
|
fileChooserOperator.goUpLevel();
|
||||||
|
fileChooserOperator.chooseFile(new File(getEscapedPath(System.getProperty("img_path"))).getName());
|
||||||
|
wo.btNext().clickMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAddSourceWizard1() {
|
||||||
|
WizardOperator wo = new WizardOperator("Add Data");
|
||||||
|
while (!wo.btFinish().isEnabled()) {
|
||||||
|
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
||||||
|
}
|
||||||
|
logger.log(Level.INFO, "Add image took {0}ms", (System.currentTimeMillis() - start));
|
||||||
|
wo.btFinish().clickMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureIngest1() {
|
||||||
|
/*
|
||||||
|
* This timeout is to allow the setup for the ingest job settings panel
|
||||||
|
* to complete.
|
||||||
|
*/
|
||||||
|
new Timeout("pausing", 10000).sleep();
|
||||||
|
|
||||||
|
logger.info("Looking for hash lookup module in ingest job settings panel");
|
||||||
|
WizardOperator wo = new WizardOperator("Add Data");
|
||||||
|
JTableOperator jto = new JTableOperator(wo, 0);
|
||||||
|
int row = jto.findCellRow("Hash Lookup", 2, 0);
|
||||||
|
jto.clickOnCell(row, 1);
|
||||||
|
logger.info("Selected hash lookup module in ingest job settings panel");
|
||||||
|
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
|
||||||
|
jbo1.pushNoBlock();
|
||||||
|
logger.info("Pushed Global Settings button for hash lookup module in ingest job settings panel");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureHash() {
|
||||||
|
logger.info("Hash Configure");
|
||||||
|
JDialog hashMainDialog = JDialogOperator.waitJDialog("Global Hash Lookup Settings", false, false);
|
||||||
|
JDialogOperator hashMainDialogOperator = new JDialogOperator(hashMainDialog);
|
||||||
|
List<String> databases = new ArrayList<>();
|
||||||
|
databases.add(getEscapedPath(System.getProperty("nsrl_path")));
|
||||||
|
databases.add(getEscapedPath(System.getProperty("known_bad_path")));
|
||||||
|
databases.stream().map((database) -> {
|
||||||
|
JButtonOperator importButtonOperator = new JButtonOperator(hashMainDialogOperator, "Import");
|
||||||
|
importButtonOperator.pushNoBlock();
|
||||||
|
JDialog addDatabaseDialog = JDialogOperator.waitJDialog("Import Hash Database", false, false);
|
||||||
|
JDialogOperator addDatabaseDialogOperator = new JDialogOperator(addDatabaseDialog);
|
||||||
|
JButtonOperator browseButtonOperator = new JButtonOperator(addDatabaseDialogOperator, "Open...", 0);
|
||||||
|
browseButtonOperator.pushNoBlock();
|
||||||
|
JFileChooserOperator fileChooserOperator = new JFileChooserOperator();
|
||||||
|
fileChooserOperator.chooseFile(database);
|
||||||
|
JButtonOperator okButtonOperator = new JButtonOperator(addDatabaseDialogOperator, "OK", 0);
|
||||||
|
return okButtonOperator;
|
||||||
|
}).map((okButtonOperator) -> {
|
||||||
|
okButtonOperator.pushNoBlock();
|
||||||
|
return okButtonOperator;
|
||||||
|
}).forEach((_item) -> {
|
||||||
|
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
||||||
|
});
|
||||||
|
// Used if the database has no index
|
||||||
|
//JDialog jd3 = JDialogOperator.waitJDialog("No Index Exists", false, false);
|
||||||
|
//JDialogOperator jdo3 = new JDialogOperator(jd3);
|
||||||
|
//JButtonOperator jbo3 = new JButtonOperator(jdo3, "Yes", 0);
|
||||||
|
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
||||||
|
//jbo3.pushNoBlock();
|
||||||
|
JButtonOperator jbo4 = new JButtonOperator(hashMainDialogOperator, "OK", 0);
|
||||||
|
jbo4.pushNoBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureIngest2() {
|
||||||
|
logger.info("Looking for keyword search module in ingest job settings panel");
|
||||||
|
WizardOperator wo = new WizardOperator("Add Data");
|
||||||
|
JTableOperator jto = new JTableOperator(wo, 0);
|
||||||
|
int row = jto.findCellRow("Keyword Search", 2, 0);
|
||||||
|
jto.clickOnCell(row, 1);
|
||||||
|
logger.info("Selected keyword search module in ingest job settings panel");
|
||||||
|
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
|
||||||
|
jbo1.pushNoBlock();
|
||||||
|
logger.info("Pushed Global Settings button for keyword search module in ingest job settings panel");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testConfigureSearch() {
|
||||||
|
logger.info("Search Configure");
|
||||||
|
JDialog jd = JDialogOperator.waitJDialog("Global Keyword Search Settings", false, false);
|
||||||
|
JDialogOperator jdo = new JDialogOperator(jd);
|
||||||
|
String words = getEscapedPath(System.getProperty("keyword_path"));
|
||||||
|
JButtonOperator jbo0 = new JButtonOperator(jdo, "Import List", 0);
|
||||||
|
jbo0.pushNoBlock();
|
||||||
|
JFileChooserOperator jfco0 = new JFileChooserOperator();
|
||||||
|
jfco0.chooseFile(words);
|
||||||
|
JTableOperator jto = new JTableOperator(jdo, 0);
|
||||||
|
jto.clickOnCell(0, 0);
|
||||||
|
new Timeout("pausing", 1000).sleep(); // give it a second to process
|
||||||
|
if (Boolean.parseBoolean(System.getProperty("mugen_mode"))) {
|
||||||
|
JTabbedPaneOperator jtpo = new JTabbedPaneOperator(jdo);
|
||||||
|
jtpo.selectPage("String Extraction");
|
||||||
|
JCheckBoxOperator jcbo0 = new JCheckBoxOperator(jtpo, "Arabic (Arabic)");
|
||||||
|
jcbo0.doClick();
|
||||||
|
JCheckBoxOperator jcbo1 = new JCheckBoxOperator(jtpo, "Han (Chinese, Japanese, Korean)");
|
||||||
|
jcbo1.doClick();
|
||||||
|
new Timeout("pausing", 1000).sleep(); // give it a second to process
|
||||||
|
}
|
||||||
|
JButtonOperator jbo2 = new JButtonOperator(jdo, "OK", 0);
|
||||||
|
jbo2.pushNoBlock();
|
||||||
|
WizardOperator wo = new WizardOperator("Add Data");
|
||||||
|
new Timeout("pausing", 10000).sleep(); // let things catch up
|
||||||
|
wo.btNext().clickMouse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIngest() {
|
||||||
|
logger.info("Ingest 3");
|
||||||
|
new Timeout("pausing", 10000).sleep(); // wait for ingest to actually start
|
||||||
|
long startIngest = System.currentTimeMillis();
|
||||||
|
IngestManager man = IngestManager.getInstance();
|
||||||
|
while (man.isIngestRunning()) {
|
||||||
|
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
||||||
|
}
|
||||||
|
logger.log(Level.INFO, "Ingest (including enqueue) took {0}ms", (System.currentTimeMillis() - startIngest));
|
||||||
|
// allow keyword search to finish saving artifacts, just in case
|
||||||
|
// but randomize the timing so that we don't always get the same error
|
||||||
|
// consistently, making it seem like default behavior
|
||||||
|
Random rand = new Random();
|
||||||
|
new Timeout("pausing", 10000 + (rand.nextInt(15000) + 5000)).sleep();
|
||||||
|
screenshot("Finished Ingest");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGenerateReportToolbar() {
|
||||||
|
logger.info("Generate Report Toolbars");
|
||||||
|
MainWindowOperator mwo = MainWindowOperator.getDefault();
|
||||||
|
JButtonOperator jbo = new JButtonOperator(mwo, "Generate Report");
|
||||||
|
jbo.pushNoBlock();
|
||||||
|
new Timeout("pausing", 5000).sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGenerateReportButton() throws IOException {
|
||||||
|
logger.info("Generate Report Button");
|
||||||
|
JDialog reportDialog = JDialogOperator.waitJDialog("Generate Report", false, false);
|
||||||
|
JDialogOperator reportDialogOperator = new JDialogOperator(reportDialog);
|
||||||
|
JListOperator listOperator = new JListOperator(reportDialogOperator);
|
||||||
|
JButtonOperator jbo0 = new JButtonOperator(reportDialogOperator, "Next");
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
|
||||||
|
Date date = new Date();
|
||||||
|
String datenotime = dateFormat.format(date);
|
||||||
|
listOperator.clickOnItem(0, 1);
|
||||||
|
new Timeout("pausing", 1000).sleep();
|
||||||
|
jbo0.pushNoBlock();
|
||||||
|
new Timeout("pausing", 1000).sleep();
|
||||||
|
JButtonOperator jbo1 = new JButtonOperator(reportDialogOperator, "Finish");
|
||||||
|
jbo1.pushNoBlock();
|
||||||
|
new Timeout("pausing", 500).sleep();
|
||||||
|
JDialog previewDialog = JDialogOperator.waitJDialog("Progress", false, false);
|
||||||
|
screenshot("Progress");
|
||||||
|
JDialogOperator previewDialogOperator = new JDialogOperator(previewDialog);
|
||||||
|
JLabelOperator.waitJLabel(previewDialog, "Complete", false, false);
|
||||||
|
JButtonOperator jbo2 = new JButtonOperator(previewDialogOperator, "Close");
|
||||||
|
jbo2.pushNoBlock();
|
||||||
|
new Timeout("pausing", 10000).sleep();
|
||||||
|
System.setProperty("ReportStr", datenotime);
|
||||||
|
screenshot("Done Testing");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void screenshot(String name) {
|
||||||
|
logger.info("Taking screenshot.");
|
||||||
|
try {
|
||||||
|
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
|
||||||
|
BufferedImage capture = new Robot().createScreenCapture(screenRect);
|
||||||
|
String outPath = getEscapedPath(System.getProperty("out_path"));
|
||||||
|
ImageIO.write(capture, "png", new File(outPath + "\\" + name + ".png"));
|
||||||
|
new Timeout("pausing", 1000).sleep(); // give it a second to save
|
||||||
|
} catch (IOException ex) {
|
||||||
|
logger.log(Level.WARNING, "IOException taking screenshot.", ex);
|
||||||
|
} catch (AWTException ex) {
|
||||||
|
logger.log(Level.WARNING, "AWTException taking screenshot.", ex);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,43 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.testing;
|
package org.sleuthkit.autopsy.testing;
|
||||||
|
|
||||||
import java.awt.AWTException;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.Robot;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.netbeans.jellytools.MainWindowOperator;
|
|
||||||
import org.netbeans.jellytools.NbDialogOperator;
|
|
||||||
import org.netbeans.jellytools.WizardOperator;
|
|
||||||
import org.netbeans.jemmy.Timeout;
|
|
||||||
import org.netbeans.jemmy.Timeouts;
|
import org.netbeans.jemmy.Timeouts;
|
||||||
import org.netbeans.jemmy.operators.JButtonOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JCheckBoxOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JComboBoxOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JDialogOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JFileChooserOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JLabelOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JListOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JTabbedPaneOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JTableOperator;
|
|
||||||
import org.netbeans.jemmy.operators.JTextFieldOperator;
|
|
||||||
import org.netbeans.junit.NbModuleSuite;
|
import org.netbeans.junit.NbModuleSuite;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test expects the following system properties to be set: img_path: The
|
* This test expects the following system properties to be set: img_path: The
|
||||||
@ -71,7 +41,7 @@ import org.sleuthkit.autopsy.ingest.IngestManager;
|
|||||||
public class RegressionTest extends TestCase {
|
public class RegressionTest extends TestCase {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(RegressionTest.class.getName());
|
private static final Logger logger = Logger.getLogger(RegressionTest.class.getName());
|
||||||
long start;
|
private static final AutopsyTestCases autopsyTests = new AutopsyTestCases();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor required by JUnit
|
* Constructor required by JUnit
|
||||||
@ -80,32 +50,12 @@ public class RegressionTest extends TestCase {
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is used to escape file/directory path. Example:
|
|
||||||
* \\NetworkLocation\foo\bar get escaped to \\\\NetworkLocation\foo\bar so
|
|
||||||
* that it can be used as intended.
|
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
*
|
|
||||||
* @return escaped path the the file/directory location.
|
|
||||||
*/
|
|
||||||
private static String getEscapedPath(String path) {
|
|
||||||
if (path.startsWith("\\\\")) { //already has escaped to \\\\NetworkLocation
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
else if (path.startsWith("\\")) {
|
|
||||||
return "\\" + path;
|
|
||||||
} else {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates suite from particular test cases.
|
* Creates suite from particular test cases.
|
||||||
*/
|
*/
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
// run tests with specific configuration
|
// run tests with specific configuration
|
||||||
File img_path = new File(getEscapedPath(System.getProperty("img_path")));
|
File img_path = new File(AutopsyTestCases.getEscapedPath(System.getProperty("img_path")));
|
||||||
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(RegressionTest.class).
|
NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(RegressionTest.class).
|
||||||
clusters(".*").
|
clusters(".*").
|
||||||
enableModules(".*");
|
enableModules(".*");
|
||||||
@ -146,8 +96,7 @@ public class RegressionTest extends TestCase {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
logger.info("######## " + AutopsyTestCases.getEscapedPath(System.getProperty("img_path")) + " #######");
|
||||||
logger.info("######## " + getEscapedPath(System.getProperty("img_path")) + " #######");
|
|
||||||
Timeouts.setDefault("ComponentOperator.WaitComponentTimeout", 1000000);
|
Timeouts.setDefault("ComponentOperator.WaitComponentTimeout", 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,219 +108,50 @@ public class RegressionTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testNewCaseWizardOpen() {
|
public void testNewCaseWizardOpen() {
|
||||||
logger.info("New Case");
|
autopsyTests.testNewCaseWizardOpen("Welcome");
|
||||||
NbDialogOperator nbdo = new NbDialogOperator("Welcome");
|
|
||||||
JButtonOperator jbo = new JButtonOperator(nbdo, 0); // the "New Case" button
|
|
||||||
jbo.pushNoBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNewCaseWizard() {
|
public void testNewCaseWizard() {
|
||||||
logger.info("New Case Wizard");
|
autopsyTests.testNewCaseWizard();
|
||||||
WizardOperator wo = new WizardOperator("New Case Information");
|
|
||||||
JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 1);
|
|
||||||
jtfo0.typeText("AutopsyTestCase"); // Name the case "AutopsyTestCase"
|
|
||||||
JTextFieldOperator jtfo1 = new JTextFieldOperator(wo, 2);
|
|
||||||
jtfo1.typeText(getEscapedPath(System.getProperty("out_path")));
|
|
||||||
wo.btNext().clickMouse();
|
|
||||||
JTextFieldOperator jtfo2 = new JTextFieldOperator(wo, 0);
|
|
||||||
jtfo2.typeText("000"); // Set the case number
|
|
||||||
JTextFieldOperator jtfo3 = new JTextFieldOperator(wo, 1);
|
|
||||||
jtfo3.typeText("Examiner 1"); // Set the case examiner
|
|
||||||
start = System.currentTimeMillis();
|
|
||||||
wo.btFinish().clickMouse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStartAddImageFileDataSource() {
|
public void testStartAddImageFileDataSource() {
|
||||||
logger.info("Starting Add Image process");
|
autopsyTests.testStartAddImageFileDataSource();
|
||||||
WizardOperator wo = new WizardOperator("Add Data");
|
|
||||||
JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 0);
|
|
||||||
String img_path = getEscapedPath(System.getProperty("img_path"));
|
|
||||||
String imageDir = img_path;
|
|
||||||
((JTextField) jtfo0.getSource()).setText(imageDir);
|
|
||||||
JComboBoxOperator comboBoxOperator = new JComboBoxOperator(wo, 1);
|
|
||||||
comboBoxOperator.setSelectedItem("(GMT-5:00) America/New_York");
|
|
||||||
wo.btNext().clickMouse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStartAddLogicalFilesDataSource() {
|
public void testStartAddLogicalFilesDataSource() {
|
||||||
logger.info("Starting Add Logical Files process");
|
autopsyTests.testStartAddLogicalFilesDataSource();
|
||||||
WizardOperator wo = new WizardOperator("Add Data");
|
|
||||||
JComboBoxOperator comboBoxOperator = new JComboBoxOperator(wo);
|
|
||||||
// select the item indexed 2 (Logical Files) from the drop-down list.
|
|
||||||
comboBoxOperator.selectItem(2);
|
|
||||||
JButtonOperator addButtonOperator = new JButtonOperator(wo, "Add");
|
|
||||||
addButtonOperator.pushNoBlock();
|
|
||||||
JFileChooserOperator fileChooserOperator = new JFileChooserOperator();
|
|
||||||
fileChooserOperator.setCurrentDirectory(new File(getEscapedPath(System.getProperty("img_path"))));
|
|
||||||
// set the current directory one level above the directory containing logicalFileSet folder.
|
|
||||||
fileChooserOperator.goUpLevel();
|
|
||||||
fileChooserOperator.chooseFile(new File(getEscapedPath(System.getProperty("img_path"))).getName());
|
|
||||||
wo.btNext().clickMouse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddSourceWizard1() {
|
public void testAddSourceWizard1() {
|
||||||
WizardOperator wo = new WizardOperator("Add Data");
|
autopsyTests.testAddSourceWizard1();
|
||||||
while (!wo.btFinish().isEnabled()) {
|
|
||||||
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
|
||||||
}
|
|
||||||
logger.info("Add image took " + (System.currentTimeMillis() - start) + "ms");
|
|
||||||
wo.btFinish().clickMouse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConfigureIngest1() {
|
public void testConfigureIngest1() {
|
||||||
/*
|
autopsyTests.testConfigureIngest1();
|
||||||
* This timeout is to allow the setup for the ingest job settings panel
|
|
||||||
* to complete.
|
|
||||||
*/
|
|
||||||
new Timeout("pausing", 10000).sleep();
|
|
||||||
|
|
||||||
logger.info("Looking for hash lookup module in ingest job settings panel");
|
|
||||||
WizardOperator wo = new WizardOperator("Add Data");
|
|
||||||
JTableOperator jto = new JTableOperator(wo, 0);
|
|
||||||
int row = jto.findCellRow("Hash Lookup", 2, 0);
|
|
||||||
jto.clickOnCell(row, 1);
|
|
||||||
logger.info("Selected hash lookup module in ingest job settings panel");
|
|
||||||
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
|
|
||||||
jbo1.pushNoBlock();
|
|
||||||
logger.info("Pushed Global Settings button for hash lookup module in ingest job settings panel");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConfigureHash() {
|
public void testConfigureHash() {
|
||||||
logger.info("Hash Configure");
|
autopsyTests.testConfigureHash();
|
||||||
JDialog hashMainDialog = JDialogOperator.waitJDialog("Global Hash Lookup Settings", false, false);
|
|
||||||
JDialogOperator hashMainDialogOperator = new JDialogOperator(hashMainDialog);
|
|
||||||
List<String> databases = new ArrayList<String>();
|
|
||||||
databases.add(getEscapedPath(System.getProperty("nsrl_path")));
|
|
||||||
databases.add(getEscapedPath(System.getProperty("known_bad_path")));
|
|
||||||
for (String database : databases) {
|
|
||||||
JButtonOperator importButtonOperator = new JButtonOperator(hashMainDialogOperator, "Import");
|
|
||||||
importButtonOperator.pushNoBlock();
|
|
||||||
JDialog addDatabaseDialog = JDialogOperator.waitJDialog("Import Hash Database", false, false);
|
|
||||||
JDialogOperator addDatabaseDialogOperator = new JDialogOperator(addDatabaseDialog);
|
|
||||||
JButtonOperator browseButtonOperator = new JButtonOperator(addDatabaseDialogOperator, "Open...", 0);
|
|
||||||
browseButtonOperator.pushNoBlock();
|
|
||||||
JFileChooserOperator fileChooserOperator = new JFileChooserOperator();
|
|
||||||
fileChooserOperator.chooseFile(database);
|
|
||||||
JButtonOperator okButtonOperator = new JButtonOperator(addDatabaseDialogOperator, "OK", 0);
|
|
||||||
okButtonOperator.pushNoBlock();
|
|
||||||
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
|
||||||
}
|
|
||||||
// Used if the database has no index
|
|
||||||
//JDialog jd3 = JDialogOperator.waitJDialog("No Index Exists", false, false);
|
|
||||||
//JDialogOperator jdo3 = new JDialogOperator(jd3);
|
|
||||||
//JButtonOperator jbo3 = new JButtonOperator(jdo3, "Yes", 0);
|
|
||||||
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
|
||||||
//jbo3.pushNoBlock();
|
|
||||||
JButtonOperator jbo4 = new JButtonOperator(hashMainDialogOperator, "OK", 0);
|
|
||||||
jbo4.pushNoBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConfigureIngest2() {
|
public void testConfigureIngest2() {
|
||||||
logger.info("Looking for keyword search module in ingest job settings panel");
|
autopsyTests.testConfigureIngest2();
|
||||||
WizardOperator wo = new WizardOperator("Add Data");
|
|
||||||
JTableOperator jto = new JTableOperator(wo, 0);
|
|
||||||
int row = jto.findCellRow("Keyword Search", 2, 0);
|
|
||||||
jto.clickOnCell(row, 1);
|
|
||||||
logger.info("Selected keyword search module in ingest job settings panel");
|
|
||||||
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
|
|
||||||
jbo1.pushNoBlock();
|
|
||||||
logger.info("Pushed Global Settings button for keyword search module in ingest job settings panel");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConfigureSearch() {
|
public void testConfigureSearch() {
|
||||||
logger.info("Search Configure");
|
autopsyTests.testConfigureSearch();
|
||||||
JDialog jd = JDialogOperator.waitJDialog("Global Keyword Search Settings", false, false);
|
|
||||||
JDialogOperator jdo = new JDialogOperator(jd);
|
|
||||||
String words = getEscapedPath(System.getProperty("keyword_path"));
|
|
||||||
JButtonOperator jbo0 = new JButtonOperator(jdo, "Import List", 0);
|
|
||||||
jbo0.pushNoBlock();
|
|
||||||
JFileChooserOperator jfco0 = new JFileChooserOperator();
|
|
||||||
jfco0.chooseFile(words);
|
|
||||||
JTableOperator jto = new JTableOperator(jdo, 0);
|
|
||||||
jto.clickOnCell(0, 0);
|
|
||||||
new Timeout("pausing", 1000).sleep(); // give it a second to process
|
|
||||||
if (Boolean.parseBoolean(System.getProperty("mugen_mode"))) {
|
|
||||||
JTabbedPaneOperator jtpo = new JTabbedPaneOperator(jdo);
|
|
||||||
jtpo.selectPage("String Extraction");
|
|
||||||
JCheckBoxOperator jcbo0 = new JCheckBoxOperator(jtpo, "Arabic (Arabic)");
|
|
||||||
jcbo0.doClick();
|
|
||||||
JCheckBoxOperator jcbo1 = new JCheckBoxOperator(jtpo, "Han (Chinese, Japanese, Korean)");
|
|
||||||
jcbo1.doClick();
|
|
||||||
new Timeout("pausing", 1000).sleep(); // give it a second to process
|
|
||||||
}
|
|
||||||
JButtonOperator jbo2 = new JButtonOperator(jdo, "OK", 0);
|
|
||||||
jbo2.pushNoBlock();
|
|
||||||
WizardOperator wo = new WizardOperator("Add Data");
|
|
||||||
new Timeout("pausing", 10000).sleep(); // let things catch up
|
|
||||||
wo.btNext().clickMouse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIngest() {
|
public void testIngest() {
|
||||||
logger.info("Ingest 3");
|
autopsyTests.testIngest();
|
||||||
new Timeout("pausing", 10000).sleep(); // wait for ingest to actually start
|
|
||||||
long startIngest = System.currentTimeMillis();
|
|
||||||
IngestManager man = IngestManager.getInstance();
|
|
||||||
while (man.isIngestRunning()) {
|
|
||||||
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
|
|
||||||
}
|
|
||||||
logger.log(Level.INFO, "Ingest (including enqueue) took {0}ms", (System.currentTimeMillis() - startIngest));
|
|
||||||
// allow keyword search to finish saving artifacts, just in case
|
|
||||||
// but randomize the timing so that we don't always get the same error
|
|
||||||
// consistently, making it seem like default behavior
|
|
||||||
Random rand = new Random();
|
|
||||||
new Timeout("pausing", 10000 + (rand.nextInt(15000) + 5000)).sleep();
|
|
||||||
screenshot("Finished Ingest");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGenerateReportToolbar() {
|
public void testGenerateReportToolbar() {
|
||||||
logger.info("Generate Report Toolbars");
|
autopsyTests.testGenerateReportToolbar();
|
||||||
MainWindowOperator mwo = MainWindowOperator.getDefault();
|
|
||||||
JButtonOperator jbo = new JButtonOperator(mwo, "Generate Report");
|
|
||||||
jbo.pushNoBlock();
|
|
||||||
new Timeout("pausing", 5000).sleep();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGenerateReportButton() throws IOException {
|
public void testGenerateReportButton() throws IOException {
|
||||||
logger.info("Generate Report Button");
|
autopsyTests.testGenerateReportButton();
|
||||||
JDialog reportDialog = JDialogOperator.waitJDialog("Generate Report", false, false);
|
|
||||||
JDialogOperator reportDialogOperator = new JDialogOperator(reportDialog);
|
|
||||||
JListOperator listOperator = new JListOperator(reportDialogOperator);
|
|
||||||
JButtonOperator jbo0 = new JButtonOperator(reportDialogOperator, "Next");
|
|
||||||
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
|
|
||||||
Date date = new Date();
|
|
||||||
String datenotime = dateFormat.format(date);
|
|
||||||
listOperator.clickOnItem(0, 1);
|
|
||||||
new Timeout("pausing", 1000).sleep();
|
|
||||||
jbo0.pushNoBlock();
|
|
||||||
new Timeout("pausing", 1000).sleep();
|
|
||||||
JButtonOperator jbo1 = new JButtonOperator(reportDialogOperator, "Finish");
|
|
||||||
jbo1.pushNoBlock();
|
|
||||||
new Timeout("pausing", 500).sleep();
|
|
||||||
JDialog previewDialog = JDialogOperator.waitJDialog("Progress", false, false);
|
|
||||||
screenshot("Progress");
|
|
||||||
JDialogOperator previewDialogOperator = new JDialogOperator(previewDialog);
|
|
||||||
JLabelOperator.waitJLabel(previewDialog, "Complete", false, false);
|
|
||||||
JButtonOperator jbo2 = new JButtonOperator(previewDialogOperator, "Close");
|
|
||||||
jbo2.pushNoBlock();
|
|
||||||
new Timeout("pausing", 10000).sleep();
|
|
||||||
System.setProperty("ReportStr", datenotime);
|
|
||||||
screenshot("Done Testing");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void screenshot(String name) {
|
|
||||||
logger.info("Taking screenshot.");
|
|
||||||
try {
|
|
||||||
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
|
|
||||||
BufferedImage capture = new Robot().createScreenCapture(screenRect);
|
|
||||||
String outPath = getEscapedPath(System.getProperty("out_path"));
|
|
||||||
ImageIO.write(capture, "png", new File(outPath + "\\" + name + ".png"));
|
|
||||||
new Timeout("pausing", 1000).sleep(); // give it a second to save
|
|
||||||
} catch (IOException ex) {
|
|
||||||
logger.log(Level.WARNING, "IOException taking screenshot.", ex);
|
|
||||||
} catch (AWTException ex) {
|
|
||||||
logger.log(Level.WARNING, "AWTException taking screenshot.", ex);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ class TestRunner(object):
|
|||||||
test_data.ant = ["ant"]
|
test_data.ant = ["ant"]
|
||||||
test_data.ant.append("-v")
|
test_data.ant.append("-v")
|
||||||
test_data.ant.append("-f")
|
test_data.ant.append("-f")
|
||||||
test_data.ant.append(make_local_path(test_data.main_config.build_path))
|
test_data.ant.append(make_local_path(test_data.main_config.build_path, "build.xml"))
|
||||||
test_data.ant.append("regression-test")
|
test_data.ant.append("regression-test")
|
||||||
test_data.ant.append("-l")
|
test_data.ant.append("-l")
|
||||||
test_data.ant.append(test_data.antlog_dir)
|
test_data.ant.append(test_data.antlog_dir)
|
||||||
@ -1485,7 +1485,7 @@ def copy_logs(test_data):
|
|||||||
shutil.copytree(log_dir, test_data.logs_dir)
|
shutil.copytree(log_dir, test_data.logs_dir)
|
||||||
|
|
||||||
# copy logs from userdir0/var/log
|
# copy logs from userdir0/var/log
|
||||||
log_dir = os.path.join("..", "..", "Testing","build","test","qa-functional","work","userdir0","var","log/")
|
log_dir = os.path.join(test_data.main_config.build_path,"build","test","qa-functional","work","userdir0","var","log/")
|
||||||
for log in os.listdir(log_dir):
|
for log in os.listdir(log_dir):
|
||||||
if log.find("log"):
|
if log.find("log"):
|
||||||
new_name = log_dir + "userdir0." + log
|
new_name = log_dir + "userdir0." + log
|
||||||
|
Loading…
x
Reference in New Issue
Block a user