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

Side by Side Diff: server/auth/authtest/db.go

Issue 2386643003: auth: Make luci-go services trust signatures produced by the token server. (Closed)
Patch Set: add tests Created 4 years, 2 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/authdb/snapshot_test.go ('k') | server/auth/delegation/checker.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 authtest 5 package authtest
6 6
7 import ( 7 import (
8 "net" 8 "net"
9 9
10 "golang.org/x/net/context" 10 "golang.org/x/net/context"
11 11
12 "github.com/luci/luci-go/server/secrets" 12 "github.com/luci/luci-go/server/secrets"
13 13
14 "github.com/luci/luci-go/server/auth" 14 "github.com/luci/luci-go/server/auth"
15 "github.com/luci/luci-go/server/auth/authdb" 15 "github.com/luci/luci-go/server/auth/authdb"
16 "github.com/luci/luci-go/server/auth/identity" 16 "github.com/luci/luci-go/server/auth/identity"
17 "github.com/luci/luci-go/server/auth/signing"
17 ) 18 )
18 19
19 // FakeDB implements user group checking part of db.DB (IsMember). 20 // FakeDB implements user group checking part of db.DB (IsMember).
20 // 21 //
21 // It is a mapping "identity -> list of its groups". Intended to be used mostly 22 // It is a mapping "identity -> list of its groups". Intended to be used mostly
22 // for testing request handlers, thus all other DB methods (that used by auth 23 // for testing request handlers, thus all other DB methods (that used by auth
23 // system when authenticating the request) is not implement and panic when 24 // system when authenticating the request) is not implement and panic when
24 // called: the wast majority of request handlers are not calling them. 25 // called: the wast majority of request handlers are not calling them.
25 type FakeDB map[identity.Identity][]string 26 type FakeDB map[identity.Identity][]string
26 27
(...skipping 23 matching lines...) Expand all
50 // IsAllowedOAuthClientID is part of authdb.DB interface. Panics. 51 // IsAllowedOAuthClientID is part of authdb.DB interface. Panics.
51 func (db FakeDB) IsAllowedOAuthClientID(c context.Context, email, clientID strin g) (bool, error) { 52 func (db FakeDB) IsAllowedOAuthClientID(c context.Context, email, clientID strin g) (bool, error) {
52 panic("FakeDB.IsAllowedOAuthClientID must not be called") 53 panic("FakeDB.IsAllowedOAuthClientID must not be called")
53 } 54 }
54 55
55 // SharedSecrets is part of authdb.DB interface. Panics. 56 // SharedSecrets is part of authdb.DB interface. Panics.
56 func (db FakeDB) SharedSecrets(c context.Context) (secrets.Store, error) { 57 func (db FakeDB) SharedSecrets(c context.Context) (secrets.Store, error) {
57 panic("FakeDB.SharedSecrets must not be called") 58 panic("FakeDB.SharedSecrets must not be called")
58 } 59 }
59 60
61 // GetCertificates is part of authdb.DB interface. Panics.
62 func (db FakeDB) GetCertificates(c context.Context, id identity.Identity) (*sign ing.PublicCertificates, error) {
63 panic("FakeDB.GetCertificates must not be called")
64 }
65
60 // GetWhitelistForIdentity is part of authdb.DB interface. Panics. 66 // GetWhitelistForIdentity is part of authdb.DB interface. Panics.
61 func (db FakeDB) GetWhitelistForIdentity(c context.Context, ident identity.Ident ity) (string, error) { 67 func (db FakeDB) GetWhitelistForIdentity(c context.Context, ident identity.Ident ity) (string, error) {
62 panic("FakeDB.GetWhitelistForIdentity must not be called") 68 panic("FakeDB.GetWhitelistForIdentity must not be called")
63 } 69 }
64 70
65 // IsInWhitelist is part of authdb.DB interface. Panics. 71 // IsInWhitelist is part of authdb.DB interface. Panics.
66 func (db FakeDB) IsInWhitelist(c context.Context, ip net.IP, whitelist string) ( bool, error) { 72 func (db FakeDB) IsInWhitelist(c context.Context, ip net.IP, whitelist string) ( bool, error) {
67 panic("FakeDB.IsInWhitelist must not be called") 73 panic("FakeDB.IsInWhitelist must not be called")
68 } 74 }
69 75
(...skipping 26 matching lines...) Expand all
96 } 102 }
97 103
98 // Use installs the fake db into the context. 104 // Use installs the fake db into the context.
99 func (db *FakeErroringDB) Use(c context.Context) context.Context { 105 func (db *FakeErroringDB) Use(c context.Context) context.Context {
100 return auth.ModifyConfig(c, func(cfg *auth.Config) { 106 return auth.ModifyConfig(c, func(cfg *auth.Config) {
101 cfg.DBProvider = func(context.Context) (authdb.DB, error) { 107 cfg.DBProvider = func(context.Context) (authdb.DB, error) {
102 return db, nil 108 return db, nil
103 } 109 }
104 }) 110 })
105 } 111 }
OLDNEW
« no previous file with comments | « server/auth/authdb/snapshot_test.go ('k') | server/auth/delegation/checker.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698