func (s *destroyControllerSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) resources := common.NewResources() s.AddCleanup(func(_ *gc.C) { resources.StopAll() }) authoriser := apiservertesting.FakeAuthorizer{ Tag: s.AdminUserTag(c), } controller, err := controller.NewControllerAPI(s.State, resources, authoriser) c.Assert(err, jc.ErrorIsNil) s.controller = controller s.otherEnvOwner = names.NewUserTag("jess@dummy") s.otherState = factory.NewFactory(s.State).MakeModel(c, &factory.ModelParams{ Name: "dummytoo", Owner: s.otherEnvOwner, Prepare: true, ConfigAttrs: testing.Attrs{ "state-server": false, }, }) s.AddCleanup(func(c *gc.C) { s.otherState.Close() }) s.otherModelUUID = s.otherState.ModelUUID() }
func (s *userManagerSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.createLocalLoginMacaroon = func(tag names.UserTag) (*macaroon.Macaroon, error) { return nil, errors.NotSupportedf("CreateLocalLoginMacaroon") } s.resources = common.NewResources() s.resources.RegisterNamed("createLocalLoginMacaroon", common.ValueResource{ func(tag names.UserTag) (*macaroon.Macaroon, error) { return s.createLocalLoginMacaroon(tag) }, }) adminTag := s.AdminUserTag(c) s.adminName = adminTag.Name() s.authorizer = apiservertesting.FakeAuthorizer{ Tag: adminTag, } var err error s.usermanager, err = usermanager.NewUserManagerAPI(s.State, s.resources, s.authorizer) c.Assert(err, jc.ErrorIsNil) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) }
func (s *clientSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.resources = common.NewResources() s.AddCleanup(func(_ *gc.C) { s.resources.StopAll() }) s.authoriser = apiservertesting.FakeAuthorizer{ Tag: s.AdminUserTag(c), EnvironManager: true, } var err error s.haServer, err = highavailability.NewHighAvailabilityAPI(s.State, s.resources, s.authoriser) c.Assert(err, jc.ErrorIsNil) _, err = s.State.AddMachines(state.MachineTemplate{ Series: "quantal", Jobs: []state.MachineJob{state.JobManageModel}, Constraints: controllerCons, }) c.Assert(err, jc.ErrorIsNil) // We have to ensure the agents are alive, or EnableHA will // create more to replace them. s.pingers = []*presence.Pinger{s.setAgentPresence(c, "0")} s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) }
func (s *destroyEnvironmentSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) s.metricSender = &testMetricSender{} s.PatchValue(common.SendMetrics, s.metricSender.SendMetrics) }
func (s *actionSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) s.authorizer = apiservertesting.FakeAuthorizer{ Tag: s.AdminUserTag(c), } var err error s.action, err = action.NewActionAPI(s.State, nil, s.authorizer) c.Assert(err, jc.ErrorIsNil) factory := jujuFactory.NewFactory(s.State) s.charm = factory.MakeCharm(c, &jujuFactory.CharmParams{ Name: "wordpress", }) s.dummy = factory.MakeService(c, &jujuFactory.ServiceParams{ Name: "dummy", Charm: factory.MakeCharm(c, &jujuFactory.CharmParams{ Name: "dummy", }), Creator: s.AdminUserTag(c), }) s.wordpress = factory.MakeService(c, &jujuFactory.ServiceParams{ Name: "wordpress", Charm: s.charm, Creator: s.AdminUserTag(c), }) s.machine0 = factory.MakeMachine(c, &jujuFactory.MachineParams{ Series: "quantal", Jobs: []state.MachineJob{state.JobHostUnits, state.JobManageModel}, }) s.wordpressUnit = factory.MakeUnit(c, &jujuFactory.UnitParams{ Service: s.wordpress, Machine: s.machine0, }) mysqlCharm := factory.MakeCharm(c, &jujuFactory.CharmParams{ Name: "mysql", }) s.mysql = factory.MakeService(c, &jujuFactory.ServiceParams{ Name: "mysql", Charm: mysqlCharm, Creator: s.AdminUserTag(c), }) s.machine1 = factory.MakeMachine(c, &jujuFactory.MachineParams{ Series: "quantal", Jobs: []state.MachineJob{state.JobHostUnits}, }) s.mysqlUnit = factory.MakeUnit(c, &jujuFactory.UnitParams{ Service: s.mysql, Machine: s.machine1, }) s.resources = common.NewResources() s.AddCleanup(func(_ *gc.C) { s.resources.StopAll() }) }
func (s *destroyTwoModelsSuite) TestCanDestroyNonBlockedModel(c *gc.C) { bh := commontesting.NewBlockHelper(s.APIState) defer bh.Close() bh.BlockDestroyModel(c, "TestBlockDestroyDestroyModel") err := common.DestroyModel(s.State, s.otherState.ModelTag()) c.Assert(err, jc.ErrorIsNil) err = common.DestroyModel(s.State, s.State.ModelTag()) bh.AssertBlocked(c, err, "TestBlockDestroyDestroyModel") }
func (s *destroyTwoEnvironmentsSuite) TestCanDestroyNonBlockedEnv(c *gc.C) { bh := commontesting.NewBlockHelper(s.APIState) defer bh.Close() bh.BlockDestroyEnvironment(c, "TestBlockDestroyDestroyEnvironment") err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag()) c.Assert(err, jc.ErrorIsNil) err = common.DestroyEnvironment(s.State, s.State.EnvironTag()) bh.AssertBlocked(c, err, "TestBlockDestroyDestroyEnvironment") }
func (s *runSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) var err error auth := apiservertesting.FakeAuthorizer{ Tag: s.AdminUserTag(c), } s.client, err = action.NewActionAPI(s.State, nil, auth) c.Assert(err, jc.ErrorIsNil) }
func (s *destroyModelSuite) TestBlockDestroyDestroyHostedModel(c *gc.C) { otherSt := s.Factory.MakeModel(c, nil) defer otherSt.Close() info := s.APIInfo(c) info.ModelTag = otherSt.ModelTag() apiState, err := api.Open(info, api.DefaultDialOpts()) block := commontesting.NewBlockHelper(apiState) defer block.Close() block.BlockDestroyModel(c, "TestBlockDestroyDestroyModel") err = common.DestroyModelIncludingHosted(s.State, s.State.ModelTag()) s.AssertBlocked(c, err, "TestBlockDestroyDestroyModel") }
func (s *destroyTwoEnvironmentsSuite) TestCanDestroyNonBlockedEnv(c *gc.C) { bh := commontesting.NewBlockHelper(s.APIState) defer bh.Close() bh.BlockDestroyEnvironment(c, "TestBlockDestroyDestroyEnvironment") err := common.DestroyEnvironment(s.State, s.otherState.EnvironTag()) c.Assert(err, jc.ErrorIsNil) err = common.DestroyEnvironment(s.State, s.State.EnvironTag()) bh.AssertBlocked(c, err, "TestBlockDestroyDestroyEnvironment") s.metricSender.CheckCalls(c, []jtesting.StubCall{{FuncName: "SendMetrics"}}) }
func (s *keyManagerSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.resources = common.NewResources() s.AddCleanup(func(_ *gc.C) { s.resources.StopAll() }) s.authoriser = apiservertesting.FakeAuthorizer{ Tag: s.AdminUserTag(c), } var err error s.keymanager, err = keymanager.NewKeyManagerAPI(s.State, s.resources, s.authoriser) c.Assert(err, jc.ErrorIsNil) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) }
func (s *userManagerSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) adminTag := s.AdminUserTag(c) s.adminName = adminTag.Name() s.authorizer = apiservertesting.FakeAuthorizer{ Tag: adminTag, } var err error s.usermanager, err = usermanager.NewUserManagerAPI(s.State, nil, s.authorizer) c.Assert(err, jc.ErrorIsNil) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) }
func (s *serviceSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) s.CharmStoreSuite.Session = s.JujuConnSuite.Session s.CharmStoreSuite.SetUpTest(c) s.service = s.Factory.MakeService(c, nil) s.authorizer = apiservertesting.FakeAuthorizer{ Tag: s.AdminUserTag(c), } var err error s.serviceApi, err = service.NewAPI(s.State, nil, s.authorizer) c.Assert(err, jc.ErrorIsNil) }
func (s *baseSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) }
func (s *toolsSuite) SetUpTest(c *gc.C) { s.toolsCommonSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) }
func (s *destroyModelSuite) SetUpTest(c *gc.C) { s.JujuConnSuite.SetUpTest(c) s.BlockHelper = commontesting.NewBlockHelper(s.APIState) s.modelManager = common.NewModelManagerBackend(s.State) s.AddCleanup(func(*gc.C) { s.BlockHelper.Close() }) }