Deploy reviewed Windows sync alignment with schema 20 server
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
Bind the administrative connection-205 review to original signed history and preserve closed readiness. Include the qualified server dependency closure, UI review, native ARM64 build provenance, and guarded deployment evidence. Migration, API/gateway replacement and TLS checks passed with unchanged job authority, protected mounts and time/database services; native Windows receipt application remains separate.
This commit is contained in:
@@ -492,7 +492,7 @@ impl UpdateInflightProof {
|
||||
|| !self.delegation.validate()
|
||||
|| !digest(&self.head_sha256)
|
||||
|| self.events.is_empty()
|
||||
|| self.events.len() > 16
|
||||
|| self.events.len() > rmm_updater_handoff::MAX_V2_EVENTS
|
||||
|| self.handoff_record.len() > 21846
|
||||
{
|
||||
return Err("UPDATE_INFLIGHT_LIMIT");
|
||||
@@ -509,8 +509,30 @@ impl UpdateInflightProof {
|
||||
}
|
||||
Ok(raw)
|
||||
}
|
||||
let handoff_record = bounded(&self.handoff_record)?;
|
||||
if self.events.len() > rmm_updater_handoff::MAX_EVENTS {
|
||||
let handoff: rmm_updater_handoff::Handoff = serde_json::from_slice(&handoff_record)
|
||||
.map_err(|_| "UPDATE_INFLIGHT_WINDOWS_CLOCK_RECORD")?;
|
||||
let limit = if handoff.schema_version == 2 {
|
||||
rmm_updater_handoff::MAX_V2_EVENTS
|
||||
} else if handoff.pin_transition
|
||||
== rmm_updater_handoff::PinTransition::WindowsCodePairClockV1
|
||||
{
|
||||
rmm_updater_handoff::MAX_WINDOWS_CLOCK_EVENTS
|
||||
} else {
|
||||
rmm_updater_handoff::MAX_EVENTS
|
||||
};
|
||||
if self.events.len() > limit
|
||||
|| handoff
|
||||
.bytes()
|
||||
.map_err(|_| "UPDATE_INFLIGHT_WINDOWS_CLOCK_RECORD")?
|
||||
!= handoff_record
|
||||
{
|
||||
return Err("UPDATE_INFLIGHT_PROFILE_LIMIT");
|
||||
}
|
||||
}
|
||||
Ok(DecodedInflightProof {
|
||||
handoff_record: bounded(&self.handoff_record)?,
|
||||
handoff_record,
|
||||
events: self
|
||||
.events
|
||||
.iter()
|
||||
|
||||
@@ -244,20 +244,14 @@ impl LocalUpdatePolicy {
|
||||
return false;
|
||||
};
|
||||
let names: Vec<_> = self.services.iter().map(|v| v.unit.as_str()).collect();
|
||||
self.schema_version == 1
|
||||
let linux = self.schema_version == 1
|
||||
&& self.profile == "linux_general_full_v1"
|
||||
&& !self.tenant_id.is_nil()
|
||||
&& !self.asset_id.is_nil()
|
||||
&& !self.agent_id.is_nil()
|
||||
&& self.enrollment_generation > 0
|
||||
&& self.assignment_version > 0
|
||||
&& self.ledger_path == "/var/lib/rmm-helper/consumption.sqlite"
|
||||
&& self.lock_path == "/var/lib/rmm-helper/executor.lock"
|
||||
&& self.installed_record_path == "/var/lib/rmm-agent-updater/installed-record.json"
|
||||
&& self.keyring_path == "/etc/rmm-agent-updater/keyring.json"
|
||||
&& self.health_pin_path == "/etc/rmm-agent-updater/health-key.json"
|
||||
&& self.registry_path == "/etc/rmm-agent-updater/reader-registry.json"
|
||||
&& digest(&self.reader_registry_sha256)
|
||||
&& (names == SERVICES
|
||||
|| names
|
||||
== [
|
||||
@@ -266,11 +260,30 @@ impl LocalUpdatePolicy {
|
||||
SERVICES[2],
|
||||
"rmm-apt-helper.service",
|
||||
])
|
||||
&& self.services.iter().all(|v| digest(&v.unit_sha256))
|
||||
&& self.updater_service.unit == "rmm-agent-updater.service"
|
||||
&& baseline.record.platform == Platform::LinuxX64;
|
||||
let windows = self.schema_version == 2
|
||||
&& self.profile == "windows_code_pair_clock_v1"
|
||||
&& self.ledger_path == r"C:\ProgramData\RustDiscoverySystem\state\ledger.sqlite"
|
||||
&& self.lock_path == r"C:\ProgramData\RustDiscoverySystem\state\executor.lock"
|
||||
&& self.installed_record_path
|
||||
== r"C:\ProgramData\RustDiscoveryUpdater\installed-record.json"
|
||||
&& self.keyring_path == r"C:\ProgramData\RustDiscoveryUpdater\keyring.json"
|
||||
&& self.health_pin_path == r"C:\ProgramData\RustDiscoveryUpdater\health-key.json"
|
||||
&& self.registry_path == r"C:\ProgramData\RustDiscoveryUpdater\reader-registry.json"
|
||||
&& names == ["RmmDiscoveryWindows", "RmmDiscoverySystemHelper"]
|
||||
&& self.updater_service.unit == "RmmDiscoveryUpdater"
|
||||
&& baseline.record.platform == Platform::WindowsX64;
|
||||
(linux || windows)
|
||||
&& !self.tenant_id.is_nil()
|
||||
&& !self.asset_id.is_nil()
|
||||
&& !self.agent_id.is_nil()
|
||||
&& self.enrollment_generation > 0
|
||||
&& self.assignment_version > 0
|
||||
&& digest(&self.reader_registry_sha256)
|
||||
&& self.services.iter().all(|v| digest(&v.unit_sha256))
|
||||
&& digest(&self.updater_service.unit_sha256)
|
||||
&& digest(&self.updater_binary_sha256)
|
||||
&& baseline.record.platform == Platform::LinuxX64
|
||||
&& self.initial_record_sha256 == hash(&baseline.payload_bytes)
|
||||
&& self.initial_manifest_sha256 == baseline.record.manifest_sha256
|
||||
&& self.initial_activation_floor == baseline.record.activation_floor
|
||||
@@ -288,3 +301,63 @@ impl LocalUpdatePolicy {
|
||||
Ok((policy, hash(raw)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Deterministic PUBLIC record metadata only. This does not authenticate an
|
||||
/// original, a release, Health or policy, and grants no namespace/ledger access.
|
||||
/// Each native private BuiltRecord constructor must first verify its actual
|
||||
/// Original and signed Health independently, then retain its own effect guard.
|
||||
pub fn assemble_updated_record(
|
||||
update: &crate::agent_update::ResolvedAgentUpdate,
|
||||
prior_raw: &[u8],
|
||||
handoff_sha256: &str,
|
||||
signed: &rmm_updater_handoff::SignedHealth,
|
||||
receipt: &rmm_updater_handoff::HealthReceipt,
|
||||
) -> Result<InstalledReleaseRecord, &'static str> {
|
||||
if !update.validate()
|
||||
|| !digest(handoff_sha256)
|
||||
|| receipt.handoff_sha256 != handoff_sha256
|
||||
|| receipt.ready
|
||||
|| signed.signature.len() != 64
|
||||
|| serde_json::to_vec(receipt).map_err(|_| "UPDATE_RECORD_RECEIPT_CODEC")? != signed.payload
|
||||
{
|
||||
return Err("UPDATE_RECORD_INPUT");
|
||||
}
|
||||
let prior = InstalledReleaseRecord::from_bytes(prior_raw)?;
|
||||
let parent = prior.release_envelope.decode()?;
|
||||
let target = update.manifest()?;
|
||||
let old_sha256 = hash(prior_raw);
|
||||
if prior.rolled_back
|
||||
|| old_sha256 != update.predecessor.installed_record_sha256
|
||||
|| prior.manifest_sha256 != update.predecessor.manifest_sha256
|
||||
|| parent.manifest.release_id != update.predecessor.release_id
|
||||
|| parent.manifest.release_sequence != update.predecessor.release_sequence
|
||||
|| parent.manifest.artifacts[0].sha256 != update.predecessor.agent_sha256
|
||||
|| parent.manifest.artifacts[1].sha256 != update.predecessor.helper_sha256
|
||||
|| prior.platform != target.platform
|
||||
|| target.release_sequence <= prior.activation_floor
|
||||
|| receipt.issued_at < prior.activated_at
|
||||
{
|
||||
return Err("UPDATE_RECORD_PREDECESSOR_OR_FLOOR");
|
||||
}
|
||||
let record = InstalledReleaseRecord {
|
||||
schema_version: 1,
|
||||
profile: "decoder_compatible_handoff_v1".into(),
|
||||
platform: target.platform,
|
||||
release_envelope: update.release_envelope.clone(),
|
||||
manifest_sha256: update.manifest_sha256.clone(),
|
||||
activation_floor: target.release_sequence,
|
||||
activated_at: receipt.issued_at,
|
||||
previous_record_sha256: Some(old_sha256.clone()),
|
||||
activation_evidence: ActivationEvidence::Updated {
|
||||
handoff_sha256: handoff_sha256.into(),
|
||||
signed_health_sha256: hash(
|
||||
&serde_json::to_vec(signed).map_err(|_| "UPDATE_RECORD_HEALTH_CODEC")?,
|
||||
),
|
||||
},
|
||||
rolled_back: false,
|
||||
};
|
||||
if hash(&record.bytes()?) == old_sha256 {
|
||||
return Err("UPDATE_RECORD_SAME_BYTES");
|
||||
}
|
||||
Ok(record)
|
||||
}
|
||||
|
||||
@@ -368,6 +368,15 @@ impl Action {
|
||||
&& self.full_maintenance()
|
||||
&& self.script_platform() == Some("windows")
|
||||
&& self.validate())
|
||||
|| (identity == "system"
|
||||
&& matches!(
|
||||
self,
|
||||
Self::Reboot {
|
||||
reconnect_timeout_seconds: crate::windows_reboot::RECONNECT_SECONDS,
|
||||
..
|
||||
}
|
||||
)
|
||||
&& self.validate())
|
||||
}
|
||||
pub fn full_maintenance(&self) -> bool {
|
||||
matches!(
|
||||
@@ -482,6 +491,19 @@ impl Action {
|
||||
update.predecessor.helper_sha256
|
||||
))
|
||||
}
|
||||
Self::Reboot {
|
||||
reconnect_timeout_seconds,
|
||||
..
|
||||
} if identity == "system" || has("windows.base/1") => {
|
||||
identity == "system"
|
||||
&& *reconnect_timeout_seconds == crate::windows_reboot::RECONNECT_SECONDS
|
||||
&& has("windows.base/1")
|
||||
&& !has("linux.base/1")
|
||||
&& has("rmm.sync.v1")
|
||||
&& has("helper.system.v1")
|
||||
&& has("system:reboot")
|
||||
&& has(crate::windows_reboot::CAPABILITY)
|
||||
}
|
||||
Self::RunScript {
|
||||
interpreter,
|
||||
windows_execution_profile,
|
||||
|
||||
@@ -7,7 +7,9 @@ pub mod inventory_document;
|
||||
pub mod jobs;
|
||||
pub mod reconciliation;
|
||||
pub mod windows_echo_probe;
|
||||
pub mod windows_reboot;
|
||||
pub mod windows_echo_completion;
|
||||
pub mod windows_sync_alignment;
|
||||
pub mod windows_execution;
|
||||
pub mod windows_sync_history;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//! The first Windows reboot capability is deliberately a fixed, separately
|
||||
//! enabled SYSTEM action. Existing Linux Reboot payload bytes are unchanged.
|
||||
use crate::jobs::{Action, JobPayload};
|
||||
pub const CAPABILITY: &str = "windows.reboot/1";
|
||||
pub const RECONNECT_SECONDS: u32 = 180;
|
||||
pub const RUNTIME_SECONDS: u32 = 60;
|
||||
pub const ANNOUNCEMENT_SECONDS: u32 = 5;
|
||||
pub fn supported(job: &JobPayload) -> bool {
|
||||
job.execution_identity == "system"
|
||||
&& job.max_runtime_seconds == RUNTIME_SECONDS
|
||||
&& (1..=65536).contains(&job.max_output_bytes)
|
||||
&& job.action.validate()
|
||||
&& matches!(
|
||||
job.action,
|
||||
Action::Reboot {
|
||||
reconnect_timeout_seconds: RECONNECT_SECONDS,
|
||||
..
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
//! Exact connection-205 administrative closure. Neither a lease nor job authority.
|
||||
use crate::{
|
||||
checkpoint_repair::{SignedDecision, inventory_sha256},
|
||||
jobs::hash,
|
||||
windows_echo_probe::{AGENT, ASSET, TENANT, TEST_PRINCIPAL},
|
||||
};
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
pub const DOMAIN: &str = "rmm.dev.windows-sync-admin-closed-alignment.v1";
|
||||
pub const FIRST: Uuid = Uuid::from_u128(0x1a4758ad0b39449e855116846851b09a);
|
||||
pub const SECOND: Uuid = Uuid::from_u128(0x2af359c55b5c4992b4451c00e271a288);
|
||||
pub const FIRST_REQUEST: Uuid = Uuid::from_u128(0x1f55d56f65b74e81bf8889c6765fe7a6);
|
||||
pub const SECOND_REQUEST: Uuid = Uuid::from_u128(0xed99c35576214846b8d03f534096eed4);
|
||||
pub const BOOT: Uuid = Uuid::from_u128(0xa9ad08955a968f2c8fb6cfdc2d5225ea);
|
||||
pub const ECHO_JOB: Uuid = Uuid::from_u128(0x645ad11b9ecd4efe8f928ad2fb6ed5cf);
|
||||
pub const ECHO_ATTEMPT: Uuid = Uuid::from_u128(0xe2ee25cd0e234c3caaa23048d232622a);
|
||||
pub const EXPIRED_JOB: Uuid = Uuid::from_u128(0x0a50aae9a7844535b62fef24c301d546);
|
||||
pub const EXPIRED_ATTEMPT: Uuid = Uuid::from_u128(0x78295f744565459a87b0641a8b95feec);
|
||||
pub const MAX_WITNESS_BYTES: usize = 768 * 1024;
|
||||
pub const FILE_ROLES: [&str; 6] = [
|
||||
"telemetry",
|
||||
"consumption",
|
||||
"agent_lock",
|
||||
"helper_ledger",
|
||||
"helper_lock",
|
||||
"system_intents",
|
||||
];
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct NativeFile {
|
||||
pub role: String,
|
||||
/// Independently measured BY_HANDLE_FILE_INFORMATION volume/high/low tuple.
|
||||
pub file_id: Option<[u32; 3]>,
|
||||
pub sha256: Option<String>,
|
||||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Counts {
|
||||
pub agent_jobs: u64,
|
||||
pub agent_consumed: u64,
|
||||
pub agent_starts: u64,
|
||||
pub agent_outcomes: u64,
|
||||
pub helper_consumed: u64,
|
||||
pub helper_starts: u64,
|
||||
pub helper_outcomes: u64,
|
||||
pub system_intents: u64,
|
||||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Witness {
|
||||
pub schema_version: u32,
|
||||
pub tenant_id: Uuid,
|
||||
pub asset_id: Uuid,
|
||||
pub agent_id: Uuid,
|
||||
pub enrollment_generation: u64,
|
||||
pub assignment_version: u64,
|
||||
pub boot_id: Uuid,
|
||||
pub connection_generation: u64,
|
||||
pub agent_journal_id: Uuid,
|
||||
pub helper_journal_id: Uuid,
|
||||
pub agent_checkpoint: u64,
|
||||
pub helper_checkpoint: u64,
|
||||
pub agent_last_decision: Uuid,
|
||||
pub helper_last_decision: Uuid,
|
||||
pub verification_key_id: String,
|
||||
pub verification_public_key_hex: String,
|
||||
pub binding_sha256: String,
|
||||
pub helper_binding_sha256: String,
|
||||
pub files: [NativeFile; 6],
|
||||
pub agent_inventory_sha256: String,
|
||||
pub consumption_inventory_sha256: String,
|
||||
pub helper_inventory_sha256: String,
|
||||
pub counts: Counts,
|
||||
pub original_requests: [Vec<u8>; 2],
|
||||
pub original_responses: [SignedDecision; 2],
|
||||
pub echo_offer: Vec<u8>,
|
||||
pub echo_start: Vec<u8>,
|
||||
pub echo_outcome: Vec<u8>,
|
||||
pub echo_result: Vec<u8>,
|
||||
pub echo_completion_receipt: Vec<u8>,
|
||||
pub expired_offer: Vec<u8>,
|
||||
}
|
||||
impl Witness {
|
||||
pub fn digest(&self) -> Option<String> {
|
||||
inventory_sha256(&serde_json::to_value(self).ok()?).ok()
|
||||
}
|
||||
pub fn valid(&self) -> bool {
|
||||
let digest = crate::agent_update::digest;
|
||||
self.schema_version == 1
|
||||
&& (self.tenant_id, self.asset_id, self.agent_id) == (TENANT, ASSET, AGENT)
|
||||
&& self.enrollment_generation == 1
|
||||
&& self.assignment_version == 1
|
||||
&& self.boot_id == BOOT
|
||||
&& self.connection_generation == 205
|
||||
&& !self.agent_journal_id.is_nil()
|
||||
&& !self.helper_journal_id.is_nil()
|
||||
&& self.agent_journal_id != self.helper_journal_id
|
||||
&& self.agent_checkpoint == 10137
|
||||
&& self.helper_checkpoint >= 148
|
||||
&& self.agent_last_decision == SECOND
|
||||
&& self.helper_last_decision == FIRST
|
||||
&& [
|
||||
&self.verification_key_id,
|
||||
&self.verification_public_key_hex,
|
||||
&self.binding_sha256,
|
||||
&self.helper_binding_sha256,
|
||||
&self.agent_inventory_sha256,
|
||||
&self.consumption_inventory_sha256,
|
||||
&self.helper_inventory_sha256,
|
||||
]
|
||||
.iter()
|
||||
.all(|h| digest(h))
|
||||
&& self.binding_sha256 == self.helper_binding_sha256
|
||||
&& hex::decode(&self.verification_public_key_hex)
|
||||
.is_ok_and(|k| hash(&k) == self.verification_key_id)
|
||||
&& self.files.iter().zip(FILE_ROLES).all(|(f, role)| {
|
||||
f.role == role
|
||||
&& match (&f.file_id, &f.sha256) {
|
||||
(Some(id), Some(h)) => *id != [0; 3] && digest(h),
|
||||
(None, None) => role == "system_intents",
|
||||
_ => false,
|
||||
}
|
||||
})
|
||||
&& self.counts
|
||||
== (Counts {
|
||||
agent_jobs: 2,
|
||||
agent_consumed: 1,
|
||||
agent_starts: 1,
|
||||
agent_outcomes: 1,
|
||||
helper_consumed: 0,
|
||||
helper_starts: 0,
|
||||
helper_outcomes: 0,
|
||||
system_intents: 0,
|
||||
})
|
||||
&& self
|
||||
.original_requests
|
||||
.iter()
|
||||
.all(|v| !v.is_empty() && v.len() <= 65536)
|
||||
&& self.original_responses.iter().all(|v| {
|
||||
!v.decision_bytes.is_empty()
|
||||
&& v.decision_bytes.len() <= 65536
|
||||
&& v.signature.len() == 64
|
||||
})
|
||||
&& [
|
||||
&self.echo_offer,
|
||||
&self.echo_start,
|
||||
&self.echo_outcome,
|
||||
&self.echo_result,
|
||||
&self.echo_completion_receipt,
|
||||
&self.expired_offer,
|
||||
]
|
||||
.iter()
|
||||
.all(|v| !v.is_empty() && v.len() <= 131072)
|
||||
&& serde_json::to_vec(self).is_ok_and(|v| v.len() <= MAX_WITNESS_BYTES)
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Receipt {
|
||||
pub domain: String,
|
||||
pub schema_version: u32,
|
||||
pub receipt_id: Uuid,
|
||||
pub request_id: Uuid,
|
||||
pub witness: Witness,
|
||||
pub witness_sha256: String,
|
||||
pub key_id: String,
|
||||
pub issued_at: DateTime<Utc>,
|
||||
pub valid_until: DateTime<Utc>,
|
||||
pub confirmed_by: String,
|
||||
pub approval_origin: String,
|
||||
pub testsimulation: bool,
|
||||
pub ready: bool,
|
||||
pub helper_ready: bool,
|
||||
pub unlock: bool,
|
||||
}
|
||||
impl Receipt {
|
||||
pub fn valid(&self, now: DateTime<Utc>) -> bool {
|
||||
self.domain == DOMAIN
|
||||
&& self.schema_version == 1
|
||||
&& !self.receipt_id.is_nil()
|
||||
&& !self.request_id.is_nil()
|
||||
&& self.receipt_id != self.request_id
|
||||
&& self.witness.valid()
|
||||
&& self.witness.digest().as_deref() == Some(self.witness_sha256.as_str())
|
||||
&& self.key_id == self.witness.verification_key_id
|
||||
&& self.confirmed_by == TEST_PRINCIPAL
|
||||
&& self.approval_origin == "dev_test_browser_simulation"
|
||||
&& self.testsimulation
|
||||
&& !self.ready
|
||||
&& !self.helper_ready
|
||||
&& !self.unlock
|
||||
&& self.issued_at <= now
|
||||
&& now < self.valid_until
|
||||
&& self.valid_until > self.issued_at
|
||||
&& self.valid_until - self.issued_at <= Duration::minutes(5)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
// Codec/profile fixture only: cryptographic original validation is independent.
|
||||
fn witness() -> Witness {
|
||||
Witness {
|
||||
schema_version: 1,
|
||||
tenant_id: TENANT,
|
||||
asset_id: ASSET,
|
||||
agent_id: AGENT,
|
||||
enrollment_generation: 1,
|
||||
assignment_version: 1,
|
||||
boot_id: BOOT,
|
||||
connection_generation: 205,
|
||||
agent_journal_id: Uuid::from_u128(1),
|
||||
helper_journal_id: Uuid::from_u128(2),
|
||||
agent_checkpoint: 10137,
|
||||
helper_checkpoint: 155,
|
||||
agent_last_decision: SECOND,
|
||||
helper_last_decision: FIRST,
|
||||
verification_key_id: hash(&[0; 32]),
|
||||
verification_public_key_hex: "00".repeat(32),
|
||||
binding_sha256: "ab".repeat(32),
|
||||
helper_binding_sha256: "ab".repeat(32),
|
||||
files: std::array::from_fn(|i| NativeFile {
|
||||
role: FILE_ROLES[i].into(),
|
||||
file_id: Some([1, i as u32 + 1, 1]),
|
||||
sha256: Some("cd".repeat(32)),
|
||||
}),
|
||||
agent_inventory_sha256: "ef".repeat(32),
|
||||
consumption_inventory_sha256: "12".repeat(32),
|
||||
helper_inventory_sha256: "34".repeat(32),
|
||||
counts: Counts {
|
||||
agent_jobs: 2,
|
||||
agent_consumed: 1,
|
||||
agent_starts: 1,
|
||||
agent_outcomes: 1,
|
||||
helper_consumed: 0,
|
||||
helper_starts: 0,
|
||||
helper_outcomes: 0,
|
||||
system_intents: 0,
|
||||
},
|
||||
original_requests: [vec![1], vec![2]],
|
||||
original_responses: std::array::from_fn(|_| SignedDecision {
|
||||
decision_bytes: vec![1],
|
||||
signature: vec![0; 64],
|
||||
}),
|
||||
echo_offer: vec![1],
|
||||
echo_start: vec![1],
|
||||
echo_outcome: vec![1],
|
||||
echo_result: vec![1],
|
||||
echo_completion_receipt: vec![1],
|
||||
expired_offer: vec![1],
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn closed_profile_never_accepts_new_consumption_stale_capture_or_other_incident() {
|
||||
let w = witness();
|
||||
assert!(w.valid());
|
||||
for mutation in 0..6 {
|
||||
let mut bad = w.clone();
|
||||
match mutation {
|
||||
0 => bad.connection_generation = 150,
|
||||
1 => bad.helper_checkpoint = 147,
|
||||
2 => bad.counts.helper_consumed = 1,
|
||||
3 => bad.counts.agent_jobs = 3,
|
||||
4 => bad.agent_last_decision = FIRST,
|
||||
_ => bad.files[0].file_id = None,
|
||||
};
|
||||
assert!(!bad.valid());
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn receipt_is_exactly_bounded_and_cannot_be_readiness_or_real_human_approval() {
|
||||
let w = witness();
|
||||
let now = Utc::now();
|
||||
let r = Receipt {
|
||||
domain: DOMAIN.into(),
|
||||
schema_version: 1,
|
||||
receipt_id: Uuid::from_u128(3),
|
||||
request_id: Uuid::from_u128(4),
|
||||
witness_sha256: w.digest().unwrap(),
|
||||
key_id: w.verification_key_id.clone(),
|
||||
witness: w,
|
||||
issued_at: now,
|
||||
valid_until: now + Duration::minutes(5),
|
||||
confirmed_by: TEST_PRINCIPAL.into(),
|
||||
approval_origin: "dev_test_browser_simulation".into(),
|
||||
testsimulation: true,
|
||||
ready: false,
|
||||
helper_ready: false,
|
||||
unlock: false,
|
||||
};
|
||||
assert!(r.valid(now));
|
||||
assert!(!r.valid(r.valid_until));
|
||||
assert!(!r.valid(now - Duration::nanoseconds(1)));
|
||||
for mutation in 0..7 {
|
||||
let mut bad = r.clone();
|
||||
match mutation {
|
||||
0 => bad.ready = true,
|
||||
1 => bad.helper_ready = true,
|
||||
2 => bad.unlock = true,
|
||||
3 => bad.testsimulation = false,
|
||||
4 => bad.valid_until += Duration::nanoseconds(1),
|
||||
5 => bad.confirmed_by = "Administrator".into(),
|
||||
_ => bad.witness.helper_checkpoint += 1,
|
||||
};
|
||||
assert!(!bad.valid(now));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user