auth

Paddy 2014-09-07 Parent:043906283c65 Child:1f7b44b130a0

33:607708cd8829 Go to Latest

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.

History
paddy@27 1 package auth
paddy@27 2
paddy@27 3 import (
paddy@27 4 "time"
paddy@27 5
paddy@27 6 "secondbit.org/uuid"
paddy@27 7 )
paddy@27 8
paddy@27 9 type Profile struct {
paddy@27 10 ID uuid.ID
paddy@27 11 Name string
paddy@27 12 Passphrase string
paddy@27 13 Email string
paddy@27 14 Created time.Time
paddy@27 15 LastSeen time.Time
paddy@27 16 }
paddy@27 17
paddy@27 18 type Login struct {
paddy@27 19 Type string
paddy@27 20 Value string
paddy@27 21 ProfileID uuid.ID
paddy@27 22 Created time.Time
paddy@27 23 LastUsed time.Time
paddy@27 24 }
paddy@27 25
paddy@27 26 type ProfileStore interface {
paddy@27 27 GetProfileByID(id uuid.ID) (Profile, error)
paddy@27 28 GetProfileByLogin(loginType, value, passphrase string) (Profile, error)
paddy@27 29 SaveProfile(user Profile) error
paddy@27 30 UpdateProfile(id uuid.ID, name, passphrase, email *string) error
paddy@27 31 DeleteProfile(id uuid.ID) error
paddy@27 32
paddy@27 33 SaveLogin(login Login) error
paddy@27 34 DeleteLogin(login Login) error
paddy@27 35 UpdateLogin(id uuid.ID, lastUsed time.Time) error
paddy@27 36 }