From 3442a5af1c6ddfead0472f500d3e0f98db241ea1 Mon Sep 17 00:00:00 2001 From: Bobby Rullo Date: Mon, 18 Apr 2016 17:08:07 -0700 Subject: [PATCH] functional: test Admin field serialization --- functional/db_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/functional/db_test.go b/functional/db_test.go index a62bb446..ecbff9ae 100644 --- a/functional/db_test.go +++ b/functional/db_test.go @@ -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) { r := db.NewClientRepo(connect(t))