Watch
0
0
Fork
You've already forked hyperhive
0

swarm-controller: inject the account store so link-route tests use the fake

The seven linked-account handlers (matrix, forge and github link and
delete, and the list) read their store from `AppState::accounts` instead
of calling `store::connect()` themselves. In production that is
`Accounts::Live`, which still logs in to the swarm's secret store on
every request: a `SecretStore` holds a token it never renews, and a store
that is down at startup must fail only the requests made while it is
down.

Tests set `Accounts::Fake` over the in-memory `FakeStore`. The eight
handler tests that proved validation passed by expecting the store
connect to fail with 500 now assert that the write or delete landed in
the fake, and lose their `BAO_*`-must-be-unset guards: with `BAO_*` set
they no longer reach a real store.
This commit is contained in:
atlas 2026-10-04 08:03:05 +02:00
commit dceb803bca
5 changed files with 184 additions and 98 deletions

View file

@ -733,6 +733,8 @@ struct AppState {
/// find it unplaced. `tokio`'s mutex, unlike `jobq`'s: the read awaits
/// the queue.
create_gate: Arc<tokio::sync::Mutex<()>>,
/// The store the linked-account routes read and write.
accounts: linked_accounts::Accounts,
}
/// Env var the controller's NixOS module sets from
@ -2957,6 +2959,7 @@ async fn main() -> Result<()> {
auth,
forge: state_forge,
create_gate: Arc::default(),
accounts: linked_accounts::Accounts::Live,
};
let app = build_app(state);
@ -3129,6 +3132,7 @@ mod tests {
auth: None,
forge: None,
create_gate: std::sync::Arc::default(),
accounts: super::linked_accounts::Accounts::Fake(std::sync::Arc::default()),
};
(state, sched)
}