pitboard-core 0.21.1

The engine behind Pitboard: switches Claude Code, Codex and Claude Desktop between accounts by parking and restoring their logins. Its API serves Pitboard's own front ends.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
//! Pitboard's parked logins on Linux as items of the Secret Service, the store the session's
//! keyring serves on its bus: gnome-keyring, KDE's ksecretd or oo7. One item per park, in the
//! collection the `default` alias names, which every home of the session shares, as every home
//! on a Mac shares the login keychain.
//!
//! Spoken through `secret-service`, a DH session over zbus 5's blocking API, one connection
//! for each question, on the session's bus as `bus::session` finds it. Read in the Secret
//! Service API 0.2 draft and measured with gnome-keyring 48.0 (`docs/facts/linux.md`).
//!
//! The collection is named for what answers for it, by the names its connection holds: KWallet
//! where KDE's daemon does, and the login keyring otherwise. A collection's label is the
//! person's to change, and gnome-keyring's is translated.
//!
//! A locked collection, a prompt dismissed and nothing on the bus to answer say nothing of what
//! the collection holds, so each is `Locked`, never a collection with nothing in it: a keyring
//! locked since its daemon started answers every search with nothing. A run the schedule or the
//! watch service started never asks to unlock it, since nobody is there to answer. A run a person
//! started asks, as `secret-tool` does, only in the desktop session: secret-service waits for a
//! prompt's answer with no bound, and the prompter puts its dialog on the desktop's display, which
//! a run over SSH or with no display is not in front of.

use super::bus;
use crate::context::Context;
use crate::host::Keyring;
use crate::permit::Permit;
use crate::schedule::Job;
use crate::store::{Backend, Error, RawStore};
use ::secret_service::EncryptionType;
use ::secret_service::blocking::{Collection, Item, SecretService};
use std::collections::HashMap;

// libsecret's attribute for an item's schema, which `secret-tool` and Seahorse read.
const SCHEMA: (&str, &str) = ("xdg:schema", "com.usepitboard.Pitboard.Park");
const SERVICE: &str = "service";
const LABEL: &str = "Pitboard parked login";
// What it holds; gnome-keyring 48.0 reads it back as `text/plain`, so nothing is told by it.
const CONTENT_TYPE: &str = "application/json";
// What a provider answers for a collection or an item it keeps locked, and the bus where nothing
// owns `org.freedesktop.secrets`.
const LOCKED: [&str; 3] = [
    "org.freedesktop.Secret.Error.IsLocked",
    "org.freedesktop.DBus.Error.ServiceUnknown",
    "org.freedesktop.DBus.Error.NameHasNoOwner",
];

const SECRETS: &str = "org.freedesktop.secrets";
// What KWallet's daemon takes beside SECRETS on its one connection: ksecretd at kwallet 6.31.0,
// kwalletd6 and kwalletd5 at 6.13.0 (docs/facts/linux.md, The Secret Service).
const KWALLET: [&str; 4] = [
    "org.kde.ksecretd",
    "org.kde.secretservicecompat",
    "org.kde.kwalletd6",
    "org.kde.kwalletd5",
];

/// The parks every home of this session keeps in the Secret Service.
pub(super) struct Vault {
    ctx: Context,
    // Whether a person started this run in the desktop session, where they can answer the
    // provider's unlock prompt.
    asks: bool,
}

impl Vault {
    pub(super) fn of(ctx: &Context) -> Vault {
        let started_by_a_job = [Job::Renew, Job::Watch]
            .into_iter()
            .any(|job| crate::schedule::started_this_run(ctx, job));
        Vault {
            ctx: ctx.clone(),
            asks: !started_by_a_job && ctx.in_the_desktop_session(),
        }
    }

    // What `then` makes of the default collection, unlocked first, a failure said as `otherwise`
    // says one. Asked again after, since one locked meanwhile answers a search with nothing. A
    // person who dismissed the prompt has answered for the run, so it is not put up again.
    fn open<T>(
        &self,
        otherwise: fn(String) -> Error,
        then: impl FnOnce(&Collection<'_>) -> Result<T, Error>,
    ) -> Result<T, Error> {
        let service = connected(&self.ctx, otherwise)?;
        let collection = service.get_default_collection().map_err(said(otherwise))?;
        if collection.is_locked().map_err(said(otherwise))? {
            if !self.asks || self.ctx.unlock_was_dismissed() {
                return Err(Error::Locked);
            }
            match collection.unlock() {
                Err(::secret_service::Error::Prompt) => {
                    self.ctx.unlock_dismissed();
                    return Err(Error::Locked);
                }
                unlocked => unlocked.map_err(said(otherwise))?,
            }
        }
        let answer = then(&collection)?;
        if collection.is_locked().map_err(said(otherwise))? {
            return Err(Error::Locked);
        }
        Ok(answer)
    }
}

// A session with the Secret Service, where one answers on this session's bus.
fn connected<'a>(
    ctx: &Context,
    otherwise: fn(String) -> Error,
) -> Result<SecretService<'a>, Error> {
    let connection = bus::session(ctx).map_err(|_| Error::Locked)?;
    SecretService::connect_with_existing(EncryptionType::Dh, connection).map_err(said(otherwise))
}

/// Whether a Secret Service on this session's bus has a default collection to park in, locked
/// or not, as a new home asks before it records its form. Nothing is unlocked to tell.
pub(super) fn answers(ctx: &Context) -> bool {
    connected(ctx, Error::Unreadable).is_ok_and(|service| service.get_default_collection().is_ok())
}

/// What owns `org.freedesktop.secrets` on this session's bus, asked of the bus alone: nothing is
/// started to tell, so where nothing does it is the login keyring.
pub(super) fn keyring(ctx: &Context) -> Keyring {
    let kwallet = bus::session(ctx).ok().and_then(|connection| {
        let bus = zbus::blocking::fdo::DBusProxy::new(&connection).ok()?;
        let owner = |name: &str| {
            let name = zbus::names::BusName::try_from(name).ok()?;
            bus.get_name_owner(name).ok()
        };
        let answering = owner(SECRETS)?;
        Some(
            KWALLET
                .iter()
                .any(|name| owner(name).as_ref() == Some(&answering)),
        )
    });
    if kwallet == Some(true) {
        Keyring::KWallet
    } else {
        Keyring::Login
    }
}

fn attributes(service: &str) -> HashMap<&str, &str> {
    HashMap::from([SCHEMA, (SERVICE, service)])
}

// Two items of one park are none Pitboard wrote: a write replaces the one there.
fn secret_of(collection: &Collection<'_>, service: &str) -> Result<Option<String>, Error> {
    let items = collection
        .search_items(attributes(service))
        .map_err(said(Error::Unreadable))?;
    match items.as_slice() {
        [] => Ok(None),
        [item] => {
            let secret = item.get_secret().map_err(said(Error::Unreadable))?;
            String::from_utf8(secret)
                .map(Some)
                .map_err(|_| Error::Unreadable(format!("{service} does not hold text")))
        }
        several => Err(Error::Unreadable(format!(
            "{} items of the Secret Service hold {service}",
            several.len()
        ))),
    }
}

// What the Secret Service said, as a store's error: locked, dismissed or not there is `Locked`.
fn said(otherwise: fn(String) -> Error) -> impl Fn(::secret_service::Error) -> Error {
    use ::secret_service::Error as Said;
    move |error| match &error {
        Said::Locked
        | Said::Prompt
        | Said::PromptDisconnected
        | Said::Unavailable
        | Said::NoResult => Error::Locked,
        Said::Zbus(zbus::Error::MethodError(name, ..)) if LOCKED.contains(&name.as_str()) => {
            Error::Locked
        }
        Said::ZbusFdo(fdo) if LOCKED.contains(&zbus::DBusError::name(fdo).as_str()) => {
            Error::Locked
        }
        _ => otherwise(format!("the Secret Service: {error}")),
    }
}

impl RawStore for Vault {
    fn kind(&self) -> Backend {
        Backend::SecretService
    }

    fn contains(&self, service: &str) -> Result<bool, Error> {
        self.open(Error::Unreadable, |collection| {
            let items = collection
                .search_items(attributes(service))
                .map_err(said(Error::Unreadable))?;
            Ok(!items.is_empty())
        })
    }

    fn read(&self, service: &str) -> Result<Option<String>, Error> {
        self.open(Error::Unreadable, |collection| {
            secret_of(collection, service)
        })
    }

    // `replace` has the provider replace the item these attributes name.
    fn write(&self, _: Permit, service: &str, contents: &str) -> Result<(), Error> {
        let back = self.open(Error::Write, |collection| {
            collection
                .create_item(
                    LABEL,
                    attributes(service),
                    contents.as_bytes(),
                    true,
                    CONTENT_TYPE,
                )
                .map_err(said(Error::Write))?;
            secret_of(collection, service)
        })?;
        match back {
            Some(back) if back == contents => Ok(()),
            _ => Err(Error::NotDurable(format!(
                "the Secret Service does not hold what was written to {service}"
            ))),
        }
    }

    fn delete(&self, _: Permit, service: &str) -> Result<(), Error> {
        self.open(Error::Write, |collection| {
            let items = collection
                .search_items(attributes(service))
                .map_err(said(Error::Write))?;
            items
                .iter()
                .try_for_each(Item::delete)
                .map_err(said(Error::Write))
        })
    }

    /// Every park of Pitboard's schema in the collection, whichever home wrote it.
    fn list(&self) -> Result<Option<Vec<String>>, Error> {
        self.open(Error::Unreadable, |collection| {
            let items = collection
                .search_items(HashMap::from([SCHEMA]))
                .map_err(said(Error::Unreadable))?;
            let mut names = Vec::new();
            for item in &items {
                let mut attributes = item.get_attributes().map_err(said(Error::Unreadable))?;
                if let Some(name) = attributes
                    .remove(SERVICE)
                    .filter(|name| crate::park::is_park_name(name))
                {
                    names.push(name);
                }
            }
            names.sort();
            names.dedup();
            Ok(Some(names))
        })
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::secret_service_testing::{Item as Held, SecretService as Started};
    use std::collections::BTreeMap;
    use std::path::Path;

    const LOGIN: &str = r#"{"claudeAiOauth":{"refreshToken":"r"}}"#;
    const AGAIN: &str = r#"{"claudeAiOauth":{"refreshToken":"s"}}"#;

    fn started(scratch: &Path) -> Started {
        Started::start(&scratch.join("keyring")).unwrap_or_else(|missing| panic!("{missing}"))
    }

    // A home of its own on the test's bus, as a command a test runs is given it.
    fn home(scratch: &Path, name: &str, on: &Started) -> Context {
        Context::for_unit_test()
            .with_pitboard_home(scratch.join(name))
            .with_test_bus(on.address().to_owned())
    }

    // The same, for a run a person started in the desktop session, which may put up a prompt.
    fn at_the_desktop(scratch: &Path, name: &str, on: &Started) -> Context {
        let home = scratch.join(name).to_string_lossy().into_owned();
        let env = crate::context::Environment::on(
            crate::host::Os::Linux,
            [("HOME", home.as_str()), ("WAYLAND_DISPLAY", "wayland-0")],
        );
        Context::read(&env, "cli")
            .with_pitboard_home(scratch.join(name).join(".pitboard"))
            .with_test_bus(on.address().to_owned())
    }

    // A park named after the test that writes it, through the guard every test's names pass, as
    // AGENTS.md asks of a test that writes a Secret Service item: `test` is its tag.
    fn park(test: &str, at: i64) -> String {
        let name = crate::park::service_name(test, 1_789_935_600_000 + at);
        if let Some(why) = crate::provider::names::refusal(&name, &[]) {
            panic!("{why}");
        }
        name
    }

    fn unlocks(service: &Started) -> usize {
        service
            .asked()
            .iter()
            .filter(|member| *member == "Unlock")
            .count()
    }

    #[test]
    fn a_park_round_trips_as_one_item_of_pitboards_schema() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let service = started(scratch.path());
        let ctx = home(scratch.path(), "home", &service);
        assert!(answers(&ctx));
        assert_eq!(
            crate::store::new_home_form(&ctx),
            Some(crate::state::VaultForm::SecretService)
        );
        let (vault, park, permit) = (Vault::of(&ctx), park("round-trip", 0), Permit::for_a_test());
        assert_eq!(vault.kind(), Backend::SecretService);
        assert_eq!(vault.read(&park).expect("read"), None);
        assert!(!vault.contains(&park).expect("looked for"));

        vault.write(permit, &park, LOGIN).expect("written");
        assert_eq!(vault.read(&park).expect("read").as_deref(), Some(LOGIN));
        vault.write(permit, &park, AGAIN).expect("written over");
        assert_eq!(
            service.items(),
            vec![Held {
                label: LABEL.into(),
                attributes: BTreeMap::from([
                    ("service".into(), park.clone()),
                    ("xdg:schema".into(), "com.usepitboard.Pitboard.Park".into()),
                ]),
                secret: AGAIN.into(),
            }]
        );
        assert!(vault.contains(&park).expect("looked for"));

        vault.delete(permit, &park).expect("deleted");
        assert_eq!(vault.read(&park).expect("read"), None);
        assert!(service.items().is_empty());
        vault
            .delete(permit, &park)
            .expect("a park already gone is deleted");
    }

    // As the login keychain on macOS: every home of the session parks in the one collection.
    #[test]
    fn the_list_holds_every_park_on_the_bus_and_nothing_of_another_schema() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let service = started(scratch.path());
        let here = Vault::of(&home(scratch.path(), "here", &service));
        let there = Vault::of(&home(scratch.path(), "there", &service));
        let permit = Permit::for_a_test();
        assert_eq!(here.list().expect("listed"), Some(Vec::new()));
        here.write(permit, &park("listed", 1), LOGIN)
            .expect("written");
        there
            .write(permit, &park("listed", 0), LOGIN)
            .expect("written");
        service.plant(
            "Another program's",
            &[
                ("xdg:schema", "org.example.Other"),
                ("service", &park("listed", 2)),
            ],
            "theirs",
        );
        service.plant("Not a park", &[SCHEMA, (SERVICE, "pitboard-park-")], "x");

        for vault in [&here, &there] {
            assert_eq!(
                vault.list().expect("listed"),
                Some(vec![park("listed", 0), park("listed", 1)])
            );
        }
    }

    // The names guard every test's writes pass, on a bus of the test's own too.
    #[test]
    #[should_panic(expected = "a test must never address")]
    fn a_test_never_plants_a_name_a_real_login_may_be_kept_under() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let nobody = Started::without_a_provider(&scratch.path().join("nobody"))
            .unwrap_or_else(|missing| panic!("{missing}"));
        nobody.plant(
            "A real login",
            &[("service", "Claude Code-credentials")],
            "x",
        );
    }

    // Every question, whoever asks: a person's run is refused once its prompt is dismissed.
    fn refused_every_way(vault: &Vault, park: &str) {
        let permit = Permit::for_a_test();
        let locked = |what: &str, answer: Result<String, Error>| match answer {
            Err(Error::Locked) => {}
            other => panic!("{what}: {other:?}"),
        };
        locked("read", vault.read(park).map(|r| format!("{r:?}")));
        locked("look", vault.contains(park).map(|c| c.to_string()));
        locked("list", vault.list().map(|l| format!("{l:?}")));
        locked(
            "write",
            vault.write(permit, park, AGAIN).map(|()| String::new()),
        );
        locked("delete", vault.delete(permit, park).map(|()| String::new()));
    }

    // gnome-keyring 48.0 answers a search of a keyring locked since it started with nothing.
    #[test]
    fn a_locked_collection_is_locked_never_absent() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let service = started(scratch.path());
        let ctx = home(scratch.path(), "home", &service);
        Vault::of(&ctx)
            .write(Permit::for_a_test(), &park("locked", 0), LOGIN)
            .expect("written");
        service.lock();

        for ctx in [ctx.clone(), ctx.clone().started_by_the_schedule()] {
            refused_every_way(&Vault::of(&ctx), &park("locked", 0));
        }
        assert!(answers(&ctx), "a locked collection is one to park in");
    }

    // The renewal timer and the watch service: nobody is there to answer a prompt.
    #[test]
    fn a_run_a_job_started_never_asks_to_unlock() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let service = started(scratch.path());
        let ctx = home(scratch.path(), "home", &service);
        service.lock();

        for job in [
            ctx.clone().started_by_the_schedule(),
            ctx.clone().started_by_the_watch_service(),
        ] {
            refused_every_way(&Vault::of(&job), &park("job", 0));
        }
        let asked = service.asked();
        assert!(
            !asked
                .iter()
                .any(|member| member == "Unlock" || member == "Prompt"),
            "{asked:?}"
        );
    }

    // Over SSH the prompter shows its dialog on the desktop's display, where nobody who started
    // this run may be, and with no display at all there is nowhere to show it: secret-service
    // 5.2 waits for an answer with no bound.
    #[test]
    fn a_run_out_of_the_desktop_session_never_asks_to_unlock() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let service = started(scratch.path());
        service.lock();
        let home = scratch.path().join("home").to_string_lossy().into_owned();
        let read = |pairs: &[(&str, &str)]| {
            let env = crate::context::Environment::on(
                crate::host::Os::Linux,
                [("HOME", home.as_str())].iter().chain(pairs).copied(),
            );
            Context::read(&env, "cli")
                .with_pitboard_home(scratch.path().join("home/.pitboard"))
                .with_test_bus(service.address().to_owned())
        };

        for away in [
            read(&[]),
            read(&[
                ("DISPLAY", "localhost:10.0"),
                ("SSH_CONNECTION", "10.0.0.2 50022 10.0.0.1 22"),
            ]),
            read(&[("WAYLAND_DISPLAY", ""), ("DISPLAY", "")]),
        ] {
            refused_every_way(&Vault::of(&away), &park("away", 0));
        }
        assert_eq!(unlocks(&service), 0, "{:?}", service.asked());

        let at_the_desktop = read(&[("DISPLAY", ":0")]);
        let read = Vault::of(&at_the_desktop).read(&park("away", 0));
        assert!(matches!(read, Err(Error::Locked)), "{read:?}");
        assert_eq!(unlocks(&service), 1, "{:?}", service.asked());
    }

    // A person who dismisses the prompt has answered for the run: each park doctor reads, and
    // each step of a switch, would put it up again.
    #[test]
    fn a_prompt_dismissed_is_not_put_up_again_in_the_same_run() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let service = started(scratch.path());
        let ctx = at_the_desktop(scratch.path(), "home", &service);
        service.lock();

        refused_every_way(&Vault::of(&ctx), &park("dismissed", 0));
        refused_every_way(&Vault::of(&ctx.clone()), &park("dismissed", 1));
        assert_eq!(unlocks(&service), 1, "{:?}", service.asked());

        let another_run = at_the_desktop(scratch.path(), "home", &service);
        let read = Vault::of(&another_run).read(&park("dismissed", 0));
        assert!(matches!(read, Err(Error::Locked)), "{read:?}");
        assert_eq!(unlocks(&service), 2, "{:?}", service.asked());
    }

    // A bus with no prompter on it, as in a container: gnome-keyring 48.0 dismisses the prompt
    // it cannot show at once.
    #[test]
    fn a_prompt_nobody_can_answer_is_refused_within_seconds() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let service = started(scratch.path());
        let vault = Vault::of(&at_the_desktop(scratch.path(), "home", &service));
        service.lock();

        let asking = std::time::Instant::now();
        let read = vault.read(&park("nobody", 0));
        let took = asking.elapsed();

        assert!(matches!(read, Err(Error::Locked)), "{read:?}");
        assert!(took < std::time::Duration::from_secs(5), "{took:?}");
        let asked = service.asked();
        assert!(
            asked.iter().any(|member| member == "Unlock")
                && asked.iter().any(|member| member == "Prompt"),
            "a person's run asks: {asked:?}"
        );
    }

    // gnome-keyring's collection is the login keyring, and ksecretd's KWallet's.
    #[test]
    fn the_keyring_is_named_for_what_owns_the_secret_service() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let gnome = started(scratch.path());
        let kde = Started::ksecretd(&scratch.path().join("kde"))
            .unwrap_or_else(|missing| panic!("{missing}"));
        let nobody = Started::without_a_provider(&scratch.path().join("nobody"))
            .unwrap_or_else(|missing| panic!("{missing}"));

        assert_eq!(
            keyring(&home(scratch.path(), "gnome", &gnome)),
            Keyring::Login
        );
        let ctx = home(scratch.path(), "kde", &kde);
        assert_eq!(keyring(&ctx), Keyring::KWallet);
        assert!(answers(&ctx), "a closed wallet is one to park in");
        assert_eq!(
            keyring(&home(scratch.path(), "nobody", &nobody)),
            Keyring::Login
        );
        let without_a_bus =
            Context::for_unit_test().with_pitboard_home(scratch.path().join("bare"));
        assert_eq!(keyring(&without_a_bus), Keyring::Login);
    }

    // As over SSH or in a container: a home on the Secret Service cannot tell what it holds.
    #[test]
    fn no_secret_service_on_the_bus_is_locked_never_absent() {
        let scratch = tempfile::tempdir().expect("a scratch folder");
        let nobody = Started::without_a_provider(&scratch.path().join("nobody"))
            .unwrap_or_else(|missing| panic!("{missing}"));
        let mut stopped = started(scratch.path());
        let ctx = home(scratch.path(), "home", &stopped);
        Vault::of(&ctx)
            .write(Permit::for_a_test(), &park("no-provider", 0), LOGIN)
            .expect("written");
        stopped.stop();

        let without_a_bus =
            Context::for_unit_test().with_pitboard_home(scratch.path().join("bare"));
        for ctx in [home(scratch.path(), "nobody", &nobody), ctx, without_a_bus] {
            refused_every_way(&Vault::of(&ctx), &park("no-provider", 0));
            assert!(!answers(&ctx));
            assert_eq!(
                crate::store::new_home_form(&ctx),
                Some(crate::state::VaultForm::Files)
            );
        }
    }
}