auth
auth/profile.go
Add more tests for ClientStores. Test that deleting a client that doesn't exist throws an ErrClientNotFound. Test that adding a client twice returns an ErrClientAlreadyExists. Test that clients retrieve have properties that all match the client that was stored. Remove the unused error return from the internal MemoryStore helper for getting a list of clients by their OwnerID. If a profile doesn't exist, return an empty list of clients, as we're technically returning any client that has that OwnerID. There's no guarantee that that OwnerID is actually valid.
1 package auth
3 import (
4 "time"
6 "secondbit.org/uuid"
7 )
9 type Profile struct {
10 ID uuid.ID
11 Name string
12 Passphrase string
13 Email string
14 Created time.Time
15 LastSeen time.Time
16 }
18 type Login struct {
19 Type string
20 Value string
21 ProfileID uuid.ID
22 Created time.Time
23 LastUsed time.Time
24 }
26 type ProfileStore interface {
27 GetProfileByID(id uuid.ID) (Profile, error)
28 GetProfileByLogin(loginType, value, passphrase string) (Profile, error)
29 SaveProfile(user Profile) error
30 UpdateProfile(id uuid.ID, name, passphrase, email *string) error
31 DeleteProfile(id uuid.ID) error
33 SaveLogin(login Login) error
34 DeleteLogin(login Login) error
35 UpdateLogin(id uuid.ID, lastUsed time.Time) error
36 }