func (s *SubnetsSuite) TestNewAPIWithBacking(c *gc.C) { // Clients are allowed. facade, err := subnets.NewAPIWithBacking( apiservertesting.BackingInstance, s.resources, s.authorizer, ) c.Assert(err, jc.ErrorIsNil) c.Assert(facade, gc.NotNil) // No calls so far. apiservertesting.CheckMethodCalls(c, apiservertesting.SharedStub) // Agents are not allowed agentAuthorizer := s.authorizer agentAuthorizer.Tag = names.NewMachineTag("42") facade, err = subnets.NewAPIWithBacking( apiservertesting.BackingInstance, s.resources, agentAuthorizer, ) c.Assert(err, jc.DeepEquals, common.ErrPerm) c.Assert(facade, gc.IsNil) // No calls so far. apiservertesting.CheckMethodCalls(c, apiservertesting.SharedStub) }
func (s *SubnetsSuite) SetUpTest(c *gc.C) { s.BaseSuite.SetUpTest(c) apiservertesting.BackingInstance.SetUp(c, apiservertesting.StubZonedEnvironName, apiservertesting.WithZones, apiservertesting.WithSpaces, apiservertesting.WithSubnets) s.resources = common.NewResources() s.authorizer = apiservertesting.FakeAuthorizer{ Tag: names.NewUserTag("admin"), EnvironManager: false, } var err error s.facade, err = subnets.NewAPIWithBacking( apiservertesting.BackingInstance, s.resources, s.authorizer, ) c.Assert(err, jc.ErrorIsNil) c.Assert(s.facade, gc.NotNil) }