auth

Paddy 2014-09-01 Parent:5bf0a5fd1d01 Child:14599a5c7819

31:88523dab00a5 Go to Latest

auth/grant_test.go

Implement ClientStore in Memstore. Add the ClientStore interface implementation to Memstore. Change the ClientStore interface's UpdateClient function to take a new type, ClientChange, rather than enumerating the arguments in the function signature, which is a much cleaner interface. Add tests for the successful (works-as-intended) scenarios involving ClientStores. Ignore UpdateClient for now--I want to do tests that test every combination of ClientUpdate attributes being specified, to be sure that only the attributes specified are updated and that all the attributes specified are updated.

History
1 package auth
3 import (
4 "testing"
5 "time"
7 "secondbit.org/uuid"
8 )
10 var grantStores = []GrantStore{NewMemstore()}
12 func TestGrantStoreSuccess(t *testing.T) {
13 grant := Grant{
14 Code: "code",
15 Created: time.Now(),
16 ExpiresIn: 180,
17 ClientID: uuid.NewID(),
18 Scope: "scope",
19 RedirectURI: "redirectURI",
20 State: "state",
21 }
22 for pos, store := range grantStores {
23 err := store.SaveGrant(grant)
24 if err != nil {
25 t.Errorf("Error saving grant in GrantStore #%d: %s", pos, err)
26 }
27 retrieved, err := store.GetGrant(grant.Code)
28 if err != nil {
29 t.Errorf("Error retrieving grant in GrantStore #%d: %s", pos, err)
30 }
31 t.Log(retrieved)
32 // TODO: compare retrieved to grant
33 err = store.DeleteGrant(grant.Code)
34 if err != nil {
35 t.Errorf("Error removing grant from GrantStore #%d: %s", pos, err)
36 }
37 retrieved, err = store.GetGrant(grant.Code)
38 if err != ErrGrantNotFound {
39 t.Errorf("Expected ErrGrantNotFound from GrantStore #%d, got %+v and %+v", pos, retrieved, err)
40 }
41 }
42 }