api: adding a gRPC call for listing passwords.

This commit is contained in:
rithu john
2016-11-17 14:50:58 -08:00
parent 19c22807a7
commit ee9738d663
4 changed files with 150 additions and 40 deletions

View File

@@ -5,6 +5,7 @@ package conformance
import (
"reflect"
"sort"
"testing"
"time"
@@ -244,6 +245,12 @@ func testRefreshTokenCRUD(t *testing.T, s storage.Storage) {
}
}
type byEmail []storage.Password
func (n byEmail) Len() int { return len(n) }
func (n byEmail) Less(i, j int) bool { return n[i].Email < n[j].Email }
func (n byEmail) Swap(i, j int) { n[i], n[j] = n[j], n[i] }
func testPasswordCRUD(t *testing.T, s storage.Storage) {
// Use bcrypt.MinCost to keep the tests short.
passwordHash, err := bcrypt.GenerateFromPassword([]byte("secret"), bcrypt.MinCost)
@@ -294,6 +301,8 @@ func testPasswordCRUD(t *testing.T, s storage.Storage) {
t.Errorf("list password: %v", err)
return
}
sort.Sort(byEmail(want))
sort.Sort(byEmail(passwords))
if diff := pretty.Compare(want, passwords); diff != "" {
t.Errorf("password list retrieved from storage did not match: %s", diff)
}