MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / foreign_session_capture_fails

Function foreign_session_capture_fails

atomic-agent/src/turn/capture.rs:611–650  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

write_captureFunction · 0.85
sample_tokenFunction · 0.85
capture_dirFunction · 0.85
latest_capture_fileFunction · 0.85
attempt_capture_pathFunction · 0.85
make_sessionFunction · 0.70
unwrapMethod · 0.45
pathMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected