tsk-19: Service login (#23)
Closes #19 Reviewed-on: phoenix/textsender-auth#23 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
@@ -3,11 +3,11 @@ package mock
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"git.kundeng.us/phoenix/textsender-models/pkg/user"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type MockServiceUserStore struct {
|
||||
@@ -53,10 +53,6 @@ func (m *MockServiceUserStore) CheckWithUsername(ctx context.Context, username s
|
||||
return false, m.Error
|
||||
}
|
||||
|
||||
if m.Error != nil {
|
||||
return false, m.Error
|
||||
}
|
||||
|
||||
var exists bool
|
||||
|
||||
for _, serviceUser := range m.ServiceUsers {
|
||||
@@ -72,3 +68,19 @@ func (m *MockServiceUserStore) CheckWithUsername(ctx context.Context, username s
|
||||
return exists, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockServiceUserStore) GetWithUsername(ctx context.Context, username string) (*user.ServiceUser, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
if m.Error != nil {
|
||||
return nil, m.Error
|
||||
}
|
||||
|
||||
serviceUser := m.ServiceUsersByUsername[username]
|
||||
if serviceUser != nil {
|
||||
return serviceUser, nil
|
||||
} else {
|
||||
return nil, fmt.Errorf("User not found")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user