[control] Mark's UI decisions: Remote-Name shown with the proof, [ui] logout_url for Sign out, openssl signing files for the manual intermediate step, engine.not_ready, server sentences for the eight generic codes
This commit is contained in:
@@ -50,6 +50,11 @@ mod unix {
|
||||
|
||||
async fn env_with_pki() -> (Env, Offline) {
|
||||
let (root_pem, root_key) = pki::create_root(now()).unwrap();
|
||||
let env = env_with_root(&root_pem).await;
|
||||
(env, Offline { root_pem, root_key })
|
||||
}
|
||||
|
||||
async fn env_with_root(root_pem: &str) -> Env {
|
||||
// Only the root certificate goes next to control; the key stays in this test.
|
||||
let extra = |dir: &Path| {
|
||||
format!(
|
||||
@@ -58,12 +63,12 @@ mod unix {
|
||||
)
|
||||
};
|
||||
let mut env = Env::new(EnvSpec::default()).await;
|
||||
std::fs::write(env.dir.join("offline-root.crt"), &root_pem).unwrap();
|
||||
std::fs::write(env.dir.join("offline-root.crt"), root_pem).unwrap();
|
||||
std::fs::write(env.dir.join("creds/pki-password"), PASSWORD).unwrap();
|
||||
let text = std::fs::read_to_string(env.config_path()).unwrap() + &extra(&env.dir.join("."));
|
||||
std::fs::write(env.config_path(), text).unwrap();
|
||||
env.start_control(None);
|
||||
(env, Offline { root_pem, root_key })
|
||||
env
|
||||
}
|
||||
|
||||
async fn wait_request(env: &Env, id: &str, want: &str) -> Value {
|
||||
@@ -406,6 +411,90 @@ mod unix {
|
||||
assert!(!err.contains("PRIVATE KEY"), "{err}");
|
||||
}
|
||||
|
||||
/// The accepted manual step (Mark, 2026-11-07, Q6): the offline machine runs openssl.
|
||||
/// A root made with openssl signs control's CSR with the extensions file control serves,
|
||||
/// and control installs the result.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn an_intermediate_signed_with_openssl_is_installed() {
|
||||
let Some(openssl) = ianitor_testkit::proc::require_binary("openssl") else {
|
||||
return;
|
||||
};
|
||||
let off = ianitor_testkit::proc::TempDir::new("openssl-root");
|
||||
let run = |args: &[&str]| {
|
||||
let o = std::process::Command::new(&openssl)
|
||||
.args(args)
|
||||
.current_dir(off.join("."))
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
o.status.success(),
|
||||
"openssl {args:?}: {}",
|
||||
String::from_utf8_lossy(&o.stderr)
|
||||
);
|
||||
};
|
||||
run(&[
|
||||
"req",
|
||||
"-x509",
|
||||
"-new",
|
||||
"-newkey",
|
||||
"ec",
|
||||
"-pkeyopt",
|
||||
"ec_paramgen_curve:P-256",
|
||||
"-nodes",
|
||||
"-keyout",
|
||||
"domi-root.key",
|
||||
"-out",
|
||||
"domi-root.crt",
|
||||
"-days",
|
||||
"3653",
|
||||
"-subj",
|
||||
"/CN=Domi PKI Root/O=Fabrica Domi",
|
||||
"-addext",
|
||||
"basicConstraints=critical,CA:TRUE,pathlen:1",
|
||||
"-addext",
|
||||
"keyUsage=critical,keyCertSign,cRLSign",
|
||||
]);
|
||||
let root_pem = std::fs::read_to_string(off.join("domi-root.crt")).unwrap();
|
||||
let env = env_with_root(&root_pem).await;
|
||||
let r = env
|
||||
.call(
|
||||
"POST",
|
||||
"/api/v1/certs/intermediate/renewal",
|
||||
Some(json!({})),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(r.status, 202, "{}", r.text);
|
||||
let rid = r.json["request_id"].as_str().unwrap().to_owned();
|
||||
let base = r.json["file_base"].as_str().unwrap().to_owned();
|
||||
let cmd = r.json["approve_command"].as_str().unwrap().to_owned();
|
||||
assert!(cmd.starts_with("openssl x509 -req"), "{cmd}");
|
||||
std::fs::write(
|
||||
off.join(&format!("{base}.csr")),
|
||||
r.json["csr_pem"].as_str().unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let ext = env
|
||||
.call("GET", &format!("/api/v1/pki-requests/{rid}/ext"), None)
|
||||
.await;
|
||||
assert_eq!(ext.status, 200, "{}", ext.text);
|
||||
std::fs::write(off.join(&format!("{base}.ext")), &ext.text).unwrap();
|
||||
// Exactly the command control shows.
|
||||
let args: Vec<&str> = cmd.split_whitespace().skip(1).collect();
|
||||
run(&args);
|
||||
let signed = std::fs::read_to_string(off.join(&format!("{base}.crt"))).unwrap();
|
||||
let info = pki::inspect(&signed).unwrap();
|
||||
assert_eq!(info.path_len, Some(0));
|
||||
let r = env
|
||||
.call(
|
||||
"PUT",
|
||||
&format!("/api/v1/pki-requests/{rid}/certificate"),
|
||||
Some(json!({"certificate_pem": signed})),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(r.status, 200, "{}", r.text);
|
||||
assert_eq!(r.json["state"], "approved");
|
||||
}
|
||||
|
||||
fn walk(dir: &Path) -> Vec<std::path::PathBuf> {
|
||||
let mut out = Vec::new();
|
||||
let mut stack = vec![dir.to_path_buf()];
|
||||
|
||||
Reference in New Issue
Block a user