Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/holger

holger-cli/tests/the_tool_carries_bundle_verify_and_agent.rs

//! **`holger-cli` is the one command-line tool** (lane HOL-PRODUCTS, owner 2026-10-30):
//! the airgap bundle's whole life (`bundle prepare|approve|finalize|inspect|extract`, and
//! the server's `bundle export|import`), the offline verifier (`verify`) and
//! the courier (`agent`) are its commands; `holger-bundle`, `holger-verify` and
//! `holger-agent` are no separate programs.

use std::process::Command;

fn help(args: &[&str]) -> String {
    let out = Command::new(env!("CARGO_BIN_EXE_holger-cli"))
        .args(args)
        .arg("--help")
        .output()
        .expect("holger-cli runs");
    assert!(
        out.status.success(),
        "holger-cli {args:?} --help failed:\n{}",
        String::from_utf8_lossy(&out.stderr)
    );
    String::from_utf8_lossy(&out.stdout).into_owned()
}

#[test]
fn bundle_carries_the_whole_life_of_a_bundle() {
    let h = help(&["bundle"]);
    for verb in [
        "prepare", "approve", "finalize", "inspect", "extract", "export", "import",
    ] {
        assert!(
            h.lines().any(|l| l.trim_start().starts_with(verb)),
            "`holger-cli bundle {verb}` is missing:\n{h}"
        );
    }
}

#[test]
fn verify_is_the_offline_verifier() {
    let h = help(&["verify"]);
    assert!(
        h.contains("--policy"),
        "`holger-cli verify` takes the trust policy:\n{h}"
    );
    let x = help(&["bundle", "extract"]);
    assert!(
        x.contains("--dest"),
        "`holger-cli bundle extract` verifies, then writes into a directory:\n{x}"
    );
}

#[test]
fn agent_is_the_courier() {
    let h = help(&["agent"]);
    assert!(h.to_lowercase().contains("usage"), "{h}");
    assert!(!h.trim().is_empty());
}

/// HOL-PRODUCTS-7: the server's signed invite for a downstream, written to a file the
/// downstream's RON names (`sync.upstreams[].invite`).
#[test]
fn downstream_invite_writes_the_servers_signed_invite() {
    let h = help(&["downstream", "invite"]);
    for flag in ["--name", "--door", "--out"] {
        assert!(
            h.contains(flag),
            "`holger-cli downstream invite` takes {flag}:\n{h}"
        );
    }
}