Skip to content

Commit

Permalink
revert naming change
Browse files Browse the repository at this point in the history
  • Loading branch information
skpratt committed Feb 9, 2023
1 parent 3427f87 commit c8b4228
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 70 deletions.
8 changes: 4 additions & 4 deletions agent/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type TestACLAgent struct {

// NewTestACLAgent does just enough so that all the code within agent/acl.go can work
// Basically it needs a local state for some of the vet* functions, a logger and a delegate.
// The key is that we are the delegate so we can control the ResolveTokenSecret responses
// The key is that we are the delegate so we can control the ResolveToken responses
func NewTestACLAgent(t *testing.T, name string, hcl string, resolveAuthz authzResolver, resolveIdent identResolver) *TestACLAgent {
t.Helper()

Expand Down Expand Up @@ -89,17 +89,17 @@ func NewTestACLAgent(t *testing.T, name string, hcl string, resolveAuthz authzRe
return a
}

func (a *TestACLAgent) ResolveTokenSecret(secretID string) (acl.Authorizer, error) {
func (a *TestACLAgent) ResolveToken(secretID string) (acl.Authorizer, error) {
if a.resolveAuthzFn == nil {
return nil, fmt.Errorf("ResolveTokenSecret call is unexpected - no authz resolver callback set")
return nil, fmt.Errorf("ResolveToken call is unexpected - no authz resolver callback set")
}

_, authz, err := a.resolveAuthzFn(secretID)
return authz, err
}

func (a *TestACLAgent) ResolveTokenAndDefaultMeta(secretID string, entMeta *acl.EnterpriseMeta, authzContext *acl.AuthorizerContext) (resolver.Result, error) {
authz, err := a.ResolveTokenSecret(secretID)
authz, err := a.ResolveToken(secretID)
if err != nil {
return resolver.Result{}, err
}
Expand Down
10 changes: 0 additions & 10 deletions agent/consul/acl_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,6 @@ func (a *ACL) TokenRead(args *structs.ACLTokenGetRequest, reply *structs.ACLToke
return fmt.Errorf("token does not exist: %w", acl.ErrNotFound)
}

reply.Index, reply.Token = index, token
reply.SourceDatacenter = args.Datacenter
if token == nil {
// token does not exist
if ns := args.EnterpriseMeta.NamespaceOrEmpty(); ns != "" {
return fmt.Errorf("token not found in namespace %s: %w", ns, acl.ErrNotFound)
}
return fmt.Errorf("token does not exist: %w", acl.ErrNotFound)
}

reply.Index, reply.Token = index, token
reply.SourceDatacenter = args.Datacenter

Expand Down
Loading

0 comments on commit c8b4228

Please sign in to comment.