Ejemplo n.º 1
0
func (s *facadeSuite) TestReportKeys(c *gc.C) {
	stub := new(testing.Stub)
	apiCaller := basetesting.APICallerFunc(func(
		objType string, version int,
		id, request string,
		args, response interface{},
	) error {
		c.Check(objType, gc.Equals, "HostKeyReporter")
		c.Check(version, gc.Equals, 0)
		c.Check(id, gc.Equals, "")
		stub.AddCall(request, args)
		*response.(*params.ErrorResults) = params.ErrorResults{
			Results: []params.ErrorResult{{
				(*params.Error)(nil),
			}},
		}
		return nil
	})
	facade := hostkeyreporter.NewFacade(apiCaller)

	err := facade.ReportKeys("42", []string{"rsa", "dsa"})
	c.Assert(err, jc.ErrorIsNil)

	stub.CheckCalls(c, []testing.StubCall{{
		"ReportKeys", []interface{}{params.SSHHostKeySet{
			EntityKeys: []params.SSHHostKeys{{
				Tag:        names.NewMachineTag("42").String(),
				PublicKeys: []string{"rsa", "dsa"},
			}},
		}},
	}})
}
Ejemplo n.º 2
0
func (s *facadeSuite) TestCallError(c *gc.C) {
	apiCaller := basetesting.APICallerFunc(func(
		objType string, version int,
		id, request string,
		args, response interface{},
	) error {
		return errors.New("blam")
	})
	facade := hostkeyreporter.NewFacade(apiCaller)

	err := facade.ReportKeys("42", []string{"rsa", "dsa"})
	c.Assert(err, gc.ErrorMatches, "blam")
}
Ejemplo n.º 3
0
func (s *facadeSuite) TestInnerError(c *gc.C) {
	apiCaller := basetesting.APICallerFunc(func(
		objType string, version int,
		id, request string,
		args, response interface{},
	) error {
		*response.(*params.ErrorResults) = params.ErrorResults{
			Results: []params.ErrorResult{{
				&params.Error{Message: "blam"},
			}},
		}
		return nil
	})
	facade := hostkeyreporter.NewFacade(apiCaller)

	err := facade.ReportKeys("42", []string{"rsa", "dsa"})
	c.Assert(err, gc.ErrorMatches, "blam")
}
Ejemplo n.º 4
0
Archivo: shim.go Proyecto: bac/juju
func NewFacade(apiCaller base.APICaller) (Facade, error) {
	return apihostkeyreporter.NewFacade(apiCaller), nil
}