Commit c81bafec authored by Armon Dadgar's avatar Armon Dadgar
Browse files

acl: Adding IsManagement check

Showing with 9 additions and 0 deletions
+9 -0
......@@ -204,3 +204,8 @@ func (a *ACL) AllowOperatorWrite() bool {
return false
}
}
// IsManagement checks if this represents a management token
func (a *ACL) IsManagement() bool {
return a.management
}
......@@ -72,6 +72,7 @@ func TestACLManagement(t *testing.T) {
assert.Equal(t, true, acl.AllowNamespaceOperation("foo", NamespaceCapabilityListJobs))
// Check the other simpler operations
assert.Equal(t, true, acl.IsManagement())
assert.Equal(t, true, acl.AllowAgentRead())
assert.Equal(t, true, acl.AllowAgentWrite())
assert.Equal(t, true, acl.AllowNodeRead())
......@@ -97,6 +98,7 @@ func TestACLMerge(t *testing.T) {
assert.Equal(t, false, acl.AllowNamespaceOperation("foo", NamespaceCapabilityListJobs))
// Check the other simpler operations
assert.Equal(t, false, acl.IsManagement())
assert.Equal(t, true, acl.AllowAgentRead())
assert.Equal(t, true, acl.AllowAgentWrite())
assert.Equal(t, true, acl.AllowNodeRead())
......@@ -118,6 +120,7 @@ func TestACLMerge(t *testing.T) {
assert.Equal(t, false, acl.AllowNamespaceOperation("foo", NamespaceCapabilityListJobs))
// Check the other simpler operations
assert.Equal(t, false, acl.IsManagement())
assert.Equal(t, true, acl.AllowAgentRead())
assert.Equal(t, false, acl.AllowAgentWrite())
assert.Equal(t, true, acl.AllowNodeRead())
......@@ -139,6 +142,7 @@ func TestACLMerge(t *testing.T) {
assert.Equal(t, false, acl.AllowNamespaceOperation("foo", NamespaceCapabilityListJobs))
// Check the other simpler operations
assert.Equal(t, false, acl.IsManagement())
assert.Equal(t, false, acl.AllowAgentRead())
assert.Equal(t, false, acl.AllowAgentWrite())
assert.Equal(t, false, acl.AllowNodeRead())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment