func ExampleVisitWebPage() { var key *bakery.KeyPair var u *url.URL client := httpbakery.NewClient() client.Key = key agent.SetCookie(client.Jar, u, "agent-username", &client.Key.Public) client.VisitWebPage = agent.VisitWebPage(client) }
func (s *agentSuite) TestNoCookieError(c *gc.C) { client := httpbakery.NewClient() client.VisitWebPage = agent.VisitWebPage(client) m, err := s.bakery.NewMacaroon("", nil, []checkers.Caveat{{ Location: s.discharger.URL, Condition: "test condition", }}) c.Assert(err, gc.IsNil) _, err = client.DischargeAll(m) c.Assert(err, gc.ErrorMatches, "cannot get discharge from .*: cannot start interactive session: cannot perform agent login: no agent-login cookie found") ierr := errgo.Cause(err).(*httpbakery.InteractionError) c.Assert(errgo.Cause(ierr.Reason), gc.Equals, http.ErrNoCookie) }