Skip to content

Commit

Permalink
added tests #586
Browse files Browse the repository at this point in the history
  • Loading branch information
hitenkoku committed Jun 20, 2022
1 parent 21dbe2c commit b20116b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/detections/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ fn load_eventcode_info(path: &str) -> EventInfoConfig {
mod tests {
use crate::detections::configs;
use chrono::{DateTime, Utc};
use hashbrown::HashSet;

// #[test]
// #[ignore]
Expand Down Expand Up @@ -581,4 +582,26 @@ mod tests {
assert!(time_filter.is_target(&start_time));
assert!(time_filter.is_target(&end_time));
}

#[test]
fn test_get_target_extensions() {
let data = vec!["evtx_data".to_string(), "evtx_stars".to_string()];
let arg = Some(&data);
let ret = configs::get_target_extensions(arg);
let expect:HashSet<&str> = HashSet::from(["evtx", "evtx_data", "evtx_stars"]);
assert_eq!(ret.len(), expect.len());
for contents in expect.iter() {
assert!(ret.contains(&contents.to_string()));
}
}

#[test]
fn no_target_extensions() {
let ret = configs::get_target_extensions(None);
let expect:HashSet<&str> = HashSet::from(["evtx"]);
assert_eq!(ret.len(), expect.len());
for contents in expect.iter() {
assert!(ret.contains(&contents.to_string()));
}
}
}

0 comments on commit b20116b

Please sign in to comment.