auth
45:3a6a65ed380c Browse Files
Update uuid import path, test for multiple profile updates. Test updating multiple profiles in one request (e.g., when profiles become compromised.) Update the uuid import path to use the new code.secondbit.org/uuid import path.
client.go client_test.go grant.go grant_test.go memstore.go profile.go profile_test.go token.go token_test.go
1.1 --- a/client.go Fri Sep 19 00:05:35 2014 -0400 1.2 +++ b/client.go Sat Sep 27 20:51:19 2014 -0400 1.3 @@ -5,8 +5,8 @@ 1.4 "net/url" 1.5 "time" 1.6 1.7 + "code.secondbit.org/uuid" 1.8 "strings" 1.9 - "secondbit.org/uuid" 1.10 ) 1.11 1.12 var (
2.1 --- a/client_test.go Fri Sep 19 00:05:35 2014 -0400 2.2 +++ b/client_test.go Sat Sep 27 20:51:19 2014 -0400 2.3 @@ -6,8 +6,8 @@ 2.4 "testing" 2.5 "time" 2.6 2.7 + "code.secondbit.org/uuid" 2.8 "sort" 2.9 - "secondbit.org/uuid" 2.10 ) 2.11 2.12 const (
3.1 --- a/grant.go Fri Sep 19 00:05:35 2014 -0400 3.2 +++ b/grant.go Sat Sep 27 20:51:19 2014 -0400 3.3 @@ -4,7 +4,7 @@ 3.4 "errors" 3.5 "time" 3.6 3.7 - "secondbit.org/uuid" 3.8 + "code.secondbit.org/uuid" 3.9 ) 3.10 3.11 var (
4.1 --- a/grant_test.go Fri Sep 19 00:05:35 2014 -0400 4.2 +++ b/grant_test.go Sat Sep 27 20:51:19 2014 -0400 4.3 @@ -4,7 +4,7 @@ 4.4 "testing" 4.5 "time" 4.6 4.7 - "secondbit.org/uuid" 4.8 + "code.secondbit.org/uuid" 4.9 ) 4.10 4.11 var grantStores = []GrantStore{NewMemstore()}
5.1 --- a/memstore.go Fri Sep 19 00:05:35 2014 -0400 5.2 +++ b/memstore.go Sat Sep 27 20:51:19 2014 -0400 5.3 @@ -3,7 +3,7 @@ 5.4 import ( 5.5 "sync" 5.6 5.7 - "secondbit.org/uuid" 5.8 + "code.secondbit.org/uuid" 5.9 ) 5.10 5.11 type Memstore struct {
6.1 --- a/profile.go Fri Sep 19 00:05:35 2014 -0400 6.2 +++ b/profile.go Sat Sep 27 20:51:19 2014 -0400 6.3 @@ -4,7 +4,7 @@ 6.4 "errors" 6.5 "time" 6.6 6.7 - "secondbit.org/uuid" 6.8 + "code.secondbit.org/uuid" 6.9 ) 6.10 6.11 var (
7.1 --- a/profile_test.go Fri Sep 19 00:05:35 2014 -0400 7.2 +++ b/profile_test.go Sat Sep 27 20:51:19 2014 -0400 7.3 @@ -5,7 +5,7 @@ 7.4 "testing" 7.5 "time" 7.6 7.7 - "secondbit.org/uuid" 7.8 + "code.secondbit.org/uuid" 7.9 ) 7.10 7.11 const ( 7.12 @@ -221,3 +221,63 @@ 7.13 } 7.14 } 7.15 } 7.16 + 7.17 +func TestProfilesUpdates(t *testing.T) { 7.18 + profile1 := Profile{ 7.19 + ID: uuid.NewID(), 7.20 + } 7.21 + profile2 := Profile{ 7.22 + ID: uuid.NewID(), 7.23 + } 7.24 + profile3 := Profile{ 7.25 + ID: uuid.NewID(), 7.26 + } 7.27 + truth := true 7.28 + change := BulkProfileChange{ 7.29 + Compromised: &truth, 7.30 + } 7.31 + for _, store := range profileStores { 7.32 + err := store.SaveProfile(profile1) 7.33 + if err != nil { 7.34 + t.Errorf("Error saving profile in %T: %s", store, err) 7.35 + } 7.36 + err = store.SaveProfile(profile2) 7.37 + if err != nil { 7.38 + t.Errorf("Error saving profile in %T: %s", store, err) 7.39 + } 7.40 + err = store.SaveProfile(profile3) 7.41 + if err != nil { 7.42 + t.Errorf("Error saving profile in %T: %s", store, err) 7.43 + } 7.44 + err = store.UpdateProfiles([]uuid.ID{profile1.ID, profile3.ID}, change) 7.45 + if err != nil { 7.46 + t.Errorf("Error updating profile in %T: %s", store, err) 7.47 + } 7.48 + profile1.Compromised = truth 7.49 + profile3.Compromised = truth 7.50 + retrieved, err := store.GetProfileByID(profile1.ID) 7.51 + if err != nil { 7.52 + t.Errorf("Error getting profile from %T: %s", store, err) 7.53 + } 7.54 + match, field, expected, got := compareProfiles(profile1, retrieved) 7.55 + if !match { 7.56 + t.Errorf("Expected field `%s` to be `%v`, got `%v` from %T", field, expected, got, store) 7.57 + } 7.58 + retrieved, err = store.GetProfileByID(profile2.ID) 7.59 + if err != nil { 7.60 + t.Errorf("Error getting profile from %T: %s", store, err) 7.61 + } 7.62 + match, field, expected, got = compareProfiles(profile2, retrieved) 7.63 + if !match { 7.64 + t.Errorf("Expected field `%s` to be `%v`, got `%v` from %T", field, expected, got, store) 7.65 + } 7.66 + retrieved, err = store.GetProfileByID(profile3.ID) 7.67 + if err != nil { 7.68 + t.Errorf("Error getting profile from %T: %s", store, err) 7.69 + } 7.70 + match, field, expected, got = compareProfiles(profile3, retrieved) 7.71 + if !match { 7.72 + t.Errorf("Expected field `%s` to be `%v`, got `%v` from %T", field, expected, got, store) 7.73 + } 7.74 + } 7.75 +}