~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/apiserver/testing/fakeauthorizer.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import (
7
7
        "gopkg.in/juju/names.v2"
8
8
 
9
 
        "github.com/juju/juju/core/description"
 
9
        "github.com/juju/juju/permission"
10
10
)
11
11
 
12
12
// FakeAuthorizer implements the facade.Authorizer interface.
51
51
 
52
52
// HasPermission returns true if the logged in user is admin or has a name equal to
53
53
// the pre-set admin tag.
54
 
func (fa FakeAuthorizer) HasPermission(operation description.Access, target names.Tag) (bool, error) {
 
54
func (fa FakeAuthorizer) HasPermission(operation permission.Access, target names.Tag) (bool, error) {
55
55
        if fa.Tag.Kind() == names.UserTagKind {
56
56
                ut := fa.Tag.(names.UserTag)
57
57
                if ut.Name() == "admin" {
61
61
                if fa.AdminTag != emptyTag && ut == fa.AdminTag {
62
62
                        return true, nil
63
63
                }
64
 
                if operation == description.WriteAccess && ut == fa.HasWriteTag {
 
64
                if operation == permission.WriteAccess && ut == fa.HasWriteTag {
65
65
                        return true, nil
66
66
                }
67
67
                return false, nil
77
77
 
78
78
// HasPermission returns true if the passed user is admin or has a name equal to
79
79
// the pre-set admin tag.
80
 
func (fa FakeAuthorizer) UserHasPermission(user names.UserTag, operation description.Access, target names.Tag) (bool, error) {
 
80
func (fa FakeAuthorizer) UserHasPermission(user names.UserTag, operation permission.Access, target names.Tag) (bool, error) {
81
81
        if user.Name() == "admin" {
82
82
                return true, nil
83
83
        }