49 lines
2.7 KiB
Rust
49 lines
2.7 KiB
Rust
//! Reproducible Rust-codec fixtures consumed directly by the WebUI tests.
|
|
use rmm_domain::jobs::*;
|
|
use serde_json::json;
|
|
use uuid::Uuid;
|
|
fn main() {
|
|
let cases = [
|
|
(
|
|
"legacy_linux_agent",
|
|
"agent_service",
|
|
"posix_sh",
|
|
"printf 'hello\\n'\n",
|
|
None,
|
|
None,
|
|
),
|
|
(
|
|
"linux_root_full",
|
|
"root",
|
|
"posix_sh",
|
|
"id\nprintf 'root stdout\\n'\nprintf 'root stderr\\n' >&2\n",
|
|
None,
|
|
Some(PrivilegedScriptProfile::FullMaintenanceV1),
|
|
),
|
|
(
|
|
"windows_system_full",
|
|
"system",
|
|
"powershell",
|
|
"Write-Output 'SYSTEM stdout'\r\n[Console]::Error.WriteLine('SYSTEM stderr')\r\n",
|
|
Some(WindowsExecutionProfile::PowerShell51RemoteSigned),
|
|
Some(PrivilegedScriptProfile::FullMaintenanceV1),
|
|
),
|
|
];
|
|
let values: Vec<_> = cases.into_iter().enumerate().map(|(index, (name, identity, interpreter, script, windows_execution_profile, privileged_script_profile))| {
|
|
let tenant = Uuid::from_u128(1);
|
|
let job = JobPayload {
|
|
schema_version: 1, tenant_id: tenant, asset_id: Uuid::from_u128(2), agent_id: Uuid::from_u128(3),
|
|
enrollment_generation: 1, assignment_version: 1, job_id: Uuid::from_u128(4+index as u128*10), attempt_id: Uuid::from_u128(5+index as u128*10),
|
|
action: Action::RunScript { interpreter: interpreter.into(), script_utf8: script.into(), arguments: vec![], expected_stdout: None, windows_execution_profile, privileged_script_profile },
|
|
execution_identity: identity.into(), not_before: "2026-11-14T12:00:00Z".parse().unwrap(), start_before: "2026-11-14T13:00:00Z".parse().unwrap(), max_runtime_seconds: 30, max_output_bytes: 4096,
|
|
};
|
|
let job_bytes = encode(&job).unwrap();
|
|
let job_hash = hash(&job_bytes);
|
|
let script_sha256 = hash(script.as_bytes());
|
|
let plan = PlanPayload { schema_version: 1, plan_id: Uuid::from_u128(6+index as u128*10), tenant_id: tenant, principal: "simulated-dev-script-console".into(), reason: format!("Codec fixture: {name}; no native execution"), jobs: vec![PlannedJob { payload: job, job_payload_hash: job_hash.clone(), script_sha256: Some(script_sha256.clone()) }], max_parallel: 1, halt_after_failures: 1, recipe_references: vec![], artifact_references: vec![] };
|
|
let bytes = encode(&plan).unwrap();
|
|
json!({"name":name,"plan_payload_bytes":bytes,"plan_hash":hash(&bytes),"job_payload_bytes":job_bytes,"job_payload_hash":job_hash,"script_sha256":script_sha256})
|
|
}).collect();
|
|
println!("{}", serde_json::to_string_pretty(&values).unwrap());
|
|
}
|