Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: server/auth/auth_test.go

Issue 2646543003: server/auth: Add TokenSource call. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « server/auth/addr_test.go ('k') | server/auth/cache_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package auth 5 package auth
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "net" 9 "net"
10 "net/http" 10 "net/http"
11 "testing" 11 "testing"
12 12
13 "golang.org/x/net/context" 13 "golang.org/x/net/context"
14 14
15 "github.com/luci/luci-go/server/secrets" 15 "github.com/luci/luci-go/server/secrets"
16 16
17 "github.com/luci/luci-go/server/auth/authdb" 17 "github.com/luci/luci-go/server/auth/authdb"
18 "github.com/luci/luci-go/server/auth/identity" 18 "github.com/luci/luci-go/server/auth/identity"
19 "github.com/luci/luci-go/server/auth/service/protocol" 19 "github.com/luci/luci-go/server/auth/service/protocol"
20 "github.com/luci/luci-go/server/auth/signing" 20 "github.com/luci/luci-go/server/auth/signing"
21 21
22 . "github.com/luci/luci-go/common/testing/assertions" 22 . "github.com/luci/luci-go/common/testing/assertions"
23 . "github.com/smartystreets/goconvey/convey" 23 . "github.com/smartystreets/goconvey/convey"
24 ) 24 )
25 25
26 func TestAuthenticate(t *testing.T) { 26 func TestAuthenticate(t *testing.T) {
27 t.Parallel()
28
27 Convey("IsAllowedOAuthClientID on default DB", t, func() { 29 Convey("IsAllowedOAuthClientID on default DB", t, func() {
28 c := context.Background() 30 c := context.Background()
29 auth := Authenticator{fakeOAuthMethod{clientID: "some_client_id" }} 31 auth := Authenticator{fakeOAuthMethod{clientID: "some_client_id" }}
30 _, err := auth.Authenticate(c, makeRequest()) 32 _, err := auth.Authenticate(c, makeRequest())
31 So(err, ShouldErrLike, "the library is not properly configured") 33 So(err, ShouldErrLike, "the library is not properly configured")
32 }) 34 })
33 35
34 Convey("IsAllowedOAuthClientID with valid client_id", t, func() { 36 Convey("IsAllowedOAuthClientID with valid client_id", t, func() {
35 c := injectTestDB(context.Background(), &fakeDB{ 37 c := injectTestDB(context.Background(), &fakeDB{
36 allowedClientID: "some_client_id", 38 allowedClientID: "some_client_id",
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 176 }
175 return db.authServiceURL, nil 177 return db.authServiceURL, nil
176 } 178 }
177 179
178 func (db *fakeDB) GetTokenServiceURL(c context.Context) (string, error) { 180 func (db *fakeDB) GetTokenServiceURL(c context.Context) (string, error) {
179 if db.authServiceURL == "" { 181 if db.authServiceURL == "" {
180 return "", errors.New("fakeDB: GetTokenServiceURL is not configu red") 182 return "", errors.New("fakeDB: GetTokenServiceURL is not configu red")
181 } 183 }
182 return db.tokenServiceURL, nil 184 return db.tokenServiceURL, nil
183 } 185 }
OLDNEW
« no previous file with comments | « server/auth/addr_test.go ('k') | server/auth/cache_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698