Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Passwords: the 409 names the approval modes, not "approvals are off"

Lin1d2b97bd7c03
diff --git a/docs/saved-passwords.md b/docs/saved-passwords.md
index 23bc512f..4c39fda8 100644
--- a/docs/saved-passwords.md
+++ b/docs/saved-passwords.md
@@ -22,6 +22,7 @@ Since 2026-10-20, approvals off and passwords in the built-in store are not allo
- A space that is off counts even if every bot in it overrides to `ask`, because a new bot there would inherit `off`.
- `local_count` counts every file in `<data>/kwnt-vault/`, including those of deleted teams, channels and bots (audit F-11). A file that won't open counts as one. Deleting a bot, team or channel now deletes its file. Leftovers from before this change are kept, because they are the person's data. They still count, and `POST /api/passwords/migrate` moves them to Bitwarden too. Spaces are only archived, so their bots' passwords keep counting. Deleting an owner never deletes items in Bitwarden.
- New spaces, and a fresh install's Default space, start on `smart` (since 2026-10-24). So on a new install, saving into the built-in store answers 409 until every space and bot is on "Ask before running commands", or Bitwarden is set up. A space created while the built-in store holds passwords starts on `ask` instead, and a fresh database next to a leftover `kwnt-vault/` folder starts its Default space on `ask`.
+- The 409 `error` names the modes rather than saying "approvals are off", which read wrong under "Ask only when risky". It says the built-in store needs every space and bot on "Ask before running commands", and that the way out is to connect Bitwarden or switch every space and bot back to that mode.
- An install that was already in this state keeps its approvals as they are. `GET /api/passwords/store` shows `exposed: true`, and kwnt logs one warning at start (a count, no secrets). Moving the passwords to Bitwarden or turning approvals back on clears it.
With Bitwarden, the API token alone doesn't show a password: that needs the master password. The DevTools gap below still applies in Bitwarden mode.
@@ -83,7 +84,7 @@ Vault:
- 400 for bad input
- 502 when Bitwarden is unreachable or refuses
- `POST /api/passwords/bitwarden/lock` returns the store status.
-- `DELETE /api/passwords/bitwarden {master_password}` goes back to the built-in store. The vault must be unlocked, and the items stay in Bitwarden. While approvals are off anywhere and the built-in store isn't empty, it returns 409 (see above).
+- `DELETE /api/passwords/bitwarden {master_password}` goes back to the built-in store. The vault must be unlocked, and the items stay in Bitwarden. While any space or bot is on "Ask only when risky" or "Don't ask" and the built-in store isn't empty, it returns 409 (see above).
- `POST /api/passwords/migrate` returns `{moved, failed}`. It runs once, when the person triggers it. Each built-in password is deleted locally only after Bitwarden has it.
## Tests
diff --git a/docs/zombie-hunter.md b/docs/zombie-hunter.md
index 02ffcc5f..f3a8e67b 100644
--- a/docs/zombie-hunter.md
+++ b/docs/zombie-hunter.md
@@ -26,7 +26,8 @@ secret, its cases and its mutes. A plain-text IMAP connection or a self-signed c
only accepted for a server on this computer (Proton Bridge, a test server).
Like any saved password (see `saved-passwords.md`), a login is refused with 409
-`{needs_bitwarden: true}` on the built-in store while approvals are off anywhere, before the
+`{needs_bitwarden: true}` on the built-in store while any space or bot is on "Ask only when
+risky" or "Don't ask", before the
connection test runs. That holds for adding a source and for changing its settings or login
(`PATCH sources/:id` with `config` or `secret`): a refused save never contacts the server. Existing logins count toward `local_count` and move with "Move to Bitwarden".
diff --git a/frontend/src/components/LooseEndsView.tsx b/frontend/src/components/LooseEndsView.tsx
index ecbd0497..604a4d34 100644
--- a/frontend/src/components/LooseEndsView.tsx
+++ b/frontend/src/components/LooseEndsView.tsx
@@ -297,7 +297,8 @@ export const LooseCaseCard: React.FC<LooseCaseCardProps> = ({ c, busy, now = Dat
};
/**
- * A login can't be saved on this server while approvals are off (or Bitwarden is locked): connect
+ * A login can't be saved on this server unless every space and bot asks before running commands
+ * (or Bitwarden is locked): connect
* or unlock Bitwarden here, move any passwords already on this server, then save again.
*/
export const NeedsBitwarden: React.FC<{ message: string; locked: boolean; onReady: () => void; onCancel: () => void }> = ({ message, locked, onReady, onCancel }) => {
diff --git a/frontend/src/components/PasswordStorePanel.tsx b/frontend/src/components/PasswordStorePanel.tsx
index d18b02bc..90d34ba6 100644
--- a/frontend/src/components/PasswordStorePanel.tsx
+++ b/frontend/src/components/PasswordStorePanel.tsx
@@ -525,7 +525,7 @@ export const PasswordStoreBar: React.FC<{
/>
<span>
<span className="block text-[11px] text-zinc-200 font-medium">Saved on this server</span>
- <span className="block text-[10px] text-zinc-500 leading-snug">Encrypted here. A bot with approvals off can read them, so use Bitwarden then.</span>
+ <span className="block text-[10px] text-zinc-500 leading-snug">Encrypted here. Works only while every space and bot is on “Ask before running commands”; otherwise use Bitwarden.</span>
</span>
</label>
<label className={`flex items-start gap-2 p-2 rounded-lg border cursor-pointer ${onBitwarden || connecting ? 'border-sky-500/60 bg-sky-500/10' : 'border-zinc-800 hover:border-zinc-700'}`}>
@@ -615,15 +615,15 @@ export const PasswordStoreBar: React.FC<{
);
};
-/** What approvals off means for saved passwords, said once, plainly, for where they're kept. */
+/** What "Ask only when risky" or "Don't ask" means for saved passwords, said once, plainly, for where they're kept. */
export const AutofillGapNote: React.FC<{ status?: StoreStatus | null }> = ({ status }) => {
const kind = status?.store === 'bitwarden' && status.local_count === 0 ? 'bitwarden' : 'local';
return (
<p className="flex items-start gap-2 text-[10px] text-zinc-400 leading-snug" data-autofill-gap={kind}>
<Info size={12} className="text-zinc-500 flex-shrink-0 mt-px" aria-hidden="true" />
<span>
- {/* The local sentence already starts with "With approvals off". */}
- {kind === 'bitwarden' && <span className="text-zinc-300">Approvals are off. </span>}
+ {/* The local sentence already names the modes. */}
+ {kind === 'bitwarden' && <span className="text-zinc-300">Some bots run commands without asking. </span>}
{autofillGapNote(status)}
</span>
</p>
diff --git a/frontend/src/looseEnds.ts b/frontend/src/looseEnds.ts
index 56c234c1..ae496108 100644
--- a/frontend/src/looseEnds.ts
+++ b/frontend/src/looseEnds.ts
@@ -196,7 +196,7 @@ export class LooseEndsError extends Error {
constructor(
message: string,
public status: number,
- /** 409: approvals are off and the login would sit on this server; Bitwarden first. */
+ /** 409: a space or bot isn't on "Ask before running commands" and the login would sit on this server; Bitwarden first. */
public needsBitwarden = false,
/** 423: Bitwarden holds the logins and is locked. */
public locked = false,
diff --git a/frontend/src/passwordStore.ts b/frontend/src/passwordStore.ts
index 053df2aa..75e20816 100644
--- a/frontend/src/passwordStore.ts
+++ b/frontend/src/passwordStore.ts
@@ -249,11 +249,12 @@ export const storeApi = {
},
};
-/** One sentence per store for wherever approvals are off. Bitwarden: the accepted gap (2026-10-20).
- * This server: approvals off can't sit next to passwords here (audit F-10), so it's blocked. */
+/** One sentence per store for wherever a space or bot is on "Ask only when risky" or "Don't ask".
+ * Bitwarden: the accepted gap (2026-10-20). This server: either mode can't sit next to passwords
+ * here (audit F-10), so it's blocked. */
export const AUTOFILL_GAP_NOTE = {
bitwarden: 'While a password is being filled into a page, a bot that can run commands can read it.',
- local: 'With approvals off, any bot that can run commands could read passwords saved on this server, so that’s blocked: use Bitwarden.',
+ local: 'Unless every space and bot is on “Ask before running commands”, any bot that can run commands could read passwords saved on this server, so they can’t be saved here: use Bitwarden.',
} as const;
/** The note for a store; unknown counts as this server, the stricter one. */
@@ -264,12 +265,12 @@ const passwords = (n: number) => `${n} saved ${n === 1 ? 'password' : 'passwords
/** Approvals can't go off while this server holds passwords: what the confirm says instead. */
export const moveFirstText = (n: number) =>
- `${capitalise(passwords(n))} ${n === 1 ? 'is' : 'are'} kept on this server. With approvals off, any bot that can run commands could read ${n === 1 ? 'it' : 'them'}, so move ${n === 1 ? 'it' : 'them'} to Bitwarden first.`;
+ `${capitalise(passwords(n))} ${n === 1 ? 'is' : 'are'} kept on this server. Under “Ask only when risky” or “Don’t ask”, any bot that can run commands could read ${n === 1 ? 'it' : 'them'}, so move ${n === 1 ? 'it' : 'them'} to Bitwarden first.`;
export const moveFirstLabel = (n: number) => `Move ${passwords(n)} to Bitwarden first`;
-/** An install already in that state (approvals off before the block). */
+/** An install already in that state (a space or bot stopped asking before the block). */
export const exposedText = (n: number) =>
- `Approvals are off and ${passwords(n)} ${n === 1 ? 'is' : 'are'} still on this server, so any bot that can run commands can read ${n === 1 ? 'it' : 'them'}.`;
+ `A space or bot is on “Ask only when risky” or “Don’t ask” and ${passwords(n)} ${n === 1 ? 'is' : 'are'} still on this server, so any bot that can run commands can read ${n === 1 ? 'it' : 'them'}.`;
/** A 409 that says the server wants Bitwarden first: its sentence, and how many passwords are here. */
export function needsBitwardenFrom(status: number, body: unknown): { message: string; local_count: number | null } | null {
diff --git a/frontend/src/savedPasswords.ts b/frontend/src/savedPasswords.ts
index a73b8db5..880f9823 100644
--- a/frontend/src/savedPasswords.ts
+++ b/frontend/src/savedPasswords.ts
@@ -147,7 +147,7 @@ async function call(url: string, init?: RequestInit): Promise<unknown> {
const res = await fetch(url, { cache: 'no-store', ...init });
const body = await res.json().catch(() => null);
if (!res.ok) {
- // Saving here while approvals are off (F-10): the server's own sentence says why and what to do.
+ // Saving here while a space or bot doesn't ask before commands (F-10): the server's own sentence says why and what to do.
const needs = needsBitwardenFrom(res.status, body);
if (needs) throw new PasswordsError('error', res.status, needs.message, true);
const problem = problemFor(res.status, body);
diff --git a/frontend/tests/approvalsNeedBitwarden.test.mjs b/frontend/tests/approvalsNeedBitwarden.test.mjs
index d14ae13b..3616159c 100644
--- a/frontend/tests/approvalsNeedBitwarden.test.mjs
+++ b/frontend/tests/approvalsNeedBitwarden.test.mjs
@@ -39,7 +39,7 @@ const BW = st({ store: 'bitwarden', bitwarden: bw() });
const BW_LEFTOVER = st({ store: 'bitwarden', bitwarden: bw(), local_count: 2 });
const BW_LOCKED = st({ store: 'bitwarden', locked: true, bitwarden: bw({ unlocked: false }), local_count: 3 });
const EXPOSED = st({ local_count: 3, approvals_off: true, exposed: true });
-const LOCAL_NOTE = "With approvals off, any bot that can run commands could read passwords saved on this server, so that's blocked: use Bitwarden.";
+const LOCAL_NOTE = "Unless every space and bot is on “Ask before running commands”, any bot that can run commands could read passwords saved on this server, so they can't be saved here: use Bitwarden.";
const BW_NOTE = 'While a password is being filled into a page, a bot that can run commands can read it.';
// ---------------------------------------------------------------- the model
@@ -70,10 +70,10 @@ test('move-first and exposed wording, one and many', () => {
assert.equal(m.moveFirstLabel(3), 'Move 3 saved passwords to Bitwarden first');
assert.equal(
text(m.moveFirstText(3)),
- "3 saved passwords are kept on this server. With approvals off, any bot that can run commands could read them, so move them to Bitwarden first.",
+ "3 saved passwords are kept on this server. Under “Ask only when risky” or “Don't ask”, any bot that can run commands could read them, so move them to Bitwarden first.",
);
assert.match(text(m.moveFirstText(1)), /^1 saved password is kept .* read it, so move it to Bitwarden first\.$/);
- assert.equal(text(m.exposedText(3)), 'Approvals are off and 3 saved passwords are still on this server, so any bot that can run commands can read them.');
+ assert.equal(text(m.exposedText(3)), 'A space or bot is on “Ask only when risky” or “Don\'t ask” and 3 saved passwords are still on this server, so any bot that can run commands can read them.');
assert.match(text(m.exposedText(1)), /1 saved password is still on this server, .* read it\.$/);
});
@@ -125,13 +125,13 @@ test('approvals PUT refused for passwords here → NeedsBitwardenError with the
);
});
-test('saving here while approvals are off: the 409 reason, not a generic error (Add and a caught login)', async () => {
- const refusal = { error: "passwords can't be saved on this server while approvals are off: a bot that can run commands could read them. Use Bitwarden, or turn approvals back on.", needs_bitwarden: true };
+test('saving here while a space or bot doesn\'t ask before commands: the 409 reason, not a generic error (Add and a caught login)', async () => {
+ const refusal = { error: "this server's built-in password store only takes passwords while every space and bot is on \"Ask before running commands\": under \"Ask only when risky\" or \"Don't ask\", a bot that can run commands could read them. Connect Bitwarden, or switch every space and bot to \"Ask before running commands\".", needs_bitwarden: true };
await withFetch(
() => json(refusal, 409),
async (calls) => {
for (const p of [m.passwordsApi.add('k1', 'https://example.com', 'alice', 'DUMMY-PW'), m.passwordsApi.savePending('k1')]) {
- await assert.rejects(p, (e) => e instanceof m.PasswordsError && e.needsBitwarden === true && e.status === 409 && /^Passwords can't be saved on this server while approvals are off/.test(e.message) && /Use Bitwarden, or turn approvals back on\.$/.test(e.message));
+ await assert.rejects(p, (e) => e instanceof m.PasswordsError && e.needsBitwarden === true && e.status === 409 && /^This server's built-in password store only takes passwords while every space and bot is on "Ask before running commands"/.test(e.message) && /Connect Bitwarden, or switch every space and bot to "Ask before running commands"\.$/.test(e.message) && !/approvals are off/i.test(e.message));
}
assert.deepEqual(calls.map((c) => `${c.method} ${c.url}`), ['POST /api/sandbox/k1/passwords', 'POST /api/sandbox/k1/passwords/pending']);
},
@@ -185,7 +185,7 @@ test('confirm with passwords here: "off" isn\'t offered; it says why and offers
const html = m.confirm(LOCAL3);
const t = text(html);
assert.match(html, /data-off-needs-bitwarden/);
- assert.match(t, /3 saved passwords are kept on this server\. With approvals off, any bot that can run commands could read them, so move them to Bitwarden first\./);
+ assert.match(t, /3 saved passwords are kept on this server\. Under “Ask only when risky” or “Don't ask”, any bot that can run commands could read them, so move them to Bitwarden first\./);
assert.deepEqual(buttons(html), ['Move 3 saved passwords to Bitwarden first', 'Keep asking']);
assert.doesNotMatch(t, /Turn approvals off/);
// The paragraph says it; the note isn't repeated above it.
@@ -243,7 +243,7 @@ test('exposed: a plain banner with both ways out, next to saved passwords and in
const html = m.banner(EXPOSED);
assert.match(html, /data-exposed/);
assert.match(html, /role="region"/);
- assert.equal(text(html).split(' Move to Bitwarden')[0], 'Approvals are off and 3 saved passwords are still on this server, so any bot that can run commands can read them.');
+ assert.equal(text(html).split(' Move to Bitwarden')[0], 'A space or bot is on “Ask only when risky” or “Don\'t ask” and 3 saved passwords are still on this server, so any bot that can run commands can read them.');
assert.deepEqual(buttons(html), ['Move to Bitwarden', 'Turn approvals back on']);
assert.equal(m.banner({ ...EXPOSED, exposed: false }), '', 'nothing when not exposed');
assert.equal(m.banner(null), '');
@@ -257,12 +257,12 @@ test('exposed: a plain banner with both ways out, next to saved passwords and in
});
test('next to saved passwords: the note follows the store, and shows when any bot runs without asking', () => {
- assert.ok(text(m.panel(st({ store: 'bitwarden', bitwarden: bw(), approvals_off: true }))).includes(BW_NOTE), 'the server says approvals are off somewhere');
+ assert.ok(text(m.panel(st({ store: 'bitwarden', bitwarden: bw(), approvals_off: true }))).includes(BW_NOTE), 'the server says some space or bot doesn\'t ask before every command');
assert.ok(text(m.panel(st({ approvals_off: true }))).includes(LOCAL_NOTE));
assert.ok(!text(m.panel(BW)).includes(BW_NOTE));
assert.match(m.gap(BW), /data-autofill-gap="bitwarden"/);
assert.match(m.gap(LOCAL0), /data-autofill-gap="local"/);
for (const s of [BW, LOCAL0]) assert.doesNotMatch(m.gap(s), /rose|red-|amber/, 'no scare styling');
- assert.equal(text(m.gap(BW)), `Approvals are off. ${BW_NOTE}`);
- assert.equal(text(m.gap(LOCAL0)), LOCAL_NOTE, 'no "Approvals are off." before "With approvals off"');
+ assert.equal(text(m.gap(BW)), `Some bots run commands without asking. ${BW_NOTE}`);
+ assert.equal(text(m.gap(LOCAL0)), LOCAL_NOTE, 'no prefix before a sentence that already names the modes');
});
diff --git a/frontend/tests/bitwardenStore.test.mjs b/frontend/tests/bitwardenStore.test.mjs
index 7d233307..00073503 100644
--- a/frontend/tests/bitwardenStore.test.mjs
+++ b/frontend/tests/bitwardenStore.test.mjs
@@ -174,7 +174,7 @@ test('the store bar: this server, Bitwarden unlocked with Lock, Bitwarden locked
test('the picker: two choices, said plainly; Bitwarden opens the connect form', () => {
const html = m.bar(LOCAL, { initialOpen: true });
assert.match(text(html), /Where passwords are kept, for every bot/);
- assert.match(text(html), /Saved on this server Encrypted here\. A bot with approvals off can read them, so use Bitwarden then\./);
+ assert.match(text(html), /Saved on this server Encrypted here\. Works only while every space and bot is on “Ask before running commands”; otherwise use Bitwarden\./);
assert.match(text(html), /Bitwarden In your own Bitwarden account/);
assert.equal(inputs(html).filter((i) => /type="radio"/.test(i)).length, 2);
const connecting = m.bar(LOCAL, { initialOpen: true, initialConnecting: true });
@@ -291,7 +291,7 @@ test('approvals off: one plain sentence per store, in the confirm and next to sa
// Bitwarden: the accepted gap. This server: blocked (audit F-10), so the sentence says so.
const bwNote = 'While a password is being filled into a page, a bot that can run commands can read it.';
assert.equal(m.AUTOFILL_GAP_NOTE.bitwarden, bwNote);
- assert.match(m.AUTOFILL_GAP_NOTE.local, /^With approvals off, any bot that can run commands could read passwords saved on this server, so that's blocked|^With approvals off, any bot that can run commands could read passwords saved on this server, so that’s blocked/);
+ assert.match(m.AUTOFILL_GAP_NOTE.local, /^Unless every space and bot is on “Ask before running commands”, any bot that can run commands could read passwords saved on this server/);
assert.ok(text(m.offConfirm()).includes(text(m.AUTOFILL_GAP_NOTE.local)), 'unknown store: the stricter sentence');
assert.ok(text(m.panel({ logins: [login()] }, { approvalsOff: true, store: m.storeState(UNLOCKED) })).includes(bwNote));
assert.ok(!text(m.panel({ logins: [login()] }, { approvalsOff: false, store: m.storeState(UNLOCKED) })).includes(bwNote));
diff --git a/frontend/tests/looseEnds.test.mjs b/frontend/tests/looseEnds.test.mjs
index e48fdf07..20bf5bdc 100644
--- a/frontend/tests/looseEnds.test.mjs
+++ b/frontend/tests/looseEnds.test.mjs
@@ -140,7 +140,7 @@ test('a 409 needs_bitwarden becomes a Bitwarden step, a 423 an unlock, and other
const real = globalThis.fetch;
const answer = (status, body) => (globalThis.fetch = async () => new Response(JSON.stringify(body), { status }));
try {
- answer(409, { needs_bitwarden: true, error: 'approvals are off: connect Bitwarden first' });
+ answer(409, { needs_bitwarden: true, error: 'a space or bot is on "Ask only when risky": connect Bitwarden first' });
await assert.rejects(m.looseApi.addSource({ kind: 'imap', label: 'x', config: {}, secret: 's' }), (e) => e.needsBitwarden && e.status === 409);
answer(423, { locked: true, error: 'the vault is locked' });
await assert.rejects(m.looseApi.addSource({ kind: 'imap', label: 'x', config: {}, secret: 's' }), (e) => e.locked && !e.needsBitwarden);
diff --git a/src/server/passwords.rs b/src/server/passwords.rs
index f62dd559..7feb04a0 100644
--- a/src/server/passwords.rs
+++ b/src/server/passwords.rs
@@ -397,7 +397,8 @@ pub async fn refuse_approvals_off(state: &AppState) -> Option<Response> {
)
}
-/// The 409 for saving into the built-in store while approvals are off anywhere. Zombie Hunter's
+/// The 409 for saving into the built-in store while any space or bot is on "Ask only when risky" or
+/// "Don't ask" (both count as off here). Zombie Hunter's
/// mailbox and GitHub logins go through it too.
pub(crate) async fn refuse_local_save(state: &AppState) -> Option<Response> {
if state.credentials.store_name() != "local" || !approvals_off_anywhere(state).await {
@@ -407,7 +408,7 @@ pub(crate) async fn refuse_local_save(state: &AppState) -> Option<Response> {
(
StatusCode::CONFLICT,
Json(json!({
- "error": "passwords can't be saved on this server while approvals are off: a bot that can run commands could read them. Use Bitwarden, or turn approvals back on.",
+ "error": "this server's built-in password store only takes passwords while every space and bot is on \"Ask before running commands\": under \"Ask only when risky\" or \"Don't ask\", a bot that can run commands could read them. Connect Bitwarden, or switch every space and bot to \"Ask before running commands\".",
"needs_bitwarden": true,
})),
)
@@ -415,14 +416,14 @@ pub(crate) async fn refuse_local_save(state: &AppState) -> Option<Response> {
)
}
-/// On start: one warning, without secrets, when approvals are off and the built-in store holds
-/// passwords. Approvals are left as the person set them.
+/// On start: one warning, without secrets, when a space or bot doesn't ask before commands and
+/// the built-in store holds passwords. Approvals are left as the person set them.
pub async fn warn_if_exposed(state: &AppState) {
let n = local_count(state).await;
if n > 0 && approvals_off_anywhere(state).await {
tracing::warn!(
local_count = n,
- "approvals are off while passwords are saved on this server: a bot that can run commands could read them. Move them to Bitwarden or turn approvals back on."
+ "a space or bot is on \"Ask only when risky\" or \"Don't ask\" while passwords are saved in the built-in password store: a bot that can run commands could read them. Move them to Bitwarden, or switch every space and bot to \"Ask before running commands\"."
);
}
}
@@ -489,7 +490,7 @@ pub async fn forget_bitwarden(State(state): State<AppState>, headers: HeaderMap,
return (
StatusCode::CONFLICT,
Json(json!({
- "error": "approvals are off, so this server can't go back to its built-in password store while it still holds passwords. Turn approvals back on first.",
+ "error": "this server can't go back to its built-in password store while it still holds passwords and a space or bot is on \"Ask only when risky\" or \"Don't ask\": a bot that can run commands could read them. Switch every space and bot to \"Ask before running commands\" first.",
"needs_bitwarden": true,
"local_count": n,
})),
diff --git a/tests/approvals_passwords_test.rs b/tests/approvals_passwords_test.rs
index ae175f77..933dff55 100644
--- a/tests/approvals_passwords_test.rs
+++ b/tests/approvals_passwords_test.rs
@@ -5,7 +5,7 @@
//! - Switching approvals off (space, bot, or a bot set to inherit an off space) answers 409
//! `{error, needs_bitwarden: true, local_count}` while the built-in store holds any password,
//! in Bitwarden mode too (leftovers open with the built-in key).
-//! - While approvals are off anywhere, saving into the built-in store answers 409 and going back
+//! - While any space or bot is on "Ask only when risky" or "Don't ask", saving into the built-in store answers 409 and going back
//! from Bitwarden to the built-in store answers 409 unless it is empty.
//! - An install already in that state shows `exposed: true` and keeps its approvals.
@@ -125,7 +125,10 @@ impl Env {
fn assert_needs_bitwarden(s: StatusCode, v: &Value, count: Option<u64>) {
assert_eq!(s, StatusCode::CONFLICT, "{v}");
assert_eq!(v["needs_bitwarden"], true, "{v}");
- assert!(v["error"].as_str().is_some_and(|e| !e.is_empty()), "{v}");
+ let e = v["error"].as_str().unwrap_or_default();
+ // Names the mode it means: "approvals are off" read wrong under "Ask only when risky"
+ assert!(e.contains("Ask only when risky"), "{v}");
+ assert!(!e.contains("approvals are off"), "{v}");
if let Some(n) = count {
assert_eq!(v["local_count"], n, "{v}");
}
@@ -195,6 +198,11 @@ async fn with_approvals_off_nothing_new_is_saved_in_the_built_in_store() {
}
let (s, v) = e.save("DUMMY-PW-OFF").await;
assert_needs_bitwarden(s, &v, None);
+ // Why, and both ways out, in the person's words
+ let why = v["error"].as_str().unwrap();
+ for part in ["Ask before running commands", "Don't ask", "Connect Bitwarden", "switch every space and bot"] {
+ assert!(why.contains(part), "{scope}: {part}: {why}");
+ }
assert_eq!(e.store().await["local_count"], 0, "{scope}: nothing saved");
// A password the browser captured keeps waiting