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

Function foreign_session_capture_fails

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

Source from the content-addressed store, hash-verified

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

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