test(accounts): assert removed-account secrets are pruned from the state file#18
Open
iceteaSA wants to merge 1 commit into
Open
test(accounts): assert removed-account secrets are pruned from the state file#18iceteaSA wants to merge 1 commit into
iceteaSA wants to merge 1 commit into
Conversation
…ate file The removal test verified the config file no longer lists the deleted id, but not that the per-account state file is scrubbed of the removed account's access/refresh tokens. A regression that rebuilt config authoritatively while leaving stale state entries would leave a deleted account's credentials at rest and pass the existing assertions. Extend the test to assert state.accounts drops the removed id and the raw state file contains neither of its tokens.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extends the existing
mutateAccountsremoval test (accounts-store.test.ts) to assert that a removed account's per-account secrets are scrubbed from the state file, not just that the config file's id list no longer contains it.Test-only — zero production change (
core/accounts.tsis byte-identical tomain).Why
mutateAccountswrites the config authoritatively and rebuilds the state file viastateFromStorage(next), so a removed account'saccess/refreshtokens are already pruned. But the removal test only verified the config file:A regression that rebuilt the config authoritatively while leaving the state entries merged in (e.g. unioning stale on-disk state into the rebuild) would leave a deleted account's credentials at rest — a credential leak — and still pass every existing assertion. The state file is where the tokens actually live, so it's the security-relevant surface to pin.
The added assertions
Verification
state.accountskeys['a','b','c']≠['a','c']); reverting restores green. So it guards the real regression, not just current behavior.Context: this is the one piece of #17 not already covered by
38df1ff(which independently landed the samemutateAccountsfix). Closed #17 as superseded and salvaged this test as a focused standalone.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Extend the
mutateAccountsremoval test to verify the state file drops the deleted account and its tokens, preventing stale credentials at rest. Test-only change; production code unchanged.Written for commit a9f2379. Summary will update on new commits.