()
| 607 | |
| 608 | #[test] |
| 609 | fn foreign_session_capture_fails() { |
| 610 | let dir = tempfile::TempDir::new().unwrap(); |
| 611 | let store = SessionStore::new(dir.path()).unwrap(); |
| 612 | let mut session = make_session("sess-cap-5"); |
| 613 | store.save(&session).unwrap(); |
| 614 | write_capture( |
| 615 | dir.path(), |
| 616 | &mut session, |
| 617 | 1, |
| 618 | "wc".to_string(), |
| 619 | &sample_token(), |
| 620 | ) |
| 621 | .unwrap(); |
| 622 | store.save(&session).unwrap(); |
| 623 | |
| 624 | let impostor = make_session("sess-cap-6"); |
| 625 | // The capture copied into the impostor's path must not authenticate |
| 626 | // under the impostor's own MAC key. |
| 627 | std::fs::create_dir_all(capture_dir(dir.path(), "sess-cap-6").unwrap()).unwrap(); |
| 628 | std::fs::copy( |
| 629 | latest_capture_file(dir.path(), "sess-cap-5", 1) |
| 630 | .unwrap() |
| 631 | .unwrap(), |
| 632 | attempt_capture_path(dir.path(), "sess-cap-6", 1, 1).unwrap(), |
| 633 | ) |
| 634 | .unwrap(); |
| 635 | assert!( |
| 636 | verify_capture( |
| 637 | dir.path(), |
| 638 | &impostor, |
| 639 | 1, |
| 640 | "wc", |
| 641 | Some(&"a".repeat(40)), |
| 642 | Some("tree-index"), |
| 643 | 0, |
| 644 | ) |
| 645 | .is_err(), |
| 646 | "another session's MAC key must not authenticate the capture" |
| 647 | ); |
| 648 | } |
| 649 | |
| 650 | /// Review R9: a retried commit within the same turn must not overwrite |
| 651 | /// the previous attempt's evidence — attempts are create-only files and |
nothing calls this directly
no test coverage detected