functional: test Admin field serialization

This commit is contained in:
Bobby Rullo 2016-04-18 17:08:07 -07:00
parent e7141336bc
commit 3442a5af1c

View file

@ -257,6 +257,42 @@ func TestDBClientRepoNewDuplicate(t *testing.T) {
} }
} }
func TestDBClientRepoNewAdmin(t *testing.T) {
for _, admin := range []bool{true, false} {
r := db.NewClientRepo(connect(t))
if _, err := r.New(client.Client{
Credentials: oidc.ClientCredentials{
ID: "foo",
},
Metadata: oidc.ClientMetadata{
RedirectURIs: []url.URL{
url.URL{Scheme: "http", Host: "foo.example.com"},
},
},
Admin: admin,
}); err != nil {
t.Fatalf("expected non-nil error: %v", err)
}
gotAdmin, err := r.IsDexAdmin("foo")
if err != nil {
t.Fatalf("expected non-nil error")
}
if gotAdmin != admin {
t.Errorf("want=%v, gotAdmin=%v", admin, gotAdmin)
}
cli, err := r.Get("foo")
if err != nil {
t.Fatalf("expected non-nil error")
}
if cli.Admin != admin {
t.Errorf("want=%v, cli.Admin=%v", admin, cli.Admin)
}
}
}
func TestDBClientRepoAuthenticate(t *testing.T) { func TestDBClientRepoAuthenticate(t *testing.T) {
r := db.NewClientRepo(connect(t)) r := db.NewClientRepo(connect(t))