| OLD | NEW |
| 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" | |
| 13 | |
| 14 "github.com/luci/luci-go/server/auth" | 12 "github.com/luci/luci-go/server/auth" |
| 15 "github.com/luci/luci-go/server/auth/authdb" | 13 "github.com/luci/luci-go/server/auth/authdb" |
| 16 "github.com/luci/luci-go/server/auth/identity" | 14 "github.com/luci/luci-go/server/auth/identity" |
| 17 "github.com/luci/luci-go/server/auth/signing" | 15 "github.com/luci/luci-go/server/auth/signing" |
| 18 ) | 16 ) |
| 19 | 17 |
| 20 // FakeDB implements user group checking part of db.DB (IsMember). | 18 // FakeDB implements user group checking part of db.DB (IsMember). |
| 21 // | 19 // |
| 22 // It is a mapping "identity -> list of its groups". Intended to be used mostly | 20 // It is a mapping "identity -> list of its groups". Intended to be used mostly |
| 23 // for testing request handlers, thus all other DB methods (that used by auth | 21 // for testing request handlers, thus all other DB methods (that used by auth |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 } | 47 } |
| 50 } | 48 } |
| 51 return false, nil | 49 return false, nil |
| 52 } | 50 } |
| 53 | 51 |
| 54 // IsAllowedOAuthClientID is part of authdb.DB interface. Panics. | 52 // IsAllowedOAuthClientID is part of authdb.DB interface. Panics. |
| 55 func (db FakeDB) IsAllowedOAuthClientID(c context.Context, email, clientID strin
g) (bool, error) { | 53 func (db FakeDB) IsAllowedOAuthClientID(c context.Context, email, clientID strin
g) (bool, error) { |
| 56 panic("FakeDB.IsAllowedOAuthClientID must not be called") | 54 panic("FakeDB.IsAllowedOAuthClientID must not be called") |
| 57 } | 55 } |
| 58 | 56 |
| 59 // SharedSecrets is part of authdb.DB interface. Panics. | |
| 60 func (db FakeDB) SharedSecrets(c context.Context) (secrets.Store, error) { | |
| 61 panic("FakeDB.SharedSecrets must not be called") | |
| 62 } | |
| 63 | |
| 64 // GetCertificates is part of authdb.DB interface. Panics. | 57 // GetCertificates is part of authdb.DB interface. Panics. |
| 65 func (db FakeDB) GetCertificates(c context.Context, id identity.Identity) (*sign
ing.PublicCertificates, error) { | 58 func (db FakeDB) GetCertificates(c context.Context, id identity.Identity) (*sign
ing.PublicCertificates, error) { |
| 66 panic("FakeDB.GetCertificates must not be called") | 59 panic("FakeDB.GetCertificates must not be called") |
| 67 } | 60 } |
| 68 | 61 |
| 69 // GetWhitelistForIdentity is part of authdb.DB interface. Panics. | 62 // GetWhitelistForIdentity is part of authdb.DB interface. Panics. |
| 70 func (db FakeDB) GetWhitelistForIdentity(c context.Context, ident identity.Ident
ity) (string, error) { | 63 func (db FakeDB) GetWhitelistForIdentity(c context.Context, ident identity.Ident
ity) (string, error) { |
| 71 panic("FakeDB.GetWhitelistForIdentity must not be called") | 64 panic("FakeDB.GetWhitelistForIdentity must not be called") |
| 72 } | 65 } |
| 73 | 66 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 99 |
| 107 // Use installs the fake db into the context. | 100 // Use installs the fake db into the context. |
| 108 func (db *FakeErroringDB) Use(c context.Context) context.Context { | 101 func (db *FakeErroringDB) Use(c context.Context) context.Context { |
| 109 return auth.ModifyConfig(c, func(cfg auth.Config) auth.Config { | 102 return auth.ModifyConfig(c, func(cfg auth.Config) auth.Config { |
| 110 cfg.DBProvider = func(context.Context) (authdb.DB, error) { | 103 cfg.DBProvider = func(context.Context) (authdb.DB, error) { |
| 111 return db, nil | 104 return db, nil |
| 112 } | 105 } |
| 113 return cfg | 106 return cfg |
| 114 }) | 107 }) |
| 115 } | 108 } |
| OLD | NEW |