Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(security): assert the backend→mode pairing, not just enum membership\n\nReview follow-up. The first pass replaced the stale `mode == "os_keyring"`\nassertion with `!matches!(mode, "consent_pending" | "declined")`, which was too\nloose: #6076 was a mismatched PAIR — `backendName: "file"` with\n`activeMode: "os_keyring"` — and that predicate would have let the exact\nregression back in while the comment above it claimed to guard against it.\n\nNow derives the expected mode from `backendName`, mirroring `active_mode_for`\n(`security/keyring_consent/policy.rs:125-146`), including the deliberate\n`consent_pending` fallback for an unrecognised backend.\n\nFault-injected to prove it bites: mapping `"file"` to `"os_keyring"` fails with\n\n a usable `file` backend must report `os_keyring` ...\n left: "local_plaintext_file" right: "os_keyring"\n\nRestored; suite green: 8 passed, 0 failed, 1 ignored.\n

M3gA-Mind9ca181912656
diff --git a/tests/raw_coverage/secrets_devices_e2e.rs b/tests/raw_coverage/secrets_devices_e2e.rs
index 644ce0b49c..9249e5ef62 100644
--- a/tests/raw_coverage/secrets_devices_e2e.rs
+++ b/tests/raw_coverage/secrets_devices_e2e.rs
@@ -367,17 +367,28 @@ async fn keyring_consent_status_decide_and_retry_probe() {
"the backend must be named so the settings panel can show it: {status}"
);
if available {
- // NOT `== "os_keyring"`. That was the #6076 defect this test was written
- // beside: every working backend reported itself as the OS keyring, so a
- // plaintext dev-keychain looked like the OS credential store. #6096 made
- // `activeMode` describe the backend that is actually in use, and the
- // schema now documents `available` as "the active backend is usable,
- // which is true for the file backends". What a usable backend implies is
- // that no consent decision is outstanding — not which backend it is.
- assert!(
- !matches!(mode, "consent_pending" | "declined"),
- "a usable backend means no consent decision is outstanding; \
- got {mode:?}: {status}"
+ // Assert the BACKEND -> MODE pairing, not merely that the mode is in the
+ // enum. #6076 was exactly a mismatched pair — `backendName: "file"` with
+ // `activeMode: "os_keyring"` — so a predicate that only rejects
+ // `consent_pending`/`declined` would let that regression back in while a
+ // comment claimed to guard it. Mirrors `active_mode_for` in
+ // `security/keyring_consent/policy.rs:125-146`.
+ let backend = status
+ .get("backendName")
+ .and_then(Value::as_str)
+ .expect("backendName asserted non-empty above");
+ let expected = match backend {
+ "os" => "os_keyring",
+ "encrypted_file" => "local_encrypted_file",
+ "file" | "mock" => "local_plaintext_file",
+ // An unrecognised backend reports `consent_pending` rather than
+ // guessing — the deliberate fallback in `policy.rs`.
+ _ => "consent_pending",
+ };
+ assert_eq!(
+ mode, expected,
+ "a usable `{backend}` backend must report `{expected}`; reporting anything \
+ else is the #6076 mismatch this test exists to catch: {status}"
);
assert!(
status.get("failureReason").is_none(),