holger-front/tests/release_signing.rs
//! **Release signing on holger.rs** (owner 2026-10-29): the front page names the key
//! Holger's releases are signed with (the owner's YubiKey key, P-256, attested on the
//! device) by its key id, and links to `slsa/` in the holger and gunnar repositories.
//! The id lives in ONE place, `holger_front::RELEASE_KEY_ID`; the page template carries
//! only a slot that the door fills.
use holger_front::{
page, release_signing_html, route, Catalogue, Doors, Front, GUNNAR_SLSA_URL, HOLGER_SLSA_URL,
PAGE, RELEASE_KEY_ID, RELEASE_SIGNING_SLOT,
};
const OWNER_KEY_ID: &str = "d24d3785e8281bcd37e8f2c40a3a85e8152d3ce2200a5c929a1a5ca636e8249e";
#[test]
fn the_key_id_is_the_owners_yubikey_key() {
assert_eq!(RELEASE_KEY_ID, OWNER_KEY_ID);
assert_eq!(
HOLGER_SLSA_URL,
"https://gunnar.rs/nordisk/holger/tree/slsa"
);
assert_eq!(
GUNNAR_SLSA_URL,
"https://gunnar.rs/nordisk/gunnar/tree/slsa"
);
}
#[test]
fn the_served_page_says_how_releases_are_signed() {
let f = Front::anonymous(Some("https://holger.rs".into()));
let c = Catalogue::default();
let reply = route(
"GET",
"/",
&Doors {
front: &f,
catalogue: &c,
},
)
.unwrap();
let body = String::from_utf8(reply.body).unwrap();
assert_eq!(body, page());
assert!(body.contains("Release signing"), "{body}");
assert!(body.contains(&format!("<code>{OWNER_KEY_ID}</code>")));
assert!(body.contains("YubiKey") && body.contains("P-256") && body.contains("attestation"));
assert!(body.contains(&format!("href=\"{HOLGER_SLSA_URL}\"")));
assert!(body.contains(&format!("href=\"{GUNNAR_SLSA_URL}\"")));
assert!(!body.contains(RELEASE_SIGNING_SLOT), "the slot is filled");
}
/// The page is the template with its one slot filled, and nothing else changed: the
/// template's own guards (no other product named, no price) still hold for every word
/// the page author wrote.
#[test]
fn the_page_is_the_template_with_the_slot_filled() {
assert_eq!(PAGE.matches(RELEASE_SIGNING_SLOT).count(), 1);
assert_eq!(
page(),
PAGE.replace(RELEASE_SIGNING_SLOT, &release_signing_html())
);
}
/// The id is written once in the crate's sources and assets.
#[test]
fn the_key_id_is_written_in_one_place() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
let mut hits = Vec::new();
for dir in ["src", "assets"] {
for e in std::fs::read_dir(root.join(dir)).unwrap() {
let p = e.unwrap().path();
let Ok(text) = std::fs::read_to_string(&p) else {
continue;
};
for _ in text.matches(OWNER_KEY_ID) {
hits.push(p.display().to_string());
}
}
}
assert_eq!(hits.len(), 1, "{hits:?}");
assert!(hits[0].ends_with("lib.rs"), "{hits:?}");
}