Prove a password still verifies after the database is reopened
ci / vet-and-test (pull_request) Successful in 49s
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:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user