Connect one-shot Linux updater worker flow behind the census gate
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -1316,6 +1316,94 @@ mod tests {
|
||||
active,
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn public_record_builder_binds_actual_original_key_and_exact_health_head() {
|
||||
let f = fixture();
|
||||
let (grant, record, start):(String,Vec<u8>,Vec<u8>)=f.db.query_row(
|
||||
"SELECT h.grant_id,h.record,e.start FROM agent_update_handoffs h JOIN execution_evidence e USING(grant_id)",
|
||||
[],|r|Ok((r.get(0)?,r.get(1)?,r.get(2)?))).unwrap();
|
||||
let grant: Uuid = grant.parse().unwrap();
|
||||
let delegation = update_handoff::read_delegation(&f.db, grant).unwrap();
|
||||
let original =
|
||||
crate::original::Original::verify_retained(&f.binding, &start, &record, delegation)
|
||||
.unwrap();
|
||||
let key: [u8; 32] = hex::decode(&original.update().updater.health_public_key_hex)
|
||||
.unwrap()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
let mut journal = Journal::open(&record, key).unwrap();
|
||||
let mut wrong_journal = Journal::open(
|
||||
&record,
|
||||
SigningKey::from_bytes(&[88; 32]).verifying_key().to_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
let mut statement =
|
||||
f.db.prepare("SELECT event FROM agent_update_handoff_events ORDER BY sequence")
|
||||
.unwrap();
|
||||
let events = statement
|
||||
.query_map([], |r| r.get::<_, Vec<u8>>(0))
|
||||
.unwrap()
|
||||
.collect::<rusqlite::Result<Vec<_>>>()
|
||||
.unwrap();
|
||||
let mut health_raw = None;
|
||||
let mut wrong_health_raw = None;
|
||||
for raw in events {
|
||||
let event: Event = serde_json::from_slice(&raw).unwrap();
|
||||
if let Evidence::HealthVerified { receipt } = &event.evidence {
|
||||
journal.replay(&raw).unwrap();
|
||||
let mut wrong = receipt.clone();
|
||||
let mut message = HEALTH_DOMAIN.to_vec();
|
||||
message.extend_from_slice(&wrong.payload);
|
||||
wrong.signature = SigningKey::from_bytes(&[88; 32])
|
||||
.sign(&message)
|
||||
.to_bytes()
|
||||
.to_vec();
|
||||
let forged = wrong_journal
|
||||
.prepare(
|
||||
event.observed_at,
|
||||
Evidence::HealthVerified { receipt: wrong },
|
||||
)
|
||||
.unwrap();
|
||||
wrong_journal.replay(&forged).unwrap();
|
||||
wrong_health_raw = Some(forged);
|
||||
health_raw = Some(raw);
|
||||
break;
|
||||
}
|
||||
journal.replay(&raw).unwrap();
|
||||
wrong_journal.replay(&raw).unwrap();
|
||||
}
|
||||
let health_raw = health_raw.unwrap();
|
||||
let built = crate::record::BuiltRecord::build(&original, &f.initial, &journal, &health_raw)
|
||||
.unwrap();
|
||||
assert_eq!(built.raw(), f.active);
|
||||
assert_eq!(built.sha256(), hash(&f.active));
|
||||
// A complete kernel Journal can be constructed with the wrong external
|
||||
// key. The public builder must independently enforce the ORIGINAL job.
|
||||
assert!(
|
||||
crate::record::BuiltRecord::build(
|
||||
&original,
|
||||
&f.initial,
|
||||
&wrong_journal,
|
||||
&wrong_health_raw.unwrap()
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
let mut changed: Event = serde_json::from_slice(&health_raw).unwrap();
|
||||
changed.observed_at += 1;
|
||||
assert!(
|
||||
crate::record::BuiltRecord::build(
|
||||
&original,
|
||||
&f.initial,
|
||||
&journal,
|
||||
&serde_json::to_vec(&changed).unwrap()
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
crate::record::BuiltRecord::build(&original, &f.active, &journal, &health_raw).is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completed_history_rejects_file_only_rollback_forks_and_tampered_activation_without_writes() {
|
||||
let f = fixture();
|
||||
|
||||
Reference in New Issue
Block a user