OLD | NEW |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package apiserver_test | 4 package apiserver_test |
5 | 5 |
6 import ( | 6 import ( |
7 . "launchpad.net/gocheck" | 7 . "launchpad.net/gocheck" |
8 "launchpad.net/juju-core/state/api" | 8 "launchpad.net/juju-core/state/api" |
9 ) | 9 ) |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 }} | 30 }} |
31 | 31 |
32 func (s *suite) TestBadLogin(c *C) { | 32 func (s *suite) TestBadLogin(c *C) { |
33 _, info, err := s.APIConn.Environ.StateInfo() | 33 _, info, err := s.APIConn.Environ.StateInfo() |
34 c.Assert(err, IsNil) | 34 c.Assert(err, IsNil) |
35 for i, t := range badLoginTests { | 35 for i, t := range badLoginTests { |
36 c.Logf("test %d; entity %q; password %q", i, t.tag, t.password) | 36 c.Logf("test %d; entity %q; password %q", i, t.tag, t.password) |
37 info.Tag = "" | 37 info.Tag = "" |
38 info.Password = "" | 38 info.Password = "" |
39 func() { | 39 func() { |
40 » » » st, err := api.Open(info) | 40 » » » st, err := api.Open(info, fastDialOpts) |
41 c.Assert(err, IsNil) | 41 c.Assert(err, IsNil) |
42 defer st.Close() | 42 defer st.Close() |
43 | 43 |
44 _, err = st.Machine("0") | 44 _, err = st.Machine("0") |
45 c.Assert(err, ErrorMatches, "not logged in") | 45 c.Assert(err, ErrorMatches, "not logged in") |
46 c.Assert(api.ErrCode(err), Equals, api.CodeUnauthorized,
Commentf("error %#v", err)) | 46 c.Assert(api.ErrCode(err), Equals, api.CodeUnauthorized,
Commentf("error %#v", err)) |
47 | 47 |
48 _, err = st.Unit("foo/0") | 48 _, err = st.Unit("foo/0") |
49 c.Assert(err, ErrorMatches, "not logged in") | 49 c.Assert(err, ErrorMatches, "not logged in") |
50 c.Assert(api.ErrCode(err), Equals, api.CodeUnauthorized) | 50 c.Assert(api.ErrCode(err), Equals, api.CodeUnauthorized) |
51 | 51 |
52 err = st.Login(t.tag, t.password) | 52 err = st.Login(t.tag, t.password) |
53 c.Assert(err, ErrorMatches, t.err) | 53 c.Assert(err, ErrorMatches, t.err) |
54 c.Assert(api.ErrCode(err), Equals, t.code) | 54 c.Assert(api.ErrCode(err), Equals, t.code) |
55 | 55 |
56 _, err = st.Machine("0") | 56 _, err = st.Machine("0") |
57 c.Assert(err, ErrorMatches, "not logged in") | 57 c.Assert(err, ErrorMatches, "not logged in") |
58 c.Assert(api.ErrCode(err), Equals, api.CodeUnauthorized) | 58 c.Assert(api.ErrCode(err), Equals, api.CodeUnauthorized) |
59 }() | 59 }() |
60 } | 60 } |
61 } | 61 } |
OLD | NEW |