Documentation ¶
Index ¶
- type Client
- type Fixture
- func (s *Fixture) AssertLoginFailureMatches(c *qt.C, regex string)
- func (s *Fixture) AssertLoginNotComplete(c *qt.C)
- func (s *Fixture) AssertLoginRedirectFailureMatches(c *qt.C, rurl, returnTo, state, errorCode, regex string)
- func (s *Fixture) AssertLoginRedirectSuccess(c *qt.C, rurl, returnTo, state string, username string)
- func (s *Fixture) AssertLoginSuccess(c *qt.C, username string)
- func (s *Fixture) Client(c *qt.C, prefix, replacement, stopPrefix string) *http.Client
- func (s *Fixture) DoInteractiveLogin(c *qt.C, idp idp.IdentityProvider, loginURL string, ...) (*store.Identity, error)
- func (s *Fixture) InitParams(c *qt.C, prefix string) idp.InitParams
- func (s *Fixture) LoginState(c *qt.C, state idputil.LoginState) (*http.Cookie, string)
- func (s *Fixture) ParseResponse(c *qt.C, resp *http.Response) (*store.Identity, error)
- func (f *Fixture) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client allows tests to simulate sending HTTP requests to an IDP.
func NewClient ¶
func NewClient(idp idp.IdentityProvider, codec *secret.Codec) *Client
NewClient create a new client for the given IDP.
func (*Client) SetLoginState ¶
func (c *Client) SetLoginState(state idputil.LoginState)
SetLoginStatus sets a login status that will be added to every request.
type Fixture ¶
type Fixture struct { // Ctx holds a context appropriate for using // for store methods. Ctx context.Context // Codec contains a codec that will be passed in the idp.InitParams. Codec *secret.Codec // Oven contains a bakery.Oven that will be passed in the // idp.InitParams. Tests can use this to mint macaroons if // necessary. Oven *bakery.Oven // Store holds the store used by the fixture. Store *candidtest.Store // Template holds the template to use for generating pages Template *template.Template // contains filtered or unexported fields }
Fixture provides a test fixture that is helpful for testing identity providers.
func NewFixture ¶
func NewFixture(c *qt.C, store *candidtest.Store) *Fixture
func (*Fixture) AssertLoginFailureMatches ¶
AssertLoginFailureMatches asserts that the login test has resulted in a failure with an error that matches the given regex.
func (*Fixture) AssertLoginNotComplete ¶
AssertLoginNotComplete asserts that the login attempt has not yet completed.
func (*Fixture) AssertLoginRedirectFailureMatches ¶
func (s *Fixture) AssertLoginRedirectFailureMatches(c *qt.C, rurl, returnTo, state, errorCode, regex string)
AssertLoginRedirectFailureMatches asserts that the login test has resulted in a failure with an error that matches the given regex.
func (*Fixture) AssertLoginRedirectSuccess ¶
func (s *Fixture) AssertLoginRedirectSuccess(c *qt.C, rurl, returnTo, state string, username string)
AssertLoginRedirectSuccess asserts that the given redirect URL is for a successful login of the given user.
func (*Fixture) AssertLoginSuccess ¶
AssertLoginSuccess asserts that the login test has resulted in a successful login of the given user.
func (*Fixture) Client ¶
Client creates an HTTP client that will replace the given prefix with the given replacement in all request URLs. The client will also stop redirecting and return the last response when a request with the given stopPrefix is attempted.
func (*Fixture) DoInteractiveLogin ¶
func (s *Fixture) DoInteractiveLogin(c *qt.C, idp idp.IdentityProvider, loginURL string, f func(*http.Client, *http.Response) (*http.Response, error)) (*store.Identity, error)
DoInteractiveLogin performs a full interactive login cycle with the given IDP.
func (*Fixture) InitParams ¶
InitParams returns a completed InitParams that a test can use to pass to idp.Init.
func (*Fixture) LoginState ¶
LoginState creates a candid-login with the given login state.
func (*Fixture) ParseResponse ¶
ParseResponse parses a store.Identity from the given HTTP response.