19 package org.sleuthkit.autopsy.testing;
21 import java.awt.AWTException;
22 import java.awt.Rectangle;
23 import java.awt.Robot;
24 import java.awt.Toolkit;
25 import java.awt.image.BufferedImage;
27 import java.io.IOException;
28 import java.text.DateFormat;
29 import java.text.SimpleDateFormat;
30 import java.util.ArrayList;
31 import java.util.Date;
32 import java.util.List;
33 import java.util.Random;
34 import java.util.logging.Logger;
35 import java.util.logging.Level;
36 import javax.imageio.ImageIO;
37 import javax.swing.JDialog;
38 import javax.swing.text.JTextComponent;
39 import javax.swing.tree.TreePath;
40 import org.netbeans.jellytools.MainWindowOperator;
41 import org.netbeans.jellytools.NbDialogOperator;
42 import org.netbeans.jellytools.WizardOperator;
43 import org.netbeans.jemmy.JemmyProperties;
44 import org.netbeans.jemmy.Timeout;
45 import org.netbeans.jemmy.TimeoutExpiredException;
46 import org.netbeans.jemmy.Timeouts;
47 import org.netbeans.jemmy.operators.JButtonOperator;
48 import org.netbeans.jemmy.operators.JCheckBoxOperator;
49 import org.netbeans.jemmy.operators.JComboBoxOperator;
50 import org.netbeans.jemmy.operators.JDialogOperator;
51 import org.netbeans.jemmy.operators.JFileChooserOperator;
52 import org.netbeans.jemmy.operators.JLabelOperator;
53 import org.netbeans.jemmy.operators.JListOperator;
54 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
55 import org.netbeans.jemmy.operators.JTableOperator;
56 import org.netbeans.jemmy.operators.JTextFieldOperator;
57 import org.netbeans.jemmy.operators.JToggleButtonOperator;
58 import org.netbeans.jemmy.operators.JTreeOperator;
59 import org.netbeans.jemmy.operators.JTreeOperator.NoSuchPathException;
80 if (path.startsWith(
"\\\\")) {
83 if (path.startsWith(
"\\")) {
101 logger.info(
"New Case");
102 setTimeout(
"WindowWaiter.WaitWindowTimeout", 240000);
103 NbDialogOperator nbdo =
new NbDialogOperator(title);
104 JButtonOperator jbo =
new JButtonOperator(nbdo, 0);
106 }
catch (TimeoutExpiredException ex) {
108 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
114 logger.info(
"New Case Wizard");
115 WizardOperator wo =
new WizardOperator(
"New Case Information");
116 JTextFieldOperator jtfo0 =
new JTextFieldOperator(wo, 1);
117 jtfo0.typeText(
"AutopsyTestCase");
118 JTextFieldOperator jtfo1 =
new JTextFieldOperator(wo, 2);
120 wo.btNext().clickMouse();
121 JTextFieldOperator jtfo2 =
new JTextFieldOperator(wo, 0);
122 jtfo2.typeText(
"000");
123 JTextFieldOperator jtfo3 =
new JTextFieldOperator(wo, 1);
124 jtfo3.typeText(
"Examiner 1");
125 start = System.currentTimeMillis();
126 wo.btFinish().clickMouse();
127 }
catch (TimeoutExpiredException ex) {
129 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
139 new Timeout(
"pausing", 120000).sleep();
140 logger.info(
"Starting Add Image process");
141 setTimeout(
"WindowWaiter.WaitWindowTimeOut", 240000);
142 WizardOperator wo =
new WizardOperator(
"Add Data Source");
143 while (!wo.btNext().isEnabled()) {
144 new Timeout(
"pausing", 1000).sleep();
148 wo.btNext().clickMouse();
151 JToggleButtonOperator jtbo =
new JToggleButtonOperator(wo, 0);
153 wo.btNext().clickMouse();
154 JTextFieldOperator jtfo0 =
new JTextFieldOperator(wo, 0);
156 String imageDir = img_path;
157 ((JTextComponent) jtfo0.getSource()).setText(imageDir);
158 JComboBoxOperator comboBoxOperator =
new JComboBoxOperator(wo, 0);
159 comboBoxOperator.setSelectedItem(
"(GMT-5:00) America/New_York");
160 wo.btNext().clickMouse();
161 }
catch (TimeoutExpiredException ex) {
163 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
173 new Timeout(
"pausing", 120000).sleep();
174 logger.info(
"Starting Add Logical Files process");
175 WizardOperator wo =
new WizardOperator(
"Add Data Source");
176 wo.setTimeouts(
setTimeout(
"WindowWaiter.WaitWindowTimeOut", 240000));
177 while (!wo.btNext().isEnabled()) {
178 new Timeout(
"pausing", 1000).sleep();
182 wo.btNext().clickMouse();
185 JToggleButtonOperator jtbo =
new JToggleButtonOperator(wo, 2);
187 wo.btNext().clickMouse();
188 JButtonOperator addButtonOperator =
new JButtonOperator(wo,
"Add");
189 addButtonOperator.pushNoBlock();
190 JFileChooserOperator fileChooserOperator =
new JFileChooserOperator();
191 fileChooserOperator.setCurrentDirectory(
new File(
getEscapedPath(System.getProperty(
"img_path"))));
193 fileChooserOperator.goUpLevel();
194 fileChooserOperator.chooseFile(
new File(
getEscapedPath(System.getProperty(
"img_path"))).getName());
195 wo.btNext().clickMouse();
196 }
catch (TimeoutExpiredException ex) {
198 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
204 WizardOperator wo =
new WizardOperator(
"Add Data Source");
205 while (!wo.btFinish().isEnabled()) {
206 new Timeout(
"pausing", 1000).sleep();
208 logger.log(Level.INFO,
"Add image took {0}ms", (System.currentTimeMillis() -
start));
209 wo.btFinish().clickMouse();
210 }
catch (TimeoutExpiredException ex) {
212 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
222 new Timeout(
"pausing", 10000).sleep();
224 logger.info(
"Looking for hash lookup module in ingest job settings panel");
225 WizardOperator wo =
new WizardOperator(
"Add Data Source");
226 while (!wo.btNext().isEnabled()) {
227 new Timeout(
"pausing", 1000).sleep();
229 JTableOperator jto =
new JTableOperator(wo, 0);
230 int row = jto.findCellRow(
"Hash Lookup", 2, 0);
231 jto.clickOnCell(row, 1);
232 logger.info(
"Selected hash lookup module in ingest job settings panel");
233 JButtonOperator jbo1 =
new JButtonOperator(wo,
"Global Settings");
235 logger.info(
"Pushed Global Settings button for hash lookup module in ingest job settings panel");
236 }
catch (TimeoutExpiredException ex) {
238 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
244 logger.info(
"Hash Configure");
245 JDialog hashMainDialog = JDialogOperator.waitJDialog(
"Global Hash Lookup Settings",
false,
false);
246 JDialogOperator hashMainDialogOperator =
new JDialogOperator(hashMainDialog);
247 List<String> databases =
new ArrayList<>();
249 databases.add(
getEscapedPath(System.getProperty(
"known_bad_path")));
250 databases.stream().map((database) -> {
251 JButtonOperator importButtonOperator =
new JButtonOperator(hashMainDialogOperator,
"Import");
252 importButtonOperator.pushNoBlock();
253 JDialog addDatabaseDialog = JDialogOperator.waitJDialog(
"Import Hash Set",
false,
false);
254 JDialogOperator addDatabaseDialogOperator =
new JDialogOperator(addDatabaseDialog);
255 JButtonOperator browseButtonOperator =
new JButtonOperator(addDatabaseDialogOperator,
"Open...", 0);
256 browseButtonOperator.pushNoBlock();
257 JFileChooserOperator fileChooserOperator =
new JFileChooserOperator();
258 fileChooserOperator.chooseFile(database);
259 JButtonOperator okButtonOperator =
new JButtonOperator(addDatabaseDialogOperator,
"OK", 0);
260 return okButtonOperator;
261 }).map((okButtonOperator) -> {
262 okButtonOperator.pushNoBlock();
263 return okButtonOperator;
264 }).forEach((_item) -> {
265 new Timeout(
"pausing", 1000).sleep();
271 new Timeout(
"pausing", 1000).sleep();
273 JButtonOperator jbo4 =
new JButtonOperator(hashMainDialogOperator,
"OK", 0);
275 }
catch (TimeoutExpiredException ex) {
277 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
283 logger.info(
"Looking for keyword search module in ingest job settings panel");
284 WizardOperator wo =
new WizardOperator(
"Add Data Source");
285 while (!wo.btNext().isEnabled()) {
286 new Timeout(
"pausing", 1000).sleep();
288 JTableOperator jto =
new JTableOperator(wo, 0);
289 int row = jto.findCellRow(
"Keyword Search", 2, 0);
290 jto.clickOnCell(row, 1);
291 logger.info(
"Selected keyword search module in ingest job settings panel");
292 JButtonOperator jbo1 =
new JButtonOperator(wo,
"Global Settings");
294 logger.info(
"Pushed Global Settings button for keyword search module in ingest job settings panel");
295 }
catch (TimeoutExpiredException ex) {
297 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
303 logger.info(
"Search Configure");
304 JDialog jd = JDialogOperator.waitJDialog(
"Global Keyword Search Settings",
false,
false);
305 JDialogOperator jdo =
new JDialogOperator(jd);
306 String words =
getEscapedPath(System.getProperty(
"keyword_path"));
307 JButtonOperator jbo0 =
new JButtonOperator(jdo,
"Import List", 0);
309 JFileChooserOperator jfco0 =
new JFileChooserOperator();
310 jfco0.chooseFile(words);
311 JTableOperator jto =
new JTableOperator(jdo, 0);
312 jto.clickOnCell(0, 0);
313 new Timeout(
"pausing", 1000).sleep();
314 if (Boolean.parseBoolean(System.getProperty(
"mugen_mode"))) {
315 JTabbedPaneOperator jtpo =
new JTabbedPaneOperator(jdo);
316 jtpo.selectPage(
"String Extraction");
317 JCheckBoxOperator jcbo0 =
new JCheckBoxOperator(jtpo,
"Arabic (Arabic)");
319 JCheckBoxOperator jcbo1 =
new JCheckBoxOperator(jtpo,
"Han (Chinese, Japanese, Korean)");
321 new Timeout(
"pausing", 1000).sleep();
323 JButtonOperator jbo2 =
new JButtonOperator(jdo,
"OK", 0);
325 WizardOperator wo =
new WizardOperator(
"Add Data Source");
326 new Timeout(
"pausing", 10000).sleep();
327 wo.btNext().clickMouse();
328 }
catch (TimeoutExpiredException ex) {
330 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
336 logger.info(
"Ingest 3");
337 new Timeout(
"pausing", 10000).sleep();
338 long startIngest = System.currentTimeMillis();
341 new Timeout(
"pausing", 1000).sleep();
343 logger.log(Level.INFO,
"Ingest (including enqueue) took {0}ms", (System.currentTimeMillis() - startIngest));
347 Random rand =
new Random();
348 new Timeout(
"pausing", 10000 + (rand.nextInt(15000) + 5000)).sleep();
349 }
catch (TimeoutExpiredException ex) {
351 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
358 logger.info(
"Data Sources Node");
359 MainWindowOperator mwo = MainWindowOperator.getDefault();
360 JTreeOperator jto =
new JTreeOperator(mwo,
"Data Sources");
361 String[] nodeNames = {
"Data Sources"};
362 TreePath tp = jto.findPath(nodeNames);
364 }
catch (TimeoutExpiredException ex) {
366 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
372 logger.info(
"Generate Report Toolbars");
373 MainWindowOperator mwo = MainWindowOperator.getDefault();
374 JButtonOperator jbo =
new JButtonOperator(mwo,
"Generate Report");
376 }
catch (TimeoutExpiredException ex) {
378 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
384 logger.info(
"Generate Report Button");
385 setTimeout(
"ComponentOperator.WaitComponentTimeout", 240000);
386 JDialog reportDialog = JDialogOperator.waitJDialog(
"Generate Report",
false,
false);
387 JDialogOperator reportDialogOperator =
new JDialogOperator(reportDialog);
388 JListOperator listOperator =
new JListOperator(reportDialogOperator);
389 JButtonOperator jbo0 =
new JButtonOperator(reportDialogOperator,
"Next");
390 DateFormat dateFormat =
new SimpleDateFormat(
"MM-dd-yyyy-HH-mm-ss");
391 Date date =
new Date();
392 String datenotime = dateFormat.format(date);
393 listOperator.clickOnItem(0, 1);
395 new Timeout(
"pausing", 2000).sleep();
398 JButtonOperator dataSourceSelectionPanelNext =
new JButtonOperator(reportDialogOperator,
"Next");
399 dataSourceSelectionPanelNext.pushNoBlock();
400 new Timeout(
"pausing", 2000).sleep();
402 JButtonOperator jbo1 =
new JButtonOperator(reportDialogOperator,
"Finish");
404 JDialog previewDialog = JDialogOperator.waitJDialog(
"Progress",
false,
false);
405 JDialogOperator previewDialogOperator =
new JDialogOperator(previewDialog);
406 JLabelOperator.waitJLabel(previewDialog,
"Complete",
false,
false);
407 JButtonOperator jbo2 =
new JButtonOperator(previewDialogOperator,
"Close");
409 new Timeout(
"pausing", 10000).sleep();
410 System.setProperty(
"ReportStr", datenotime);
411 }
catch (TimeoutExpiredException ex) {
413 logger.log(Level.SEVERE,
"AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
419 File screenShotFile =
new File(outPath +
"\\" + name +
".png");
420 if (!screenShotFile.exists()) {
421 logger.info(
"Taking screenshot.");
423 Rectangle screenRect =
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
424 BufferedImage capture =
new Robot().createScreenCapture(screenRect);
425 ImageIO.write(capture,
"png", screenShotFile);
426 new Timeout(
"pausing", 1000).sleep();
427 }
catch (IOException ex) {
428 logger.log(Level.WARNING,
"IOException taking screenshot.", ex);
429 }
catch (AWTException ex) {
430 logger.log(Level.WARNING,
"AWTException taking screenshot.", ex);
441 Timeouts timeouts = JemmyProperties.getCurrentTimeouts();
442 timeouts.setTimeout(name, value);
449 CaseDbConnectionInfo connectionInfo =
new CaseDbConnectionInfo(
450 System.getProperty(
"dbHost"),
451 System.getProperty(
"dbPort"),
452 System.getProperty(
"dbUserName"),
453 System.getProperty(
"dbPassword"),
454 TskData.DbType.POSTGRESQL);
458 logger.log(Level.SEVERE,
"Error saving case database connection info", ex);
465 System.getProperty(
"messageServiceHost"),
466 Integer.parseInt(System.getProperty(
"messageServicePort")),
472 logger.log(Level.SEVERE,
"Error saving messaging service connection info", ex);
482 for (TreePath t : jto.getChildPaths(tp)) {
485 }
catch (NoSuchPathException ne) {
486 logger.log(Level.SEVERE,
"Error expanding tree path", ne);
static void setZkServerHost(String hostName)
void screenshot(String name)
void testConfigureSearch()
static synchronized IngestManager getInstance()
void testGenerateReportToolbar()
static void setZkServerPort(String port)
void testStartAddLogicalFilesDataSource()
void testConfigureIngest1()
void testAddSourceWizard1()
boolean isIngestRunning()
static String getEscapedPath(String path)
Timeouts setTimeout(String name, int value)
static void setIsMultiUserModeEnabled(boolean enabled)
static void setMessageServiceConnectionInfo(MessageServiceConnectionInfo info)
void testExpandDataSourcesTree()
void expandNodes(JTreeOperator jto, TreePath tp)
void setMultiUserPerferences()
static void setDatabaseConnectionInfo(CaseDbConnectionInfo connectionInfo)
static void setIndexingServerHost(String hostName)
static void setIndexingServerPort(int port)
void testGenerateReportButton()
void testNewCaseWizardOpen(String title)
AutopsyTestCases(boolean isMultiUser)
static final Logger logger
void testStartAddImageFileDataSource()
void testConfigureIngest2()