102 lines
3.8 KiB
Rust
102 lines
3.8 KiB
Rust
use std::process::Command;
|
|
|
|
fn multi_rir_bundle_root() -> std::path::PathBuf {
|
|
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../rpki/target/live/20260316-112341-multi-final3")
|
|
}
|
|
|
|
fn helper_script() -> std::path::PathBuf {
|
|
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("scripts/payload_replay/multi_rir_case_info.py")
|
|
}
|
|
|
|
fn wrapper_script() -> std::path::PathBuf {
|
|
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
|
.join("scripts/payload_replay/run_multi_rir_replay_case.sh")
|
|
}
|
|
|
|
#[test]
|
|
fn multi_rir_case_info_resolves_all_five_rirs_and_timings() {
|
|
let bundle_root = multi_rir_bundle_root();
|
|
assert!(bundle_root.is_dir(), "bundle root missing: {}", bundle_root.display());
|
|
|
|
let expected = [
|
|
("afrinic", "afrinic", "afrinic.tal", "afrinic-ta.cer"),
|
|
("apnic", "apnic", "apnic-rfc7730-https.tal", "apnic-ta.cer"),
|
|
("arin", "arin", "arin.tal", "arin-ta.cer"),
|
|
("lacnic", "lacnic", "lacnic.tal", "lacnic-ta.cer"),
|
|
("ripe", "ripe", "ripe-ncc.tal", "ripe-ncc-ta.cer"),
|
|
];
|
|
|
|
for (rir, trust_anchor, tal_suffix, ta_suffix) in expected {
|
|
let out = Command::new("python3")
|
|
.arg(helper_script())
|
|
.args([
|
|
"--bundle-root",
|
|
bundle_root.to_string_lossy().as_ref(),
|
|
"--rir",
|
|
rir,
|
|
])
|
|
.output()
|
|
.expect("run helper script");
|
|
|
|
assert!(
|
|
out.status.success(),
|
|
"helper failed for {rir}: status={}\nstdout={}\nstderr={}",
|
|
out.status,
|
|
String::from_utf8_lossy(&out.stdout),
|
|
String::from_utf8_lossy(&out.stderr)
|
|
);
|
|
|
|
let json: serde_json::Value =
|
|
serde_json::from_slice(&out.stdout).expect("parse helper json");
|
|
assert_eq!(json["rir"].as_str(), Some(rir));
|
|
assert_eq!(json["trust_anchor"].as_str(), Some(trust_anchor));
|
|
assert!(json["base_archive"].as_str().unwrap_or("").ends_with("base-payload-archive"));
|
|
assert!(json["delta_archive"].as_str().unwrap_or("").ends_with("payload-delta-archive"));
|
|
assert!(json["base_locks"].as_str().unwrap_or("").ends_with("base-locks.json"));
|
|
assert!(json["delta_locks"].as_str().unwrap_or("").ends_with("locks-delta.json"));
|
|
assert!(json["tal_path"].as_str().unwrap_or("").ends_with(tal_suffix));
|
|
assert!(json["ta_path"].as_str().unwrap_or("").ends_with(ta_suffix));
|
|
assert!(json["validation_times"]["snapshot"].as_str().unwrap_or("").contains("T"));
|
|
assert!(json["validation_times"]["delta"].as_str().unwrap_or("").contains("T"));
|
|
assert!(json["routinator_timings"]["base_replay_seconds"]
|
|
.as_f64()
|
|
.unwrap_or(0.0)
|
|
> 0.0);
|
|
assert!(json["routinator_timings"]["delta_replay_seconds"]
|
|
.as_f64()
|
|
.unwrap_or(0.0)
|
|
> 0.0);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn multi_rir_wrapper_describe_mode_works_for_ripe() {
|
|
let bundle_root = multi_rir_bundle_root();
|
|
assert!(bundle_root.is_dir(), "bundle root missing: {}", bundle_root.display());
|
|
|
|
let out = Command::new(wrapper_script())
|
|
.env("BUNDLE_ROOT", &bundle_root)
|
|
.args(["ripe", "describe"])
|
|
.output()
|
|
.expect("run wrapper script");
|
|
|
|
assert!(
|
|
out.status.success(),
|
|
"wrapper failed: status={}\nstdout={}\nstderr={}",
|
|
out.status,
|
|
String::from_utf8_lossy(&out.stdout),
|
|
String::from_utf8_lossy(&out.stderr)
|
|
);
|
|
|
|
let json: serde_json::Value =
|
|
serde_json::from_slice(&out.stdout).expect("parse wrapper describe json");
|
|
assert_eq!(json["rir"].as_str(), Some("ripe"));
|
|
assert_eq!(json["trust_anchor"].as_str(), Some("ripe"));
|
|
assert!(json["verification_json"]
|
|
.as_str()
|
|
.unwrap_or("")
|
|
.ends_with("verification.json"));
|
|
}
|