added more tests again

This commit is contained in:
epi 2022-02-15 16:34:12 -06:00
parent 88a595fd82
commit 3030296d1c
3 changed files with 41 additions and 10 deletions

View File

@ -407,7 +407,6 @@ impl HeuristicTests {
#[cfg(test)]
mod tests {
use super::*;
use assay::assay;
#[test]
/// request a unique string of 32bytes * a value returns correct result
@ -419,7 +418,7 @@ mod tests {
}
}
#[assay]
#[test]
/// `detect_directory_listing` correctly identifies tomcat/python instances
fn detect_directory_listing_finds_tomcat_python() {
let html = "<title>directory listing for /</title>";
@ -433,7 +432,7 @@ mod tests {
));
}
#[assay]
#[test]
/// `detect_directory_listing` correctly identifies apache instances
fn detect_directory_listing_finds_apache() {
let html = "<title>index of /</title>";
@ -444,7 +443,7 @@ mod tests {
assert!(matches!(dirlist_type.unwrap(), DirListingType::Apache));
}
#[assay]
#[test]
/// `detect_directory_listing` correctly identifies ASP.NET instances
fn detect_directory_listing_finds_asp_dot_net() {
let html = "<title>directory listing -- /</title>";
@ -455,7 +454,7 @@ mod tests {
assert!(matches!(dirlist_type.unwrap(), DirListingType::AspDotNet));
}
#[assay]
#[test]
/// `detect_directory_listing` returns None when heuristic doesn't match
fn detect_directory_listing_returns_none_as_default() {
let html = "<title>derp listing -- /</title>";

View File

@ -559,3 +559,39 @@ impl FeroxScans {
extension_added
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
/// unknown extension should be added to collected_extensions
fn unknown_extension_is_added_to_collected_extensions() {
let scans = FeroxScans::new(OutputLevel::Default);
assert_eq!(0, scans.collected_extensions.read().unwrap().len());
let added = scans.add_discovered_extension(String::from("js"));
assert!(added);
assert_eq!(1, scans.collected_extensions.read().unwrap().len());
}
#[test]
/// known extension should not be added to collected_extensions
fn known_extension_is_added_to_collected_extensions() {
let scans = FeroxScans::new(OutputLevel::Default);
scans
.collected_extensions
.write()
.unwrap()
.insert(String::from("js"));
assert_eq!(1, scans.collected_extensions.read().unwrap().len());
let added = scans.add_discovered_extension(String::from("js"));
assert!(!added);
assert_eq!(1, scans.collected_extensions.read().unwrap().len());
}
}

View File

@ -1,12 +1,8 @@
mod utils;
use assay::assay;
use assert_cmd::prelude::*;
use httpmock::Method::GET;
use httpmock::MockServer;
use predicates::prelude::*;
use std::env::temp_dir;
use std::thread::sleep;
use std::time::Duration;
use std::{process::Command, time};
use utils::{setup_tmp_directory, teardown_tmp_directory};
@ -643,7 +639,7 @@ fn rate_limit_enforced_when_specified() {
teardown_tmp_directory(tmp_dir);
}
#[assay]
#[test]
/// ensure that auto-discovered extensions are tracked in statistics and bar lengths are updated
fn add_discovered_extension_updates_bars_and_stats() {
let srv = MockServer::start();