Prove a password still verifies after the database is reopened
ci / vet-and-test (pull_request) Successful in 49s

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 <cursoragent@cursor.com>
This commit is contained in:
2026-10-12 14:52:21 +00:00
co-authored by Cursor
parent f13e8b1ab7
commit 545a75b54e
+26
View File
@@ -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"))