Skip to content

Commit

Permalink
add lnk2bodyfile integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Starke committed Nov 2, 2023
1 parent 450bbba commit 0330115
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
Binary file added tests/data/lnk2bodyfile/x64dbg.lnk
Binary file not shown.
1 change: 1 addition & 0 deletions tests/lnk2bodyfile/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod x64dbg;
39 changes: 39 additions & 0 deletions tests/lnk2bodyfile/x64dbg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use std::{
io::{BufRead, BufReader, Cursor},
path::PathBuf,
};

use assert_cmd::Command;
use dfir_toolkit::common::bodyfile::Bodyfile3Line;

#[test]
fn test_x64dbg() {
let mut cmd = Command::cargo_bin("lnk2bodyfile").unwrap();
let mut data_path = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
data_path.push("tests");
data_path.push("data");
data_path.push("lnk2bodyfile");
data_path.push("x64dbg.lnk");

let result = cmd.arg(data_path).ok();
if result.is_err() {
println!("{}", result.as_ref().err().unwrap());
}

assert!(result.is_ok());

// parse the result as bodyfile 😈
let reader = BufReader::new(Cursor::new(result.unwrap().stdout));
let mut lines_iterator = reader.lines();
let first_line = lines_iterator.next().unwrap().unwrap();

let bfline = Bodyfile3Line::try_from(&first_line[..]).unwrap();
assert_eq!(bfline.get_name(), r#"C:\Program Files\x64dbg\release\x64\x64dbg.exe - (referred to by "x64dbg.lnk")"#);
assert_eq!(*bfline.get_size(), 172768);
assert_eq!(*bfline.get_atime(), 1695724808);
assert_eq!(*bfline.get_mtime(), 1695250410);
assert_eq!(*bfline.get_ctime(), -1);
assert_eq!(*bfline.get_crtime(), 1695724422);

assert!(lines_iterator.next().is_none());
}
3 changes: 2 additions & 1 deletion tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
mod mactime2;
mod ts2date;
mod ts2date;
mod lnk2bodyfile;

0 comments on commit 0330115

Please sign in to comment.