~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/api/state_macaroon_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
        s.MacaroonSuite.SetUpTest(c)
29
29
        s.AddModelUser(c, testUserName)
30
30
        info := s.APIInfo(c)
31
 
        // Don't log in.
32
 
        info.UseMacaroons = false
 
31
        info.SkipLogin = true
33
32
        s.client = s.OpenAPI(c, info, nil)
34
33
}
35
34
 
40
39
 
41
40
func (s *macaroonLoginSuite) TestSuccessfulLogin(c *gc.C) {
42
41
        s.DischargerLogin = func() string { return testUserName }
43
 
        err := s.client.Login(nil, "", "")
 
42
        err := s.client.Login(nil, "", "", nil)
44
43
        c.Assert(err, jc.ErrorIsNil)
45
44
}
46
45
 
47
46
func (s *macaroonLoginSuite) TestFailedToObtainDischargeLogin(c *gc.C) {
48
 
        err := s.client.Login(nil, "", "")
 
47
        err := s.client.Login(nil, "", "", nil)
49
48
        c.Assert(err, gc.ErrorMatches, `cannot get discharge from "https://.*": third party refused discharge: cannot discharge: login denied by discharger`)
50
49
}
51
50
 
53
52
        s.DischargerLogin = func() string {
54
53
                return "testUnknown"
55
54
        }
56
 
        err := s.client.Login(nil, "", "")
 
55
        err := s.client.Login(nil, "", "", nil)
57
56
        c.Assert(errors.Cause(err), gc.DeepEquals, &rpc.RequestError{
58
57
                Message: "invalid entity name or password",
59
58
                Code:    "unauthorized access",
69
68
                return testUserName
70
69
        }
71
70
        // First log into the regular API.
72
 
        err := s.client.Login(nil, "", "")
 
71
        err := s.client.Login(nil, "", "", nil)
73
72
        c.Assert(err, jc.ErrorIsNil)
74
73
        c.Assert(dischargeCount, gc.Equals, 1)
75
74