crates/monetize-shop-pairing/src/m4_tests.rs
//! ★ **A Holger front is fed the pay page its site row carries** (lane M4): the order's
//! `pay_page`, as Gunnar's console is fed its own (each by its facts' `billing`).
use super::*;
#[allow(unused_imports)]
use crate::test_fixtures::*;
fn order(pay_page: &str) -> LaidOrder {
serde_json::from_value(serde_json::json!({
"company": "acme", "apex": "test3.holger.rs", "domain": "",
"names": ["acme.test3.holger.rs"],
"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,
"pay_page": pay_page
}))
.unwrap()
}
#[test]
fn a_holger_estate_is_fed_the_pay_page_its_site_row_carries() {
let o = order("https://test3.holger.rs/private?renew=acme");
let f = shared_feed_for(
&holger(),
&o,
"acme-owner",
"ssh-ed25519 AAAA op",
"inviteinviteinvite",
)
.unwrap();
assert_eq!(
f.get(contract::FEED_BILLING_URL).map(String::as_str),
Some("https://test3.holger.rs/private?renew=acme")
);
// No pay page on the order: nothing made up.
let f = shared_feed_for(
&holger(),
&order(""),
"acme-owner",
"ssh-ed25519 AAAA op",
"inviteinviteinvite",
)
.unwrap();
assert!(!f.contains_key(contract::FEED_BILLING_URL), "{f:?}");
// Gunnar's console serves its own pay page, as it always did.
let f = shared_feed_for(
&gunnar(),
&o,
"acme-owner",
"ssh-ed25519 AAAA op",
"inviteinviteinvite",
)
.unwrap();
assert_eq!(
f.get(contract::FEED_BILLING_URL).map(String::as_str),
Some("https://acme.test3.holger.rs/billing/{tenant}")
);
}