Esempio n. 1
0
func (s *openSuite) TestOpenStateNormal(c *C) {
	conf := agent.Conf{
		StateInfo: s.StateInfo(c),
	}
	conf.OldPassword = "******"

	st, changed, err := conf.OpenState()
	c.Assert(err, IsNil)
	defer st.Close()
	c.Assert(changed, Equals, false)
	c.Assert(st, NotNil)
}
Esempio n. 2
0
func (s *openSuite) TestOpenStateNoPassword(c *C) {
	conf := agent.Conf{
		StateInfo: s.StateInfo(c),
	}
	conf.OldPassword = conf.StateInfo.Password
	conf.StateInfo.Password = ""

	st, changed, err := conf.OpenState()
	c.Assert(err, IsNil)
	defer st.Close()
	c.Assert(changed, Equals, true)
	c.Assert(st, NotNil)
	p, err := trivial.RandomPassword()
	c.Assert(err, IsNil)
	c.Assert(conf.StateInfo.Password, HasLen, len(p))
	c.Assert(conf.OldPassword, Equals, s.StateInfo(c).Password)
}