[control] Share and token fixes: settle the epoch before minting, mint in its own task so a dropped client frees its key, token checks off the async threads, CLI refuses to run as another user than the state dir's owner

This commit is contained in:
2026-11-07 19:20:05 +01:00
parent 43918943da
commit 7d3af00720
6 changed files with 102 additions and 13 deletions
+25
View File
@@ -171,3 +171,28 @@ fn a_deny_list_that_would_overflow_raises_the_epoch() {
);
assert!(r["deny"].as_array().unwrap().len() < 10_000);
}
#[test]
fn a_link_minted_after_the_records_were_lost_works() {
let d = TempDir::new("doa");
let rev = d.join("share-revocations.json");
let s = Shares::new(d.path(), &rev);
let key = ShareKey::new(&[9u8; 32]).unwrap();
let a = s.mint(&key, "a.test", "/", 3600, None, None, "t").unwrap();
s.stop(&a.record.id).unwrap();
std::fs::remove_file(d.join("share-links.json")).unwrap();
let b = s.mint(&key, "a.test", "/", 3600, None, None, "t").unwrap();
let published = revocations(&rev);
assert!(
u64::from(b.record.epoch) >= published["epoch"].as_u64().unwrap(),
"dead on arrival: link epoch {} < published {}",
b.record.epoch,
published["epoch"]
);
let list = s.load().unwrap();
let rec = list.links.iter().find(|l| l.id == b.record.id).unwrap();
assert_eq!(
rec.state(list.epoch, ianitor_control::util::now()),
"active"
);
}