#![allow(clippy::unwrap_used, clippy::expect_used)]
use shellhist_core::parse_auto;
use shellhist_forensic::{audit, HistAnomaly};
const REAL_BASH: &[u8] = include_bytes!("../../tests/data/real_bash_history");
#[test]
fn real_bash_history_parses_with_timestamps() {
let entries = parse_auto(REAL_BASH, Some(".bash_history"));
assert!(!entries.is_empty(), "real history must yield entries");
assert!(
entries.iter().all(|e| e.timestamp.is_some()),
"every entry should carry an epoch"
);
assert!(entries.iter().any(|e| e.command == "ls -la /tmp"));
}
#[test]
fn real_bash_history_surfaces_its_planted_anomalies() {
let entries = parse_auto(REAL_BASH, Some(".bash_history"));
let codes: Vec<&str> = audit(&entries).iter().map(HistAnomaly::code).collect();
assert!(
codes.contains(&"SHELLHIST-REMOTE-EXEC-PIPE"),
"download-pipe-to-shell not detected in real history; got {codes:?}"
);
assert!(
codes.contains(&"SHELLHIST-HISTORY-DISABLED"),
"history-clearing not detected in real history; got {codes:?}"
);
}