const DF_VMDK: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/data/df.vmdk");
#[test]
fn vmdk_unclean_shutdown_surfaces_in_opened_image() {
let mut bytes = std::fs::read(DF_VMDK).expect("read df.vmdk fixture");
bytes[72] = 1;
let dir = tempfile::tempdir().unwrap();
let p = dir.path().join("unclean.vmdk");
std::fs::write(&p, &bytes).unwrap();
let opened = disk_forensic::container::open(&p).expect("open mutated vmdk");
let codes: Vec<&str> = opened.findings.iter().map(|f| f.code.as_ref()).collect();
assert!(
codes.contains(&"VMDK-UNCLEAN-SHUTDOWN"),
"VMDK forensic findings surface on the opened image, got: {codes:?}"
);
}
#[test]
fn clean_vmdk_has_no_container_findings() {
let opened =
disk_forensic::container::open(std::path::Path::new(DF_VMDK)).expect("open clean vmdk");
assert!(
opened.findings.is_empty(),
"a clean VMDK has no container findings, got: {:?}",
opened
.findings
.iter()
.map(|f| f.code.as_ref())
.collect::<Vec<_>>()
);
}