Documentation ¶
Overview ¶
Package candidtest provides suites and functions useful for testing the identity manager.
Index ¶
- Variables
- func AssertEqualIdentity(c *qt.C, obtained, expected *store.Identity)
- func BakeryClient(i httpbakery.Interactor) *httpbakery.Client
- func LogTo(c *qt.C)
- type DischargeCreator
- func (s *DischargeCreator) AssertDischarge(c *qt.C, i httpbakery.Interactor)
- func (s *DischargeCreator) AssertMacaroon(c *qt.C, ms macaroon.Slice, op bakery.Op, id string)
- func (s *DischargeCreator) Discharge(c *qt.C, condition string, client *httpbakery.Client) (macaroon.Slice, error)
- func (s *DischargeCreator) NewMacaroon(c *qt.C, condition string, op bakery.Op) *bakery.Macaroon
- type NoVisit
- type Server
- func (s *Server) AdminClient() *httpbakery.Client
- func (s *Server) AdminIdentityClient() *candidclient.Client
- func (s *Server) Client(i httpbakery.Interactor) *httpbakery.Client
- func (s *Server) CreateAgent(c *qt.C, username string, groups ...string) *bakery.KeyPair
- func (s *Server) CreateUser(c *qt.C, name string, groups ...string) string
- func (s *Server) Do(c *qt.C, req *http.Request) *http.Response
- func (s *Server) Get(c *qt.C, url string) *http.Response
- func (s *Server) IdentityClient(c *qt.C, username string, groups ...string) *candidclient.Client
- func (s *Server) RoundTrip(c *qt.C, req *http.Request) *http.Response
- func (s *Server) ThirdPartyInfo(ctx context.Context, loc string) (bakery.ThirdPartyInfo, error)
- type Store
- type VisitorFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultTemplate = template.New("")
Functions ¶
func AssertEqualIdentity ¶
AssertEqualIdentity asserts that the two provided identites are semantically equivilent.
func BakeryClient ¶
func BakeryClient(i httpbakery.Interactor) *httpbakery.Client
BakeryClient creates a new httpbakery.Client which uses the given visitor as its WebPageVisitor. If no Visitor is specified then NoVisit will be used.
Types ¶
type DischargeCreator ¶
type DischargeCreator struct { ServerURL string Bakery *identchecker.Bakery // contains filtered or unexported fields }
DischargeCreator represents a third party service that creates discharges addressed to Candid.
func NewDischargeCreator ¶
func NewDischargeCreator(server *Server) *DischargeCreator
NewDischargeCreator returns a DischargeCreator that creates third party caveats addressed to the given server, which must be serving the "discharger" API.
func (*DischargeCreator) AssertDischarge ¶
func (s *DischargeCreator) AssertDischarge(c *qt.C, i httpbakery.Interactor)
AssertDischarge checks that a macaroon can be discharged with interaction using the specified visitor.
func (*DischargeCreator) AssertMacaroon ¶
AssertMacaroon asserts that the given macaroon slice is valid for the given operation. If id is specified then the declared identity in the macaroon is checked to be the same as id.
func (*DischargeCreator) Discharge ¶
func (s *DischargeCreator) Discharge(c *qt.C, condition string, client *httpbakery.Client) (macaroon.Slice, error)
Discharge attempts to perform a discharge of a new macaroon against this suites identity server using the given client and returns a macaroon slice containing a discharged macaroon or any error. The newly minted macaroon will have a third-party caveat addressed to the identity server with the given condition.
func (*DischargeCreator) NewMacaroon ¶
NewMacaroon creates a new macaroon with a third-party caveat addressed to the identity server which has the given condition.
type NoVisit ¶
type NoVisit struct{}
NoVisit is a httpbakery.Visitor that returns an error without attempting a visit.
type Server ¶
type Server struct { // URL contains the URL of the server. URL string // Ctx contains a context.Context that has been initialised with // the servers. Ctx context.Context // Key holds the key that the server uses. Key *bakery.KeyPair // contains filtered or unexported fields }
Server implements a test fixture that contains a candid server.
func NewMemServer ¶
NewMemServer returns a Server instance that uses in-memory storage and serves the given API version
func NewServer ¶
func NewServer(c *qt.C, p identity.ServerParams, versions map[string]identity.NewAPIHandlerFunc) *Server
NewServer returns new Server instance. The server parameters must contain at least Store, MeetingStore and RootKeyStore. The versions argument configures what API versions to serve.
If p.Key is zero then a new key will be generated. If p.PrivateAddr is zero then it will default to localhost. If p.Template is zero then DefaultTemplate will be used.
func (*Server) AdminClient ¶
func (s *Server) AdminClient() *httpbakery.Client
AdminClient creates a new httpbakery.Client that is configured to log in as an admin user.
func (*Server) AdminIdentityClient ¶
func (s *Server) AdminIdentityClient() *candidclient.Client
AdminIdentityClient creates a new candidclient.Client that is configured to log in as an admin user.
func (*Server) Client ¶
func (s *Server) Client(i httpbakery.Interactor) *httpbakery.Client
Client is a convenience method that returns the result of calling BakeryClient(i)
func (*Server) CreateAgent ¶
CreateAgent creates a new agent user in the identity server's store with the given name and groups. The agent's username and key are returned.
The agent will be owned by admin@candid.
func (*Server) CreateUser ¶
CreateUser creates a new user in the identity server's store with the given name and groups. The user's username is returned.
func (*Server) Do ¶
Do is a convenience function for performing HTTP requests against the server. The server's URL will be prepended to the one specified in the request and then the request will be performed using http.DefaultClient.
func (*Server) Get ¶
Get is a convenience function for performing HTTP requests against the server. The server's URL will be prepended to the one given and then the GET will be performed using http.DefaultClient.
func (*Server) IdentityClient ¶
IdentityClient creates a new agent with the given username (which must end in @candid) and groups and then creates an candidclient.Client which authenticates using that agent.
func (*Server) RoundTrip ¶
RoundTrip is a convenience function for performing a single HTTP requests against the server. The server's URL will be prepended to the one specified in the request and then a single request will be performed using http.DefaultTransport.
func (*Server) ThirdPartyInfo ¶
ThirdPartyInfo implements bakery.ThirdPartyLocator.ThirdPartyInfo allowing the suite to be used as a bakery.ThirdPartyLocator.
type Store ¶
type Store struct { Store store.Store ProviderDataStore store.ProviderDataStore MeetingStore meeting.Store BakeryRootKeyStore bakery.RootKeyStore ACLStore aclstore.ACLStore }
Store implements a test fixture that contains memory-based store implementations for use with tests.
func (*Store) AssertUser ¶
AssertUser asserts that the specified user is stored in the store. It returns the stored identity.
func (*Store) ServerParams ¶
func (s *Store) ServerParams() identity.ServerParams
ServerParams returns parameters suitable for passing to NewServer that will use s as its store.
type VisitorFunc ¶
A VisitorFunc converts a function to a httpbakery.LegacyInteractor.
func (VisitorFunc) LegacyInteract ¶
func (f VisitorFunc) LegacyInteract(ctx context.Context, _ *httpbakery.Client, _ string, u *url.URL) error
LegacyInteract implements httpbakery.LegacyInteractor.LegacyInteract.