message: added tests for time-limit
diff: @@ -3,6 +3,9 @@ use assert_cmd::Command;
  use httpmock::Method::GET;
  use httpmock::{Mock, MockServer};
  use predicates::prelude::*;
  +use std::fs::{read_to_string, write};
  +use std::path::Path;
  +use std::time;
  use utils::{setup_tmp_directory, teardown_tmp_directory};
  #[test]
  @@ -91,3 +94,42 @@ fn resume_scan_works() {
  assert_eq!(also_already_scanned.times_called(), 0);
  assert_eq!(not_scanned_yet.times_called(), 1);
  }
  +
  +#[test]
  +/// kick off scan with a time limit;
  +fn time_limit_enforced_when_specified() {
  + let srv = MockServer::start();
  + let (tmp_dir, file) =
  + setup_tmp_directory(&["css".to_string(), "stuff".to_string()], "wordlist").unwrap();
  +
  + // ensure the command will run long enough by adding crap to the wordlist
  + let more_words = read_to_string(Path::new("/etc/dictionaries-common/words")).unwrap();
  + write(&file, more_words).unwrap();
  +
  + assert!(file.metadata().unwrap().len() > 100); // sanity check on wordlist size
  +
  + let now = time::Instant::now();
  + let lower_bound = time::Duration::new(5, 0);
  + let upper_bound = time::Duration::new(6, 0);
  +
  + Command::cargo_bin("feroxbuster")
  + .unwrap()
  + .arg("--url")
  + .arg(srv.url("/"))
  + .arg("--wordlist")
  + .arg(file.as_os_str())
  + .arg("--time-limit")
  + .arg("5s")
  + .assert()
  + .failure();
  +
  + // expected run time is somewhere in the 30 seconds ballpark (real 0m37.376s)
  + // so if the cmd returns in a significantly shorter amount of time, the test will have
  + // succeeded
  +
  + // --time-limit is 5 seconds, so elapsed should be in a window that is greater than 5
  + // but significantly less than 30ish
  + assert!(now.elapsed() > lower_bound && now.elapsed() < upper_bound);
  +
  + teardown_tmp_directory(tmp_dir);
  +}
  