1
// Copyright 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"gopkg.in/juju/names.v2"
9
"github.com/juju/juju/core/description"
12
// FakeAuthorizer implements the facade.Authorizer interface.
13
type FakeAuthorizer struct {
18
func (fa FakeAuthorizer) AuthOwner(tag names.Tag) bool {
22
func (fa FakeAuthorizer) AuthModelManager() bool {
23
return fa.EnvironManager
26
// AuthMachineAgent returns whether the current client is a machine agent.
27
func (fa FakeAuthorizer) AuthMachineAgent() bool {
28
_, isMachine := fa.GetAuthTag().(names.MachineTag)
32
// AuthUnitAgent returns whether the current client is a unit agent.
33
func (fa FakeAuthorizer) AuthUnitAgent() bool {
34
_, isUnit := fa.GetAuthTag().(names.UnitTag)
38
// AuthClient returns whether the authenticated entity is a client
40
func (fa FakeAuthorizer) AuthClient() bool {
41
_, isUser := fa.GetAuthTag().(names.UserTag)
45
func (fa FakeAuthorizer) GetAuthTag() names.Tag {
49
func (fa FakeAuthorizer) HasPermission(operation description.Access, target names.Tag) (bool, error) {
50
// TODO(perrito666) provide a way to pre-set the desired result here.
51
return fa.Tag == target, nil