func (s *openSuite) TestOpenStateNormal(c *C) { conf := agent.Conf{ StateInfo: s.StateInfo(c), } conf.OldPassword = "******" st, err := conf.OpenState() c.Assert(err, IsNil) st.Close() }
func (s *openSuite) TestOpenAPINormal(c *C) { conf := agent.Conf{ APIInfo: s.APIInfo(c), } conf.OldPassword = "******" st, newPassword, err := conf.OpenAPI(api.DialOpts{}) c.Assert(err, IsNil) defer st.Close() c.Assert(newPassword, Equals, "") c.Assert(st, NotNil) }
func (s *openSuite) TestOpenStateNoPassword(c *C) { conf := agent.Conf{ StateInfo: s.StateInfo(c), } conf.OldPassword = conf.StateInfo.Password conf.StateInfo.Password = "" st, err := conf.OpenState() c.Assert(err, IsNil) c.Assert(st, NotNil) st.Close() }
func (s *openSuite) TestOpenStateFallbackPassword(c *gc.C) { conf := agent.Conf{ StateInfo: s.StateInfo(c), } conf.OldPassword = conf.StateInfo.Password conf.StateInfo.Password = "******" st, err := conf.OpenState() c.Assert(err, gc.IsNil) c.Assert(st, gc.NotNil) st.Close() }
func (s *openSuite) TestOpenAPINoPassword(c *C) { conf := agent.Conf{ APIInfo: s.APIInfo(c), } conf.OldPassword = conf.APIInfo.Password conf.APIInfo.Password = "" st, newPassword, err := conf.OpenAPI(api.DialOpts{}) c.Assert(err, IsNil) defer st.Close() c.Assert(newPassword, Matches, ".+") c.Assert(st, NotNil) p, err := utils.RandomPassword() c.Assert(err, IsNil) c.Assert(newPassword, HasLen, len(p)) c.Assert(conf.OldPassword, Equals, s.APIInfo(c).Password) }
func (s *openSuite) TestOpenAPIFallbackPassword(c *gc.C) { conf := agent.Conf{ APIInfo: s.APIInfo(c), } conf.OldPassword = conf.APIInfo.Password conf.APIInfo.Password = "******" st, newPassword, err := conf.OpenAPI(api.DialOpts{}) c.Assert(err, gc.IsNil) defer st.Close() c.Assert(newPassword, gc.Matches, ".+") c.Assert(st, gc.NotNil) p, err := utils.RandomPassword() c.Assert(err, gc.IsNil) c.Assert(newPassword, gc.HasLen, len(p)) c.Assert(conf.OldPassword, gc.Equals, s.APIInfo(c).Password) }