setupMockStoreWithUser creates a mock store with a user account.
(t *testing.T, email, password string)
| 1267 | |
| 1268 | // setupMockStoreWithUser creates a mock store with a user account. |
| 1269 | func setupMockStoreWithUser(t *testing.T, email, password string) *mockStore { |
| 1270 | t.Helper() |
| 1271 | ms := newMockStore() |
| 1272 | hash, salt, kdfP, err := auth.HashUserPassword([]byte(password)) |
| 1273 | if err != nil { |
| 1274 | t.Fatalf("HashUserPassword: %v", err) |
| 1275 | } |
| 1276 | ms.users[email] = &store.User{ |
| 1277 | ID: "user-id", Email: email, |
| 1278 | PasswordHash: hash, PasswordSalt: salt, |
| 1279 | KDFTime: kdfP.Time, KDFMemory: kdfP.Memory, KDFThreads: kdfP.Threads, |
| 1280 | Role: "owner", IsActive: true, |
| 1281 | } |
| 1282 | return ms |
| 1283 | } |
| 1284 | |
| 1285 | func TestLoginSuccess(t *testing.T) { |
| 1286 | ms := setupMockStoreWithUser(t, "admin@test.com", "test-password-123") |
no test coverage detected