Exemple #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()
}
Exemple #2
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()
}
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()
}
Exemple #4
0
func openState(c *agent.Conf, a Agent) (*state.State, AgentState, error) {
	st, err := c.OpenState()
	if err != nil {
		return nil, nil, err
	}
	entity, err := a.Entity(st)
	if errors.IsNotFoundError(err) || err == nil && entity.Life() == state.Dead {
		err = worker.ErrTerminateAgent
	}
	if err != nil {
		st.Close()
		return nil, nil, err
	}
	return st, entity, nil
}