Skip to content

Commit 6fe9bac

Browse files
committed
test(report): lock golden report fixtures
1 parent a0f0d45 commit 6fe9bac

6 files changed

Lines changed: 42 additions & 3 deletions

File tree

docs/report-artifacts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ The report contracts are backed by generated fixture artifacts:
6161
| Fixture case | Golden artifacts |
6262
| --- | --- |
6363
| [`syslog_legacy`](../tests/fixtures/report_contracts/syslog_legacy) | `report.md`, `report.json`, `findings.csv`, `warnings.csv` |
64-
| [`journalctl_short_full`](../tests/fixtures/report_contracts/journalctl_short_full) | `report.md`, `report.json` |
64+
| [`journalctl_short_full`](../tests/fixtures/report_contracts/journalctl_short_full) | `report.md`, `report.json`, `findings.csv`, `warnings.csv` |
6565
| [`multi_host_syslog_legacy`](../tests/fixtures/report_contracts/multi_host_syslog_legacy) | `report.md`, `report.json`, `findings.csv`, `warnings.csv` |
66-
| [`multi_host_journalctl_short_full`](../tests/fixtures/report_contracts/multi_host_journalctl_short_full) | `report.md`, `report.json` |
66+
| [`multi_host_journalctl_short_full`](../tests/fixtures/report_contracts/multi_host_journalctl_short_full) | `report.md`, `report.json`, `findings.csv`, `warnings.csv` |
6767

68-
The enforcement lives in [`tests/test_report_contracts.cpp`](../tests/test_report_contracts.cpp). The focused report writer tests live in [`tests/test_report.cpp`](../tests/test_report.cpp).
68+
The enforcement lives in [`tests/test_report_contracts.cpp`](../tests/test_report_contracts.cpp). Parser or rule changes that alter report artifacts must update these snapshots explicitly. The focused report writer tests live in [`tests/test_report.cpp`](../tests/test_report.cpp).
6969

7070
## Boundaries
7171

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rule,subject_kind,subject,event_count,window_start,window_end,usernames,summary
2+
brute_force,source_ip,203.0.113.10,5,2026-03-10 08:11:22,2026-03-10 08:18:05,,5 failed SSH attempts from 203.0.113.10 within 10 minutes.
3+
multi_user_probing,source_ip,203.0.113.10,5,2026-03-10 08:11:22,2026-03-10 08:18:05,admin;deploy;guest;root;test,203.0.113.10 targeted 5 usernames within 15 minutes.
4+
sudo_burst,username,alice,3,2026-03-10 08:21:00,2026-03-10 08:24:15,,alice ran 3 sudo commands within 5 minutes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind,line_number,message
2+
parse_warning,15,unrecognized auth pattern: sshd_connection_closed_preauth
3+
parse_warning,16,unrecognized auth pattern: sshd_timeout_or_disconnection
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rule,subject_kind,subject,event_count,window_start,window_end,usernames,summary
2+
brute_force,source_ip,203.0.113.10,5,2026-03-11 09:00:00,2026-03-11 09:04:05,,5 failed SSH attempts from 203.0.113.10 within 10 minutes.
3+
multi_user_probing,source_ip,203.0.113.10,5,2026-03-11 09:00:00,2026-03-11 09:04:05,admin;deploy;guest;root;test,203.0.113.10 targeted 5 usernames within 15 minutes.
4+
sudo_burst,username,alice,3,2026-03-11 09:11:00,2026-03-11 09:14:15,,alice ran 3 sudo commands within 5 minutes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind,line_number,message
2+
parse_warning,12,unrecognized auth pattern: pam_sss_unknown_user
3+
parse_warning,14,unrecognized auth pattern: sshd_connection_closed_preauth
4+
parse_warning,15,unrecognized auth pattern: sshd_timeout_or_disconnection
5+
parse_warning,16,unrecognized auth pattern: pam_unix_session_closed
6+
parse_warning,17,unrecognized auth pattern: sshd_negotiation_failure

tests/test_report_contracts.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ void run_report_contract_case(const std::filesystem::path& loglens_exe,
241241
const auto golden_markdown = read_file(fixture_directory / "report.md");
242242
const auto golden_json = read_file(fixture_directory / "report.json");
243243

244+
expect_equal_lines(
245+
split_lines(actual_markdown),
246+
split_lines(golden_markdown),
247+
"markdown snapshot mismatch for " + fixture_directory.filename().string());
248+
expect_equal_lines(
249+
split_lines(actual_json),
250+
split_lines(golden_json),
251+
"json snapshot mismatch for " + fixture_directory.filename().string());
244252
expect_equal_lines(
245253
extract_markdown_contract_lines(actual_markdown),
246254
extract_markdown_contract_lines(golden_markdown),
@@ -326,13 +334,27 @@ int main(int argc, char* argv[]) {
326334
"syslog",
327335
"--year 2026 --csv",
328336
true);
337+
run_report_contract_case(
338+
loglens_exe,
339+
fixture_root / "journalctl_short_full",
340+
output_root,
341+
"journalctl-short-full",
342+
"--csv",
343+
true);
329344
run_report_contract_case(
330345
loglens_exe,
331346
fixture_root / "multi_host_syslog_legacy",
332347
output_root,
333348
"syslog",
334349
"--year 2026 --csv",
335350
true);
351+
run_report_contract_case(
352+
loglens_exe,
353+
fixture_root / "multi_host_journalctl_short_full",
354+
output_root,
355+
"journalctl-short-full",
356+
"--csv",
357+
true);
336358
} catch (...) {
337359
std::filesystem::current_path(original_cwd);
338360
throw;

0 commit comments

Comments
 (0)