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.Level;
35 import java.util.logging.Logger;
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.Timeouts;
46 import org.netbeans.jemmy.operators.JButtonOperator;
47 import org.netbeans.jemmy.operators.JCheckBoxOperator;
48 import org.netbeans.jemmy.operators.JComboBoxOperator;
49 import org.netbeans.jemmy.operators.JDialogOperator;
50 import org.netbeans.jemmy.operators.JFileChooserOperator;
51 import org.netbeans.jemmy.operators.JLabelOperator;
52 import org.netbeans.jemmy.operators.JListOperator;
53 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
54 import org.netbeans.jemmy.operators.JTableOperator;
55 import org.netbeans.jemmy.operators.JTextFieldOperator;
56 import org.netbeans.jemmy.operators.JToggleButtonOperator;
57 import org.netbeans.jemmy.operators.JTreeOperator;
58 import org.netbeans.jemmy.operators.JTreeOperator.NoSuchPathException;
79 if (path.startsWith(
"\\\\")) {
82 if (path.startsWith(
"\\")) {
99 logger.info(
"New Case");
101 NbDialogOperator nbdo =
new NbDialogOperator(title);
102 JButtonOperator jbo =
new JButtonOperator(nbdo, 0);
107 logger.info(
"New Case Wizard");
108 WizardOperator wo =
new WizardOperator(
"New Case Information");
109 JTextFieldOperator jtfo0 =
new JTextFieldOperator(wo, 1);
110 jtfo0.typeText(
"AutopsyTestCase");
111 JTextFieldOperator jtfo1 =
new JTextFieldOperator(wo, 2);
113 wo.btNext().clickMouse();
114 JTextFieldOperator jtfo2 =
new JTextFieldOperator(wo, 0);
115 jtfo2.typeText(
"000");
116 JTextFieldOperator jtfo3 =
new JTextFieldOperator(wo, 1);
117 jtfo3.typeText(
"Examiner 1");
118 start = System.currentTimeMillis();
119 wo.btFinish().clickMouse();
126 new Timeout(
"pausing", 120000).sleep();
127 logger.info(
"Starting Add Image process");
129 WizardOperator wo =
new WizardOperator(
"Add Data Source");
130 while(!wo.btNext().isEnabled()){
131 new Timeout(
"pausing", 1000).sleep();
134 JToggleButtonOperator jtbo =
new JToggleButtonOperator(wo, 0);
136 wo.btNext().clickMouse();
137 JTextFieldOperator jtfo0 =
new JTextFieldOperator(wo, 0);
139 String imageDir = img_path;
140 ((JTextComponent) jtfo0.getSource()).setText(imageDir);
141 JComboBoxOperator comboBoxOperator =
new JComboBoxOperator(wo, 0);
142 comboBoxOperator.setSelectedItem(
"(GMT-5:00) America/New_York");
143 wo.btNext().clickMouse();
150 new Timeout(
"pausing", 120000).sleep();
151 logger.info(
"Starting Add Logical Files process");
152 WizardOperator wo =
new WizardOperator(
"Add Data Source");
153 wo.setTimeouts(
resetTimeouts(
"WindowWaiter.WaitWindowTimeOut", 240000));
154 while(!wo.btNext().isEnabled()){
155 new Timeout(
"pausing", 1000).sleep();
158 JToggleButtonOperator jtbo =
new JToggleButtonOperator(wo, 2);
160 wo.btNext().clickMouse();
161 JButtonOperator addButtonOperator =
new JButtonOperator(wo,
"Add");
162 addButtonOperator.pushNoBlock();
163 JFileChooserOperator fileChooserOperator =
new JFileChooserOperator();
164 fileChooserOperator.setCurrentDirectory(
new File(
getEscapedPath(System.getProperty(
"img_path"))));
166 fileChooserOperator.goUpLevel();
167 fileChooserOperator.chooseFile(
new File(
getEscapedPath(System.getProperty(
"img_path"))).getName());
168 wo.btNext().clickMouse();
172 WizardOperator wo =
new WizardOperator(
"Add Data Source");
173 while (!wo.btFinish().isEnabled()) {
174 new Timeout(
"pausing", 1000).sleep();
176 logger.log(Level.INFO,
"Add image took {0}ms", (System.currentTimeMillis() -
start));
177 wo.btFinish().clickMouse();
185 new Timeout(
"pausing", 10000).sleep();
187 logger.info(
"Looking for hash lookup module in ingest job settings panel");
188 WizardOperator wo =
new WizardOperator(
"Add Data Source");
189 while(!wo.btNext().isEnabled()){
190 new Timeout(
"pausing", 1000).sleep();
192 JTableOperator jto =
new JTableOperator(wo, 0);
193 int row = jto.findCellRow(
"Hash Lookup", 2, 0);
194 jto.clickOnCell(row, 1);
195 logger.info(
"Selected hash lookup module in ingest job settings panel");
196 JButtonOperator jbo1 =
new JButtonOperator(wo,
"Global Settings");
198 logger.info(
"Pushed Global Settings button for hash lookup module in ingest job settings panel");
202 logger.info(
"Hash Configure");
203 JDialog hashMainDialog = JDialogOperator.waitJDialog(
"Global Hash Lookup Settings",
false,
false);
204 JDialogOperator hashMainDialogOperator =
new JDialogOperator(hashMainDialog);
205 List<String> databases =
new ArrayList<>();
207 databases.add(
getEscapedPath(System.getProperty(
"known_bad_path")));
208 databases.stream().map((database) -> {
209 JButtonOperator importButtonOperator =
new JButtonOperator(hashMainDialogOperator,
"Import");
210 importButtonOperator.pushNoBlock();
211 JDialog addDatabaseDialog = JDialogOperator.waitJDialog(
"Import Hash Set",
false,
false);
212 JDialogOperator addDatabaseDialogOperator =
new JDialogOperator(addDatabaseDialog);
213 JButtonOperator browseButtonOperator =
new JButtonOperator(addDatabaseDialogOperator,
"Open...", 0);
214 browseButtonOperator.pushNoBlock();
215 JFileChooserOperator fileChooserOperator =
new JFileChooserOperator();
216 fileChooserOperator.chooseFile(database);
217 JButtonOperator okButtonOperator =
new JButtonOperator(addDatabaseDialogOperator,
"OK", 0);
218 return okButtonOperator;
219 }).map((okButtonOperator) -> {
220 okButtonOperator.pushNoBlock();
221 return okButtonOperator;
222 }).forEach((_item) -> {
223 new Timeout(
"pausing", 1000).sleep();
229 new Timeout(
"pausing", 1000).sleep();
231 JButtonOperator jbo4 =
new JButtonOperator(hashMainDialogOperator,
"OK", 0);
236 logger.info(
"Looking for keyword search module in ingest job settings panel");
237 WizardOperator wo =
new WizardOperator(
"Add Data Source");
238 while(!wo.btNext().isEnabled()){
239 new Timeout(
"pausing", 1000).sleep();
241 JTableOperator jto =
new JTableOperator(wo, 0);
242 int row = jto.findCellRow(
"Keyword Search", 2, 0);
243 jto.clickOnCell(row, 1);
244 logger.info(
"Selected keyword search module in ingest job settings panel");
245 JButtonOperator jbo1 =
new JButtonOperator(wo,
"Global Settings");
247 logger.info(
"Pushed Global Settings button for keyword search module in ingest job settings panel");
251 logger.info(
"Search Configure");
252 JDialog jd = JDialogOperator.waitJDialog(
"Global Keyword Search Settings",
false,
false);
253 JDialogOperator jdo =
new JDialogOperator(jd);
254 String words =
getEscapedPath(System.getProperty(
"keyword_path"));
255 JButtonOperator jbo0 =
new JButtonOperator(jdo,
"Import List", 0);
257 JFileChooserOperator jfco0 =
new JFileChooserOperator();
258 jfco0.chooseFile(words);
259 JTableOperator jto =
new JTableOperator(jdo, 0);
260 jto.clickOnCell(0, 0);
261 new Timeout(
"pausing", 1000).sleep();
262 if (Boolean.parseBoolean(System.getProperty(
"mugen_mode"))) {
263 JTabbedPaneOperator jtpo =
new JTabbedPaneOperator(jdo);
264 jtpo.selectPage(
"String Extraction");
265 JCheckBoxOperator jcbo0 =
new JCheckBoxOperator(jtpo,
"Arabic (Arabic)");
267 JCheckBoxOperator jcbo1 =
new JCheckBoxOperator(jtpo,
"Han (Chinese, Japanese, Korean)");
269 new Timeout(
"pausing", 1000).sleep();
271 JButtonOperator jbo2 =
new JButtonOperator(jdo,
"OK", 0);
273 WizardOperator wo =
new WizardOperator(
"Add Data Source");
274 new Timeout(
"pausing", 10000).sleep();
275 wo.btNext().clickMouse();
279 logger.info(
"Ingest 3");
280 new Timeout(
"pausing", 10000).sleep();
281 long startIngest = System.currentTimeMillis();
284 new Timeout(
"pausing", 1000).sleep();
286 logger.log(Level.INFO,
"Ingest (including enqueue) took {0}ms", (System.currentTimeMillis() - startIngest));
290 Random rand =
new Random();
291 new Timeout(
"pausing", 10000 + (rand.nextInt(15000) + 5000)).sleep();
297 logger.info(
"Data Sources Node");
298 MainWindowOperator mwo = MainWindowOperator.getDefault();
299 JTreeOperator jto =
new JTreeOperator(mwo,
"Data Sources");
300 String [] nodeNames = {
"Data Sources"};
301 TreePath tp = jto.findPath(nodeNames);
307 logger.info(
"Generate Report Toolbars");
308 MainWindowOperator mwo = MainWindowOperator.getDefault();
309 JButtonOperator jbo =
new JButtonOperator(mwo,
"Generate Report");
311 new Timeout(
"pausing", 5000).sleep();
315 logger.info(
"Generate Report Button");
316 resetTimeouts(
"ComponentOperator.WaitComponentTimeout", 240000);
317 JDialog reportDialog = JDialogOperator.waitJDialog(
"Generate Report",
false,
false);
318 JDialogOperator reportDialogOperator =
new JDialogOperator(reportDialog);
319 JListOperator listOperator =
new JListOperator(reportDialogOperator);
320 JButtonOperator jbo0 =
new JButtonOperator(reportDialogOperator,
"Next");
321 DateFormat dateFormat =
new SimpleDateFormat(
"MM-dd-yyyy-HH-mm-ss");
322 Date date =
new Date();
323 String datenotime = dateFormat.format(date);
324 listOperator.clickOnItem(0, 1);
326 new Timeout(
"pausing", 2000).sleep();
327 JButtonOperator jbo1 =
new JButtonOperator(reportDialogOperator,
"Finish");
329 JDialog previewDialog = JDialogOperator.waitJDialog(
"Progress",
false,
false);
331 JDialogOperator previewDialogOperator =
new JDialogOperator(previewDialog);
332 JLabelOperator.waitJLabel(previewDialog,
"Complete",
false,
false);
333 JButtonOperator jbo2 =
new JButtonOperator(previewDialogOperator,
"Close");
335 new Timeout(
"pausing", 10000).sleep();
336 System.setProperty(
"ReportStr", datenotime);
341 logger.info(
"Taking screenshot.");
343 Rectangle screenRect =
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
344 BufferedImage capture =
new Robot().createScreenCapture(screenRect);
346 ImageIO.write(capture,
"png",
new File(outPath +
"\\" + name +
".png"));
347 new Timeout(
"pausing", 1000).sleep();
348 }
catch (IOException ex) {
349 logger.log(Level.WARNING,
"IOException taking screenshot.", ex);
350 }
catch (AWTException ex) {
351 logger.log(Level.WARNING,
"AWTException taking screenshot.", ex);
362 Timeouts timeouts = JemmyProperties.getCurrentTimeouts();
363 timeouts.setTimeout(name, value);
370 CaseDbConnectionInfo connectionInfo =
new CaseDbConnectionInfo(
371 System.getProperty(
"dbHost"),
372 System.getProperty(
"dbPort"),
373 System.getProperty(
"dbUserName"),
374 System.getProperty(
"dbPassword"),
375 TskData.DbType.POSTGRESQL);
379 logger.log(Level.SEVERE,
"Error saving case database connection info", ex);
386 System.getProperty(
"messageServiceHost"),
387 Integer.parseInt(System.getProperty(
"messageServicePort")),
393 logger.log(Level.SEVERE,
"Error saving messaging service connection info", ex);
400 for (TreePath t : jto.getChildPaths(tp)) {
403 }
catch (NoSuchPathException ne) {
404 logger.log(Level.SEVERE,
"Error expanding tree path", ne);
void screenshot(String name)
void testConfigureSearch()
static synchronized IngestManager getInstance()
void testGenerateReportToolbar()
void testStartAddLogicalFilesDataSource()
void testConfigureIngest1()
void testAddSourceWizard1()
boolean isIngestRunning()
static String getEscapedPath(String path)
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)
Timeouts resetTimeouts(String name, int value)
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()