Ejemplo n.º 1
0
func (s *CleanerSuite) TestNewCleanerAPIRequiresEnvironManager(c *gc.C) {
	anAuthoriser := s.authoriser
	anAuthoriser.EnvironManager = false
	api, err := cleaner.NewCleanerAPI(nil, nil, anAuthoriser)
	c.Assert(api, gc.IsNil)
	c.Assert(err, gc.ErrorMatches, "permission denied")
	c.Assert(common.ServerError(err), jc.Satisfies, params.IsCodeUnauthorized)
}
Ejemplo n.º 2
0
func (s *CleanerSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)

	s.authoriser = apiservertesting.FakeAuthorizer{
		EnvironManager: true,
	}
	s.st = &mockState{&testing.Stub{}, false}
	cleaner.PatchState(s, s.st)
	var err error
	res := common.NewResources()
	s.api, err = cleaner.NewCleanerAPI(nil, res, s.authoriser)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.api, gc.NotNil)
}