()
| 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 | } |
nothing calls this directly
no test coverage detected