Пример #1
0
func (s *undertakerSuite) setupStateAndAPI(c *gc.C, isSystem bool, envName string) (*mockState, *undertaker.UndertakerAPI) {
	machineNo := "1"
	if isSystem {
		machineNo = "0"
	}

	authorizer := apiservertesting.FakeAuthorizer{
		Tag:            names.NewMachineTag(machineNo),
		EnvironManager: true,
	}

	st := newMockState(names.NewUserTag("admin"), envName, isSystem)
	api, err := undertaker.NewUndertaker(st, nil, authorizer)
	c.Assert(err, jc.ErrorIsNil)
	return st, api
}
Пример #2
0
func (s *undertakerSuite) TestNoPerms(c *gc.C) {
	for _, authorizer := range []apiservertesting.FakeAuthorizer{
		apiservertesting.FakeAuthorizer{
			Tag: names.NewMachineTag("0"),
		},
		apiservertesting.FakeAuthorizer{
			Tag:            names.NewUserTag("bob"),
			EnvironManager: true,
		},
	} {
		st := newMockState(names.NewUserTag("admin"), "admin", true)
		_, err := undertaker.NewUndertaker(
			st,
			nil,
			authorizer,
		)
		c.Assert(err, gc.ErrorMatches, "permission denied")
	}
}