1use std::path::Path;
56use std::sync::{Mutex, OnceLock, RwLock};
57
58use nordisk_pairing::feedbus::{self, Feed};
59
60pub const FEED_SMTP_URL: &str = "secret.smtp_url";
63pub const FEED_SMTP_FROM: &str = "secret.smtp_from";
64
65pub const FEED_MONETIZE: &str = "monetize_pubkey";
67pub const FEED_CLOCK_KEY: &str = "clock_key";
68pub const FEED_CLOCK_PEER: &str = "clock_peer";
69pub const FEED_SSO_PRIVATE_IDP_CIDRS: &str = "sso_private_idp_cidrs";
74pub const FEED_SELLS_ROOM: &str = "sells_room";
78pub const FEED_FLEET: &str = "fleet";
82pub const FEED_FLEET_INSTANCE: &str = "fleet_instance";
84pub const FEED_FLEET_AT: &str = "fleet_at";
89pub const FEED_FLEET_CA: &str = "fleet_ca";
93
94pub const FEED_BILLING_URL: &str = "refusal_link";
99pub const FEED_REPAIR_AUTO: &str = "repair_auto";
103pub const FEED_REPAIR_KEY: &str = "secret.repair_key";
109
110pub const FEED_MISMATCH: &str = "pairing.feed_mismatch";
112pub const FEED_NOT_APPLIED: &str = "pairing.feed_not_applied";
116
117pub fn offered_by<'a>(feed: &'a std::collections::BTreeMap<String, String>, vm: &str, key: &str) -> Option<&'a str> {
119 feed.get(&format!("offer.{vm}.{key}")).map(|v| v.trim()).filter(|v| !v.is_empty())
120}
121
122#[derive(Debug, Clone, Default, PartialEq, Eq)]
124pub struct Fed {
125 pub monetize_pubkey: Option<String>,
126 pub clock_key: Option<String>,
127 pub clock_peer: Option<String>,
128 pub sso_private_idp_cidrs: Option<String>,
130 pub sells_room: bool,
132 pub fleet: Option<String>,
134 pub fleet_instance: Option<String>,
136 pub fleet_at: Option<String>,
138 pub fleet_ca: Option<String>,
140 pub smtp_url: Option<Withheld>,
143 pub smtp_from: Option<String>,
145 pub billing_url: Option<String>,
147 pub repair_auto: bool,
149 pub repair_key: Option<Withheld>,
151}
152
153#[derive(Clone, Default, PartialEq, Eq)]
155pub struct Withheld(pub String);
156
157impl std::fmt::Debug for Withheld {
158 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
159 f.write_str("<withheld>")
160 }
161}
162
163impl Fed {
164 pub fn from_feed(feed: &std::collections::BTreeMap<String, String>) -> Fed {
170 let get = |k: &str| feed.get(k).map(|v| v.trim().to_string()).filter(|v| !v.is_empty()).or_else(|| nordisk_pairing::feedbus::offered(feed, k));
171 Fed {
172 monetize_pubkey: get(FEED_MONETIZE),
173 clock_key: get(FEED_CLOCK_KEY),
174 clock_peer: get(FEED_CLOCK_PEER),
175 sso_private_idp_cidrs: get(FEED_SSO_PRIVATE_IDP_CIDRS),
176 sells_room: get(FEED_SELLS_ROOM).as_deref() == Some("true"),
177 fleet: get(FEED_FLEET),
178 fleet_instance: get(FEED_FLEET_INSTANCE),
179 fleet_at: get(FEED_FLEET_AT),
180 fleet_ca: get(FEED_FLEET_CA),
181 smtp_url: get(FEED_SMTP_URL).map(Withheld),
182 smtp_from: get(FEED_SMTP_FROM),
183 billing_url: get(FEED_BILLING_URL),
184 repair_auto: get(FEED_REPAIR_AUTO).as_deref() == Some("true"),
185 repair_key: get(FEED_REPAIR_KEY).map(Withheld),
186 }
187 }
188
189 pub fn is_empty(&self) -> bool {
190 self == &Fed::default()
191 }
192
193 pub fn read(root: &Path) -> anyhow::Result<Option<Fed>> {
197 Ok(kept_feed(root)?.as_ref().map(Fed::from_feed))
198 }
199
200 pub fn current() -> Option<Fed> {
203 feedbus::current().map(|feed| Fed::from_feed(&feed))
204 }
205}
206
207#[cfg(feature = "wg-client")]
209pub fn kept_feed(root: &Path) -> anyhow::Result<Option<Feed>> {
210 let p = root.join(crate::pairing::JOINED_REL);
211 let Some(text) = crate::fed_at_rest::read_checked(root, crate::pairing::JOINED_REL)? else { return Ok(None) };
212 let reply = nordisk_pairing::join::JoinReply::parse(&text).map_err(|e| anyhow::anyhow!("{}: {e}", p.display()))?;
213 Ok(Some(reply.feed))
214}
215
216#[cfg(not(feature = "wg-client"))]
218pub fn kept_feed(_root: &Path) -> anyhow::Result<Option<Feed>> {
219 Ok(None)
220}
221
222pub fn sso_private_nets(fed: Option<&Fed>) -> Result<gunnar_grpc::sso::PrivateNets, String> {
226 match fed.and_then(|f| f.sso_private_idp_cidrs.as_deref()) {
227 Some(text) => gunnar_grpc::sso::PrivateNets::parse(text).map_err(|why| format!("`{FEED_SSO_PRIVATE_IDP_CIDRS}`: {why}")),
228 None => Ok(gunnar_grpc::sso::PrivateNets::default()),
229 }
230}
231
232pub fn load_at_start(root: &Path) -> Option<Fed> {
236 match kept_feed(root) {
237 Ok(Some(feed)) => {
238 let fed = Fed::from_feed(&feed);
239 if !fed.is_empty() {
240 tracing::info!(monetize = fed.monetize_pubkey.is_some(), clock_peer = ?fed.clock_peer, clock_key = fed.clock_key.is_some(), "feed: the installer's values from {}", "<data>/pairing/joined.toml");
241 }
242 feedbus::publish(feed);
243 Some(fed)
244 }
245 Ok(None) => None,
246 Err(e) => {
247 tracing::error!(error = %format!("{e:#}"), "feed: the persisted join reply is unreadable — this start uses the medium's values only");
248 None
249 }
250 }
251}
252
253fn in_force_slot() -> &'static RwLock<Option<Option<[u8; 32]>>> {
259 static IN_FORCE: OnceLock<RwLock<Option<Option<[u8; 32]>>>> = OnceLock::new();
260 IN_FORCE.get_or_init(|| RwLock::new(None))
261}
262
263pub fn record_monetize_in_force(key: Option<[u8; 32]>) {
264 if let Ok(mut s) = in_force_slot().write() {
265 *s = Some(key);
266 }
267}
268
269pub fn monetize_in_force() -> Option<[u8; 32]> {
270 in_force_slot().read().ok().and_then(|s| s.flatten())
271}
272
273pub type MonetizeTaker = Box<dyn Fn(&[u8; 32]) -> Result<(), String> + Send + Sync>;
277
278fn takers() -> &'static Mutex<Vec<(&'static str, MonetizeTaker)>> {
279 static TAKERS: OnceLock<Mutex<Vec<(&'static str, MonetizeTaker)>>> = OnceLock::new();
280 TAKERS.get_or_init(|| Mutex::new(Vec::new()))
281}
282
283pub fn on_monetize_key(name: &'static str, take: MonetizeTaker) {
288 if let Ok(mut t) = takers().lock() {
289 t.push((name, take));
290 }
291}
292
293fn hex(k: &[u8; 32]) -> String {
294 k.iter().map(|b| format!("{b:02x}")).collect()
295}
296
297pub fn resolve_monetize(medium: Option<[u8; 32]>, fed: Option<&str>) -> Result<Option<[u8; 32]>, String> {
302 let fed = match fed {
303 None => return Ok(medium),
304 Some(text) => gunnar_common::monetize_key::parse_hex32(text.trim()).map_err(|why| {
305 format!("REFUSED [pairing-feed-monetize-malformed] the installer fed `{FEED_MONETIZE}` = `{text}`, which is not a monetize key: {why}")
306 })?,
307 };
308 match medium {
309 None => Ok(Some(fed)),
310 Some(m) if m == fed => Ok(Some(m)),
311 Some(m) => Err(format!(
312 "REFUSED [{FEED_MISMATCH}] the medium trusts monetize key {} and the installer's door fed {} — \
313 this box will not pick one silently. Compose the medium without `monetize_pubkey` (the door \
314 feeds it), or with the front's live key",
315 hex(&m),
316 hex(&fed)
317 )),
318 }
319}
320
321#[cfg(feature = "metered")]
330const NO_TAKER_WHY: &str = "the metered start opened no entitlement slot (no --billing-url on a `fed` medium)";
331#[cfg(not(feature = "metered"))]
332const NO_TAKER_WHY: &str = "this build carries no entitlement module, so no start opens a slot to take it";
333
334pub fn monetize_arrived(fed: Option<&str>) -> Option<MonetizeArrival> {
340 let in_force = in_force_slot().read().ok().and_then(|s| *s)?;
341 let fed = fed?;
342 match resolve_monetize(in_force, Some(fed)) {
343 Ok(Some(k)) if Some(k) == in_force => None,
344 Ok(Some(k)) => {
345 let takers = takers().lock().ok()?;
346 if takers.is_empty() {
347 let detail = format!(
348 "the installer fed monetize key {} and nothing on this box can enforce it: {NO_TAKER_WHY}",
349 hex(&k)
350 );
351 raise(FEED_NOT_APPLIED, &detail);
352 return Some(MonetizeArrival::NotApplied(detail));
353 }
354 let failed: Vec<String> = takers.iter().filter_map(|(name, take)| take(&k).err().map(|e| format!("{name}: {e}"))).collect();
355 if !failed.is_empty() {
356 let detail = format!("the installer fed monetize key {}, and it could not be applied: {}", hex(&k), failed.join("; "));
357 raise(FEED_NOT_APPLIED, &detail);
358 return Some(MonetizeArrival::NotApplied(detail));
359 }
360 record_monetize_in_force(Some(k));
361 let detail = format!("the installer fed monetize key {}; it is IN FORCE now (applied in place, no restart)", hex(&k));
362 tracing::info!(event = "pairing.feed_applied", "feed: {detail}");
363 Some(MonetizeArrival::Applied(detail))
364 }
365 Ok(None) => None,
366 Err(why) => {
367 raise(FEED_MISMATCH, &why);
368 Some(MonetizeArrival::Mismatch(why))
369 }
370 }
371}
372
373#[derive(Debug, Clone, PartialEq, Eq)]
374pub enum MonetizeArrival {
375 Applied(String),
377 NotApplied(String),
379 Mismatch(String),
381}
382
383pub use estate_clock::offer::resolve_clock;
390
391pub fn clock_config() -> Result<estate_clock::config::Config, String> {
397 use estate_clock::config::{var, Config, Role, CLOCK_ENV, CLOCK_KEY_ENV};
398 let env_clock = var(CLOCK_ENV);
399 let env_key = var(CLOCK_KEY_ENV);
400 let fed = Fed::current().unwrap_or_default();
401 let (clock, key) = resolve_clock(env_clock.as_deref(), env_key.as_deref(), fed.clock_peer.as_deref(), fed.clock_key.as_deref())?;
402 Config::parse(clock.as_deref(), key.as_deref(), Role::Appliance)
403}
404
405pub fn clock_fed() -> bool {
407 Fed::current().is_some_and(|f| f.clock_peer.is_some())
408}
409
410fn alarm_slot() -> &'static Mutex<Vec<gunnar_proto::HealthAlarm>> {
413 static ALARMS: OnceLock<Mutex<Vec<gunnar_proto::HealthAlarm>>> = OnceLock::new();
414 ALARMS.get_or_init(|| Mutex::new(Vec::new()))
415}
416
417pub fn raise(event: &str, detail: &str) {
419 tracing::error!(event, "feed: {detail}");
420 let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_millis() as i64).unwrap_or(0);
421 if let Ok(mut alarms) = alarm_slot().lock() {
422 match alarms.iter_mut().find(|a| a.event == event) {
423 Some(a) => {
424 a.count += 1;
425 a.detail = detail.to_string();
426 }
427 None => alarms.push(gunnar_proto::HealthAlarm { event: event.into(), count: 1, since_unix_ms: now, detail: detail.to_string() }),
428 }
429 }
430}
431
432pub fn alarms() -> Vec<gunnar_proto::HealthAlarm> {
434 alarm_slot().lock().map(|a| a.clone()).unwrap_or_default()
435}
436
437pub fn seam_refusal(at: Option<&str>, ca: bool) -> Option<String> {
443 const WORD: &str = "fleet-seam-bench-only";
444 match at {
445 None if ca => Some(format!(
446 "REFUSED [{WORD}] the installer fed `{}` with no `{}`: a door's own CA is a bench's, beside a bench address only — a public door is checked under the public roots",
447 crate::feed::FEED_FLEET_CA,
448 crate::feed::FEED_FLEET_AT
449 )),
450 None => None,
451 Some(at) => match at.trim().parse::<std::net::SocketAddr>() {
452 Ok(a) if bench_address(a.ip()) => None,
453 _ => Some(format!(
454 "REFUSED [{WORD}] the installer fed `{}` = {at}: the pull channel is dialled elsewhere than its door's name only on a bench (a private, loopback or link-local `ip:port`)",
455 crate::feed::FEED_FLEET_AT
456 )),
457 },
458 }
459}
460
461fn bench_address(ip: std::net::IpAddr) -> bool {
463 match ip {
464 std::net::IpAddr::V4(v) => v.is_private() || v.is_loopback() || v.is_link_local() || (v.octets()[0] == 100 && (v.octets()[1] & 0xc0) == 64),
465 std::net::IpAddr::V6(v) => v.is_loopback() || (v.segments()[0] & 0xfe00) == 0xfc00 || (v.segments()[0] & 0xffc0) == 0xfe80,
466 }
467}
468
469#[cfg(test)]
470mod tests {
471 use super::*;
472
473 #[test]
476 fn the_fed_relay_is_read_and_its_url_withheld() {
477 let feed: std::collections::BTreeMap<String, String> = [(FEED_SMTP_URL, "smtp://u:TOKENvalue@smtp.example:587"), (FEED_SMTP_FROM, "u@smtp.example")].iter().map(|(k, v)| (k.to_string(), v.to_string())).collect();
478 let f = Fed::from_feed(&feed);
479 assert_eq!(f.smtp_url, Some(Withheld("smtp://u:TOKENvalue@smtp.example:587".into())));
480 assert_eq!(f.smtp_from.as_deref(), Some("u@smtp.example"));
481 assert!(!format!("{f:?}").contains("TOKENvalue"), "{f:?}");
482 assert!(Fed::from_feed(&Default::default()).smtp_url.is_none());
483 }
484
485 const A: &str = "43cb00000000000000000000000000000000000000000000000000000000842a";
486 const B: &str = "43cb00000000000000000000000000000000000000000000000000000000842b";
487
488 fn k(s: &str) -> [u8; 32] {
489 gunnar_common::monetize_key::parse_hex32(s).unwrap()
490 }
491
492 #[test]
495 fn a_value_offered_by_a_vm_is_taken_when_the_installer_feeds_none_itself() {
496 let feed = |pairs: &[(&str, &str)]| pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect::<std::collections::BTreeMap<_, _>>();
497 let f = Fed::from_feed(&feed(&[("offer.front.monetize_pubkey", A), ("offer.front.clock_key", "ssh-ed25519 AAAAk"), ("clock_peer", "peer://10.13.8.1:50123"), ("offer.front.xmonetize_pubkey", B)]));
498 assert_eq!(f, Fed { monetize_pubkey: Some(A.into()), clock_key: Some("ssh-ed25519 AAAAk".into()), clock_peer: Some("peer://10.13.8.1:50123".into()), ..Fed::default() });
499 assert_eq!(Fed::from_feed(&feed(&[(FEED_MONETIZE, B), ("offer.front.monetize_pubkey", A)])).monetize_pubkey.as_deref(), Some(B), "the plain key wins");
500 assert_eq!(nordisk_pairing::feedbus::offered(&feed(&[("offer..monetize_pubkey", A), ("offer.a.b.monetize_pubkey", A)]), FEED_MONETIZE), None, "not a VM name");
501 }
502
503 #[test]
506 fn the_fleet_door_and_the_estate_are_taken_from_the_feed_or_the_fronts_offer() {
507 let feed = |pairs: &[(&str, &str)]| pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect::<std::collections::BTreeMap<_, _>>();
508 let f = Fed::from_feed(&feed(&[("offer.front.fleet", "https://monetize.ignalina.dk:8443"), ("offer.front.fleet_instance", "acme"), ("offer.front.monetize_pubkey", A)]));
509 assert_eq!((f.fleet.as_deref(), f.fleet_instance.as_deref(), f.monetize_pubkey.as_deref()), (Some("https://monetize.ignalina.dk:8443"), Some("acme"), Some(A)));
510 let f = Fed::from_feed(&feed(&[(FEED_FLEET, "https://one:8443"), ("offer.front.fleet", "https://other:8443"), (FEED_FLEET_INSTANCE, " "), ("offer.front.fleet_instance", "acme")]));
511 assert_eq!((f.fleet.as_deref(), f.fleet_instance.as_deref()), (Some("https://one:8443"), Some("acme")), "the plain key wins; blank is absent");
512 assert!(Fed::from_feed(&feed(&[])).fleet.is_none());
513 }
514
515 #[test]
518 fn sells_room_is_fed_as_exactly_true() {
519 let feed = |pairs: &[(&str, &str)]| pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect::<std::collections::BTreeMap<_, _>>();
520 assert!(Fed::from_feed(&feed(&[(FEED_SELLS_ROOM, "true")])).sells_room);
521 assert!(Fed::from_feed(&feed(&[(FEED_SELLS_ROOM, " true\n")])).sells_room, "trimmed, as fed");
522 assert!(!Fed::from_feed(&feed(&[(FEED_SELLS_ROOM, "yes")])).sells_room);
523 assert!(!Fed::from_feed(&feed(&[])).sells_room, "a sold estate is fed nothing");
524 }
525
526 #[test]
529 fn the_sites_pay_page_is_read_from_the_feed() {
530 let feed = |pairs: &[(&str, &str)]| pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect::<std::collections::BTreeMap<_, _>>();
531 assert_eq!(FEED_BILLING_URL, "refusal_link");
532 assert_eq!(Fed::from_feed(&feed(&[(FEED_BILLING_URL, " https://test2.gunnar.rs/billing/{tenant}\n")])).billing_url.as_deref(), Some("https://test2.gunnar.rs/billing/{tenant}"));
533 assert_eq!(Fed::from_feed(&feed(&[(FEED_BILLING_URL, " ")])).billing_url, None);
534 assert_eq!(Fed::from_feed(&feed(&[])).billing_url, None);
535 }
536
537 #[test]
542 fn the_operators_idp_networks_are_fed_and_applied_live() {
543 let feed = |pairs: &[(&str, &str)]| pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect::<std::collections::BTreeMap<_, _>>();
544 let fed = Fed::from_feed(&feed(&[(FEED_SSO_PRIVATE_IDP_CIDRS, " 10.0.2.100/32 ")]));
545 assert_eq!(fed.sso_private_idp_cidrs.as_deref(), Some("10.0.2.100/32"));
546 assert_eq!(sso_private_nets(Some(&fed)).expect("a private network").to_string(), "10.0.2.100/32");
547 assert!(sso_private_nets(None).expect("nothing fed").is_empty());
548 let public = Fed::from_feed(&feed(&[(FEED_SSO_PRIVATE_IDP_CIDRS, "8.8.8.0/24")]));
549 assert!(sso_private_nets(Some(&public)).is_err(), "a public range is refused");
550 let seen = std::sync::Arc::new(Mutex::new(Vec::<String>::new()));
551 let into = std::sync::Arc::clone(&seen);
552 feedbus::on_published("test: the idp networks", move |f: &Feed| into.lock().unwrap().push(Fed::from_feed(f).sso_private_idp_cidrs.clone().unwrap_or_default()));
553 feedbus::publish(feed(&[(FEED_SSO_PRIVATE_IDP_CIDRS, " 10.0.2.100/32 ")]));
554 feedbus::publish(feed(&[]));
555 let got = seen.lock().unwrap().clone();
556 let at = got.iter().position(|v| v == "10.0.2.100/32").expect("the list reached the taker");
557 assert!(got[at + 1..].iter().any(String::is_empty), "every publish reaches the taker: {got:?}");
558 }
559
560 #[test]
563 fn an_offer_is_read_from_the_named_vm_not_the_first_by_name() {
564 let feed: std::collections::BTreeMap<String, String> = [("offer.vm2.ticket_pubkey", A), ("offer.vm3.ticket_pubkey", B), ("offer.vm4.ticket_pubkey", " ")].iter().map(|(k, v)| (k.to_string(), v.to_string())).collect();
565 assert_eq!(nordisk_pairing::feedbus::offered(&feed, "ticket_pubkey").as_deref(), Some(A), "the first by name");
566 assert_eq!(offered_by(&feed, "vm3", "ticket_pubkey"), Some(B), "the primary's own");
567 assert_eq!(offered_by(&feed, "vm4", "ticket_pubkey"), None, "blank is absent");
568 assert_eq!(offered_by(&feed, "vm9", "ticket_pubkey"), None);
569 }
570
571 #[test]
572 fn monetize_door_alone_medium_alone_and_equal_are_taken() {
573 assert_eq!(resolve_monetize(None, Some(A)), Ok(Some(k(A))), "one medium, any estate: the door's key");
574 assert_eq!(resolve_monetize(Some(k(A)), None), Ok(Some(k(A))), "no feed: today's behaviour");
575 assert_eq!(resolve_monetize(Some(k(A)), Some(A)), Ok(Some(k(A))));
576 assert_eq!(resolve_monetize(None, None), Ok(None), "a metered build with no key from either source: today's behaviour");
577 }
578
579 #[test]
580 fn monetize_medium_and_a_different_door_key_is_refused_by_name() {
581 let why = resolve_monetize(Some(k(A)), Some(B)).unwrap_err();
582 assert!(why.contains(&format!("[{FEED_MISMATCH}]")) && why.contains(A) && why.contains(B), "{why}");
583 let why = resolve_monetize(None, Some("not-a-key")).unwrap_err();
584 assert!(why.contains("[pairing-feed-monetize-malformed]"), "{why}");
585 }
586
587 #[test]
588 fn the_feed_table_reads_the_contract_keys_and_blank_is_absent() {
589 let mut feed = std::collections::BTreeMap::new();
590 feed.insert(FEED_MONETIZE.to_string(), A.to_string());
591 feed.insert(FEED_CLOCK_PEER.to_string(), "peer://10.13.8.179:50123".to_string());
592 feed.insert(FEED_CLOCK_KEY.to_string(), " ".to_string());
593 feed.insert("admin_pubkey".to_string(), "ssh-ed25519 AAAAconsole".to_string());
594 let fed = Fed::from_feed(&feed);
595 assert_eq!(fed, Fed { monetize_pubkey: Some(A.into()), clock_key: None, clock_peer: Some("peer://10.13.8.179:50123".into()), ..Fed::default() });
596 }
597
598 #[cfg(feature = "wg-client")]
599 #[test]
600 fn a_persisted_join_reply_is_read_back_and_absent_is_none() {
601 let dir = std::env::temp_dir().join(format!("gunnar-feed-{}", std::process::id()));
602 let _ = std::fs::create_dir_all(dir.join("pairing"));
603 assert_eq!(Fed::read(&dir.join("nowhere")).unwrap(), None);
604 let mut feed = std::collections::BTreeMap::new();
605 feed.insert(FEED_MONETIZE.to_string(), A.to_string());
606 feed.insert(FEED_CLOCK_KEY.to_string(), "ssh-ed25519 AAAAk".to_string());
607 let reply = nordisk_pairing::join::JoinReply {
608 estate: "gunnar.rs".into(),
609 me: nordisk_pairing::join::Assigned { name: "main".into(), overlay: nordisk_pairing::OVERLAY_BOX_A },
610 cert_pem: None,
611 role: None,
612 primary_overlay: None,
613 primary_utility: None,
614 peers: vec![],
615 feed,
616 };
617 std::fs::write(dir.join(crate::pairing::JOINED_REL), reply.render().unwrap()).unwrap();
618 let fed = Fed::read(&dir).unwrap().unwrap();
619 assert_eq!(fed.monetize_pubkey.as_deref(), Some(A));
620 assert_eq!(fed.clock_key.as_deref(), Some("ssh-ed25519 AAAAk"));
621 let _ = std::fs::remove_dir_all(&dir);
622 }
623}