mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 01:15:43 +03:00
Add ErrPermissionDenied, rename TokenNotFound
This commit is contained in:
@@ -82,7 +82,7 @@ func (c *Client) ResolveToken(secretID string) (*acl.ACL, error) {
|
||||
return nil, err
|
||||
}
|
||||
if token == nil {
|
||||
return nil, structs.TokenNotFound
|
||||
return nil, structs.ErrTokenNotFound
|
||||
}
|
||||
|
||||
// Check if this is a management token
|
||||
|
||||
@@ -159,6 +159,6 @@ func TestClient_ACL_ResolveToken(t *testing.T) {
|
||||
|
||||
// Test bad token
|
||||
out4, err := c1.ResolveToken(structs.GenerateUUID())
|
||||
assert.Equal(t, structs.TokenNotFound, err)
|
||||
assert.Equal(t, structs.ErrTokenNotFound, err)
|
||||
assert.Nil(t, out4)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func resolveTokenFromSnapshotCache(snap *state.StateSnapshot, cache *lru.TwoQueu
|
||||
return nil, err
|
||||
}
|
||||
if token == nil {
|
||||
return nil, structs.TokenNotFound
|
||||
return nil, structs.ErrTokenNotFound
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestResolveACLToken(t *testing.T) {
|
||||
// Attempt resolution of unknown token. Should fail.
|
||||
randID := structs.GenerateUUID()
|
||||
aclObj, err = resolveTokenFromSnapshotCache(snap, cache, randID)
|
||||
assert.Equal(t, structs.TokenNotFound, err)
|
||||
assert.Equal(t, structs.ErrTokenNotFound, err)
|
||||
assert.Nil(t, aclObj)
|
||||
|
||||
// Attempt resolution of management token. Should get singleton.
|
||||
|
||||
@@ -34,8 +34,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNoLeader = fmt.Errorf("No cluster leader")
|
||||
ErrNoRegionPath = fmt.Errorf("No path to region")
|
||||
ErrNoLeader = fmt.Errorf("No cluster leader")
|
||||
ErrNoRegionPath = fmt.Errorf("No path to region")
|
||||
ErrTokenNotFound = errors.New("ACL token not found")
|
||||
ErrPermissionDenied = errors.New("Permission denied")
|
||||
|
||||
// validPolicyName is used to validate a policy name
|
||||
validPolicyName = regexp.MustCompile("^[a-zA-Z0-9-]{1,128}$")
|
||||
@@ -5440,9 +5442,6 @@ type ACLPolicyUpsertRequest struct {
|
||||
WriteRequest
|
||||
}
|
||||
|
||||
// TokenNotFound indicates the Token was not found
|
||||
var TokenNotFound = errors.New("ACL token not found")
|
||||
|
||||
// ACLToken represents a client token which is used to Authenticate
|
||||
type ACLToken struct {
|
||||
AccessorID string // Public Accessor ID (UUID)
|
||||
|
||||
Reference in New Issue
Block a user