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:706–748  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

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