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

nordisk/holger

holger-estate-front/tests/shop_pairing_contract.rs

//! ★ **The ONE shop's install feed is what a Holger estate reads** (2026-10-18): the feed
//! monetize-shop-pairing writes for a SOLD Holger front (its HOLGER contract) carries the shop
//! door this front's SoldEstate client takes (`shop_door.toml`, `secret.shop_client_key`) and
//! the ONE monetize's words it relays to every box (`fleet`, `fleet_instance`,
//! `monetize_pubkey`), which a box's pull channel reads as `offer.<front>.<key>` (holger-fleet
//! `config::FleetConfig::from_feed`, the names gunnar-server `feed.rs` reads). Held equal here,
//! dev-dependencies only: nothing of the shop ships in the front.

#![cfg(feature = "metered")]

use std::collections::BTreeMap;

use holger_estate_front::front::relayed;
use holger_estate_front::shop_door::ShopDoor;

fn order() -> monetize_server::estate_order::LaidOrder {
    serde_json::from_value(serde_json::json!({
        "company": "acme", "apex": "holger.rs", "domain": "",
        "names": ["acme.holger.rs"],
        "shop_door": "https://monetize.ignalina.dk",
        "monetize_pubkey": "ab".repeat(32),
        "estate": {"reference": "estate/acme", "company": "acme", "zone": "se-sto1", "machines": [
            {"role": "front", "hostname": "f", "title": "f", "plan": "STARTER-4xCPU-8GB", "server": "s1", "public_ipv4": "198.51.100.1", "utility_ipv4": "10.6.0.1", "disks": []},
            {"role": "main", "hostname": "m", "title": "m", "plan": "STARTER-4xCPU-16GB", "server": "s2", "public_ipv4": "198.51.100.2", "utility_ipv4": "10.6.0.2", "disks": []},
            {"role": "twin", "hostname": "t", "title": "t", "plan": "STARTER-1xCPU-2GB", "server": "s3", "public_ipv4": "198.51.100.3", "utility_ipv4": "10.6.0.3", "disks": []}
        ]},
        "first_login_ttl_secs": 604800
    }))
    .unwrap()
}

#[test]
fn the_shops_holger_front_feed_names_the_shop_door_and_what_every_box_pulls_from() {
    let dir = tempfile::tempdir().unwrap();
    std::fs::write(dir.path().join("console-admin-token"), "aa".repeat(16)).unwrap();
    std::fs::write(dir.path().join("estate-client.key"), "cd".repeat(32)).unwrap();
    let f = monetize_shop_pairing::front_feed_for(
        &monetize_shop_pairing::ProductContract::of(&holger_monetize_guest::lifecycle()).unwrap(),
        &BTreeMap::new(),
        &order(),
        dir.path(),
    )
    .expect("the shop feeds a Holger front");

    let door = ShopDoor::from_feed(&f)
        .expect("a sold front is fed a shop door")
        .expect("and it is usable");
    assert_eq!(
        (door.door.as_str(), door.company.as_str()),
        ("https://monetize.ignalina.dk", "acme")
    );

    let r = relayed(&f);
    assert_eq!(
        r.get("fleet").map(String::as_str),
        Some("https://monetize.ignalina.dk"),
        "{r:?}"
    );
    assert_eq!(r.get("fleet_instance").map(String::as_str), Some("acme"));
    assert_eq!(r.get("monetize_pubkey"), Some(&"ab".repeat(32)));
    assert!(
        r.keys().all(|k| !k.starts_with("secret.")),
        "the front relays no secret to the boxes"
    );
}

/// ★ Lane M4: the shop feeds every box of a Holger estate its pay page (`refusal_link`, the
/// site row's renewal page, as Gunnar's boxes are fed theirs), which a paid refusal names.
#[test]
fn the_shop_feeds_every_holger_box_its_pay_page() {
    let mut o = order();
    o.pay_page = "https://holger.rs/private?renew=acme".into();
    let f = monetize_shop_pairing::shared_feed_for(
        &monetize_shop_pairing::ProductContract::of(&holger_monetize_guest::lifecycle()).unwrap(),
        &o,
        "acme-owner",
        "ssh-ed25519 AAAA op",
        "invite-invite",
    )
    .expect("the shop's estate feed");
    assert_eq!(
        f.get("refusal_link").map(String::as_str),
        Some("https://holger.rs/private?renew=acme"),
        "{f:?}"
    );
}

/// ★ **HOL-REPO-NAME: a shop-laid Holger front routes and certifies `repo.<site>`** (measured
/// 2026-10-31: repo.test2.holger.rs and repo.holger.rs had no record of the lay's and no name on
/// the front's certificate, though every client is sent to `https://repo.<site>/…`). Holger's
/// OWN facts (its guest's `names` and `repo_names`) through the shop's front feed, with no sale
/// feed key: the name is on the certificate (`web_hosts`), and this front's route carries it to
/// the primary's repository HTTP and gRPC, nothing refused.
#[test]
fn a_shop_laid_holger_front_routes_and_certifies_repo_of_its_site() {
    use holger_estate_front as front;
    let dir = tempfile::tempdir().unwrap();
    std::fs::write(dir.path().join("console-admin-token"), "aa".repeat(16)).unwrap();
    std::fs::write(dir.path().join("estate-client.key"), "cd".repeat(32)).unwrap();
    let mut o = order();
    o.names = [
        "acme.holger.rs",
        "www.acme.holger.rs",
        "repo.acme.holger.rs",
    ]
    .map(String::from)
    .to_vec();
    let c =
        monetize_shop_pairing::ProductContract::of(&holger_monetize_guest::lifecycle()).unwrap();
    let f = monetize_shop_pairing::front_feed_for(&c, &BTreeMap::new(), &o, dir.path())
        .expect("the shop feeds a Holger front");
    let web = estate_front::web::WebConfig::from("acme.holger.rs", &f);
    assert_eq!(
        web.hosts,
        [
            "acme.holger.rs",
            "www.acme.holger.rs",
            "repo.acme.holger.rs"
        ],
        "repo.<site> is on the certificate"
    );
    assert!(
        web.callback_only.is_empty(),
        "Holger redirects no served name"
    );
    let route = estate_front::route::RepoRoute::of(
        &f,
        &web,
        front::PRODUCT,
        Some((front::HTTP_PORT, front::CONTROL_PORT)),
        front::CARRIED_GRPC,
    );
    assert_eq!(
        route.hosts,
        ["repo.acme.holger.rs"],
        "routed to the primary"
    );
    assert!(route.refused.is_empty(), "{:?}", route.refused);
}