Ejemplo n.º 1
0
func (s *Suite) TestReportKeysError(c *gc.C) {
	s.facade.reportErr = errors.New("blam")
	w, err := hostkeyreporter.New(s.config)
	c.Assert(err, jc.ErrorIsNil)
	err = workertest.CheckKilled(c, w)
	c.Check(err, gc.ErrorMatches, "blam")
}
Ejemplo n.º 2
0
func (s *Suite) TestSuccess(c *gc.C) {
	w, err := hostkeyreporter.New(s.config)
	c.Assert(err, jc.ErrorIsNil)
	err = workertest.CheckKilled(c, w)
	c.Check(err, gc.Equals, dependency.ErrUninstall)
	s.stub.CheckCalls(c, []jujutesting.StubCall{{
		"ReportKeys", []interface{}{"42", []string{"dsa", "ecdsa", "rsa"}},
	}})
}
Ejemplo n.º 3
0
func (s *Suite) TestNoSSHDir(c *gc.C) {
	// No /etc/ssh at all
	s.config.RootDir = c.MkDir()

	w, err := hostkeyreporter.New(s.config)
	c.Assert(err, jc.ErrorIsNil)
	err = workertest.CheckKilled(c, w)
	c.Check(errors.Cause(err), gc.Equals, dependency.ErrUninstall)
}
Ejemplo n.º 4
0
func (s *Suite) TestNoKeys(c *gc.C) {
	// Pass an empty /etc/ssh
	dir := c.MkDir()
	c.Assert(os.MkdirAll(filepath.Join(dir, "etc", "ssh"), 0777), jc.ErrorIsNil)
	s.config.RootDir = dir

	w, err := hostkeyreporter.New(s.config)
	c.Assert(err, jc.ErrorIsNil)
	err = workertest.CheckKilled(c, w)
	c.Check(err, gc.ErrorMatches, "no SSH host keys found")
}
Ejemplo n.º 5
0
func (s *Suite) TestInvalidConfig(c *gc.C) {
	s.config.MachineId = ""
	_, err := hostkeyreporter.New(s.config)
	c.Check(err, gc.ErrorMatches, "empty MachineId .+")
	c.Check(s.stub.Calls(), gc.HasLen, 0)
}