starting accounts #2

Open
qpismont wants to merge 15 commits from accounts into main
6 changed files with 12 additions and 8 deletions
Showing only changes of commit 9d544c7e8a - Show all commits

View file

@ -3,7 +3,7 @@ when:
steps: steps:
- name: build - name: build
image: golang:1.24-alpine image: golang:1.24.1-alpine
commands: commands:
- apk update - apk update
- apk add bash - apk add bash

View file

@ -3,7 +3,7 @@ when:
steps: steps:
- name: lint - name: lint
image: golang:1.24-alpine image: golang:1.24.1-alpine
commands: commands:
- apk update - apk update
- apk add bash curl jq - apk add bash curl jq

View file

@ -3,7 +3,7 @@ when:
steps: steps:
- name: tests - name: tests
image: golang:1.24-alpine image: golang:1.24.1-alpine
environment: environment:
TEST_DB_HOST: db TEST_DB_HOST: db
TEST_DB_PORT: 5432 TEST_DB_PORT: 5432

View file

@ -9,7 +9,7 @@ import (
) )
func TestRepository_Insert(t *testing.T) { func TestRepository_Insert(t *testing.T) {
db := test.SetupTestDB(t, "../..") db := test.SetupTestDB(t, "../../..")
defer db.Close() defer db.Close()
repo := NewRepository(db) repo := NewRepository(db)
@ -29,7 +29,7 @@ func TestRepository_Insert(t *testing.T) {
} }
func TestRepository_FetchOneByUsername(t *testing.T) { func TestRepository_FetchOneByUsername(t *testing.T) {
db := test.SetupTestDB(t, "../..") db := test.SetupTestDB(t, "../../..")
defer db.Close() defer db.Close()
repo := NewRepository(db) repo := NewRepository(db)

View file

@ -32,6 +32,10 @@ func (s *Service) Login(login domain.AccountLogin) (*domain.AccountWithToken, *c
return nil, core.NewInternalServerError(err) return nil, core.NewInternalServerError(err)
} }
if account == nil {
return nil, domain.ErrAccountNotFound
}
ok, err := core.ComparePassword(login.Password, account.Password) ok, err := core.ComparePassword(login.Password, account.Password)
if err != nil { if err != nil {
return nil, domain.ErrBadPassword return nil, domain.ErrBadPassword

View file

@ -19,9 +19,9 @@ func TestJWT_GenerateToken(t *testing.T) {
assert.NotEmpty(t, token) assert.NotEmpty(t, token)
claims, err := VerifyJWT(token) claims, jwtErr := VerifyJWT(token)
if err != nil { if jwtErr != nil {
t.Fatalf("Failed to verify token: %v", err) t.Fatalf("Failed to verify token: %v", jwtErr)
} }
assert.Equal(t, claims.AccountId, 1) assert.Equal(t, claims.AccountId, 1)