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

Function future_dated_capture_is_refused

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

Source from the content-addressed store, hash-verified

702 /// sides of the window.
703 #[test]
704 fn future_dated_capture_is_refused() {
705 let dir = tempfile::TempDir::new().unwrap();
706 let store = SessionStore::new(dir.path()).unwrap();
707 let mut session = make_session("sess-cap-8");
708 store.save(&session).unwrap();
709 write_capture(
710 dir.path(),
711 &mut session,
712 1,
713 "wc".to_string(),
714 &sample_token(),
715 )
716 .unwrap();
717 store.save(&session).unwrap();
718
719 let key = session.mac_key.clone().unwrap();
720 let path = latest_capture_file(dir.path(), "sess-cap-8", 1)
721 .unwrap()
722 .unwrap();
723 let mut capture = ManagedCommitCapture::from_json(&std::fs::read(&path).unwrap()).unwrap();
724
725 // A future-dated but correctly-signed capture is fabrication, not
726 // freshness.
727 capture.at_unix = chrono::Utc::now().timestamp() + 10_000;
728 capture.sign(&key);
729 std::fs::write(&path, capture.to_json().unwrap()).unwrap();
730
731 let persisted = store.load("sess-cap-8").unwrap().unwrap();
732 let error = verify_capture(
733 dir.path(),
734 &persisted,
735 1,
736 "wc",
737 Some(&"a".repeat(40)),
738 Some("tree-index"),
739 0,
740 )
741 .expect_err("future-dated capture must fail");
742 assert!(
743 error.to_string().contains("future-dated"),
744 "unexpected: {error}"
745 );
746 }
747}

Callers

nothing calls this directly

Calls 15

write_captureFunction · 0.85
sample_tokenFunction · 0.85
latest_capture_fileFunction · 0.85
verify_captureFunction · 0.85
make_sessionFunction · 0.70
readFunction · 0.50
writeFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
saveMethod · 0.45
cloneMethod · 0.45
timestampMethod · 0.45

Tested by

no test coverage detected