Esempio n. 1
0
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()
}
Esempio n. 2
0
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)
}
Esempio n. 3
0
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()
}
Esempio n. 4
0
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()
}
Esempio n. 5
0
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)
}
Esempio n. 6
0
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)
}