Documentation ¶
Overview ¶
Package idmtest holds a mock implementation of the identity manager suitable for testing.
Index ¶
- Constants
- type Server
- func (srv *Server) AddUser(name string, groups ...string)
- func (srv *Server) Client(username string) *httpbakery.Client
- func (srv *Server) Close()
- func (srv *Server) IDMClient(username string) *idmclient.Client
- func (srv *Server) PublicKeyForLocation(loc string) (*bakery.PublicKey, error)
- func (srv *Server) RemoveUser(user string)
- func (srv *Server) RemoveUsers()
- func (srv *Server) SetDefaultUser(name string)
- func (srv *Server) ThirdPartyInfo(ctx context.Context, loc string) (bakery.ThirdPartyInfo, error)
- func (srv *Server) UserPublicKey(username string) *bakery.KeyPair
Constants ¶
const GroupListGroup = "group-lister"
GroupListGroup is the group that users must belong to in order to enquire about other users' groups.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct { // URL holds the URL of the mock identity server. // The discharger endpoint is located at URL/v1/discharge. URL *url.URL // PublicKey holds the public key of the mock identity server. PublicKey *bakery.PublicKey // Bakery holds the macaroon bakery used by // the mock server. Bakery *identchecker.Bakery // contains filtered or unexported fields }
Server represents a mock identity server. It currently serves only the discharge and groups endpoints.
func NewServer ¶
func NewServer() *Server
NewServer runs a mock identity server. It can discharge macaroons and return information on user group membership. The returned server should be closed after use.
func (*Server) AddUser ¶
AddUser adds a new user that's in the given set of groups. If the user already exists, the given groups are added to that user's groups.
func (*Server) Client ¶
func (srv *Server) Client(username string) *httpbakery.Client
Client returns a bakery client that will discharge as the given user. If the user does not exist, it is added with no groups.
func (*Server) IDMClient ¶
IDMClient returns an identity manager client that takes to the given server as the given user name.
func (*Server) PublicKeyForLocation ¶
PublicKeyForLocation implements bakery.PublicKeyLocator by returning the server's public key for all locations.
func (*Server) RemoveUser ¶
RemoveUser removes the given user.
func (*Server) RemoveUsers ¶
func (srv *Server) RemoveUsers()
RemoveUsers removes all added users and resets the default user to nothing.
func (*Server) SetDefaultUser ¶
SetDefaultUser configures the server so that it will discharge for the given user if no agent-login cookie is found. The user does not need to have been added. Note that this will bypass the VisitURL logic.
If the name is empty, there will be no default user.
func (*Server) ThirdPartyInfo ¶
ThirdPartyInfo implements bakery.ThirdPartyLocator.ThirdPartyInfo.