Skip to content

fix(connection): stop a locked keyring from deleting the stored password - #526

Merged
EVWorth merged 1 commit into
mainfrom
fix/connection-keyring-and-readonly-badge
Aug 29, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/connection-keyring-and-readonly-badge

Conversation

@EVWorth

@EVWorth EVWorth commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Refs #274, #277.

The keyring wipe (#274, P0)

The frontend never receives credentials — they're #[serde(skip_serializing)] — so on edit it sends them back absent and the command layer fills them in from the store. It did that with:

if let Ok(stored) = state.connection_store.get(&profile.id) {

which treats every failure identically. A keyring that is locked, sandboxed, or momentarily unavailable looked exactly like "this profile has no stored password". The field stayed empty, and save() reads an empty password as "the user cleared it":

if profile.password.is_empty() {
    self.delete_password(&profile.id)?;

So: edit a profile's name, see a success toast, and the credential is gone.

ConnectionStore::get_existing now returns Option<ConnectionProfile>, giving the two outcomes different types so the call site has to choose:

  • profile not found → None, a new profile where empty really is the intent
  • anything else → an error, and the save is refused with a message saying nothing was written and the stored password is untouched

test_connection had the same pattern, where the cost was a false Access denied sending the user off to debug credentials that were fine.

Worth noting get_password already distinguished NoEntry from a backend error correctly — the information was there, and the command layer threw it away.

The read-only badge (#277)

Enforcement landed in #522. The other half of that issue is that a read-only connection looks like any other until the executor refuses something — a guard the user can't see is one they meet by surprise. Read-only connections now carry a lock in their tab.

Two things found while testing

ConnectionTabs.test.tsx's mocks were never applying. vi.mock specifiers resolve relative to the test file, not the component, so "../../stores/connectionStore" pointed at src/components/stores/… — which doesn't exist. Every mock in that file was inert; the tests ran against the real stores and asserted only things that held either way. That's why my new test rendered an empty tab bar. Fixed.

Three ConnectionStore tests were over-ignored by my own change in #516. They touch only the store and an in-memory keyring, so the blanket #[ignore] was wrong for them. They're back on the ordinary test path — and since CI's Rust job has no database services, a green run is the proof they need none.

Unit tests 71 → 77, integration 66 → 63 (the same three, relocated). 1653 frontend tests. clippy/tsc/dprint clean.

🤖 Generated with Claude Code

The frontend never receives credentials, so on edit it sends them back
absent, and the command layer fills them in from the store. It did that with
`if let Ok(stored)`, which treats every failure the same way: a keyring that
is locked, sandboxed or momentarily unavailable looked exactly like "this
profile has no stored password". The field stayed empty, and `save()` reads an
empty password as "the user cleared it" and calls `delete_password`. The user
edits a profile name, sees a success toast, and the credential is gone.

`ConnectionStore::get_existing` now returns `Option`, so the two outcomes have
different types and the call site has to decide. A profile that does not exist
is `None` — a new profile, where empty really is the intent. Anything else is
an error, and the save is refused with a message saying that nothing was
written and the stored password is untouched. `test_connection` had the same
pattern, where the cost was a false "Access denied" sending the user off to
debug credentials that were fine.

Also completes #277. Enforcement landed in #522; the other half of that issue
is a connection marked read-only being indistinguishable from any other until
the executor refuses something. Read-only connections now carry a lock in
their tab.

Two things found while testing:

The mock specifiers in ConnectionTabs.test.tsx resolve relative to the test
file, not the component, so `../../stores/connectionStore` pointed at
`src/components/stores/…`, which does not exist. None of that file's mocks
were ever applied — the tests ran against the real stores and asserted only
things that held either way. Fixed, which is what let the new tests render a
tab at all.

Three ConnectionStore tests were swept up by the blanket #[ignore] in #516.
They touch only the store and an in-memory keyring, so they are back on the
ordinary test path where they belong; CI has no database services, so a green
Test Rust job is the proof they need none.

Refs #274, #277
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant