From 545a75b54e52f8fb4dd38474870c05d3436f2e3d Mon Sep 17 00:00:00 2001 From: weichen Date: Mon, 12 Oct 2026 14:52:21 +0000 Subject: [PATCH] Prove a password still verifies after the database is reopened Why: a commit that only checks the password in the same process does not show the hash was durable. Evidence: SELF go test TestPasswordSurvivesReopen. Impact: test only. Refs: docs/svc-deploy/u7-account-tx-audit.md Co-authored-by: Cursor --- internal/store/account_lifecycle_test.go | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/store/account_lifecycle_test.go b/internal/store/account_lifecycle_test.go index 40f3c0f..0004d14 100644 --- a/internal/store/account_lifecycle_test.go +++ b/internal/store/account_lifecycle_test.go @@ -119,6 +119,32 @@ func TestBootstrapRefusesExistingBusiness(t *testing.T) { } } +func TestPasswordSurvivesReopen(t *testing.T) { + path := filepath.Join(t.TempDir(), "agent-system.db") + st, err := OpenSQLite(path) + if err != nil { + t.Fatal(err) + } + hash, err := HashPassword("keep-password") + if err != nil { + t.Fatal(err) + } + if _, err := st.CreateActivatedAccount(AccountWrite{Owner: "ada", Name: "Ada", PasswordHash: hash}); err != nil { + t.Fatal(err) + } + if err := st.Close(); err != nil { + t.Fatal(err) + } + st, err = OpenSQLite(path) + if err != nil { + t.Fatal(err) + } + defer st.Close() + if _, ok := st.VerifyLogin("ada", "keep-password"); !ok { + t.Fatal("password did not survive reopen") + } +} + func openLife(t *testing.T) *Store { t.Helper() st, err := OpenSQLite(filepath.Join(t.TempDir(), "agent-system.db"))