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") }
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"}}, }}) }
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) }
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") }
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) }