idmtest

package
v0.0.0-...-98ac3e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2016 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package idmtest holds a mock implementation of the identity manager suitable for testing.

Index

Constants

This section is empty.

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
	// 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

func (srv *Server) AddUser(name string, groups ...string)

AddUser adds a new user that's in the given set of 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) Close

func (srv *Server) Close()

Close shuts down the server.

func (*Server) PublicKeyForLocation

func (srv *Server) PublicKeyForLocation(loc string) (*bakery.PublicKey, error)

PublicKeyForLocation implements bakery.PublicKeyLocator by returning the server's public key for all locations.

func (*Server) SetDefaultUser

func (srv *Server) SetDefaultUser(name string)

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) UserPublicKey

func (srv *Server) UserPublicKey(username string) *bakery.KeyPair

UserPublicKey returns the key for the given user. It panics if the user has not been added.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL