func (s *loggerSuite) TestNewLoggerAPIRefusesNonAgent(c *gc.C) { // We aren't even a machine agent anAuthorizer := s.authorizer anAuthorizer.Tag = s.AdminUserTag(c) endPoint, err := logger.NewLoggerAPI(s.State, s.resources, anAuthorizer) c.Assert(endPoint, gc.IsNil) c.Assert(err, gc.ErrorMatches, "permission denied") }
func (s *loggerSuite) TestNewLoggerAPIAcceptsUnitAgent(c *gc.C) { // We aren't even a machine agent anAuthorizer := s.authorizer anAuthorizer.Tag = names.NewUnitTag("germany/7") endPoint, err := logger.NewLoggerAPI(s.State, s.resources, anAuthorizer) c.Assert(err, jc.ErrorIsNil) c.Assert(endPoint, gc.NotNil) }
func (s *loggerSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.resources = common.NewResources() s.AddCleanup(func(_ *gc.C) { s.resources.StopAll() }) // Create a machine to work with var err error s.rawMachine, err = s.State.AddMachine("quantal", state.JobHostUnits) c.Assert(err, jc.ErrorIsNil) // The default auth is as the machine agent s.authorizer = apiservertesting.FakeAuthorizer{ Tag: s.rawMachine.Tag(), } s.logger, err = logger.NewLoggerAPI(s.State, s.resources, s.authorizer) c.Assert(err, jc.ErrorIsNil) }