Skip to content

Commit

Permalink
Add elapsed time to TestIamPermissions error. (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
csieber authored Nov 21, 2023
1 parent 8e9404d commit 93af5fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/go/cmd/token-vendor/oauth/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ func (v *TokenVerifier) Verify(ctx context.Context, token Token, sa string) erro
}
pcall := v.s.Projects.ServiceAccounts.TestIamPermissions(resource, &preq)
pcall.Header().Set("Authorization", "Bearer "+string(token))
ts := time.Now()
resp, err := pcall.Context(ctx).Do()
if err != nil {
return errors.Wrapf(err, "TestIamPermissions failed for resource %q with permission %q",
resource, iamActAs)
return errors.Wrapf(err, "TestIamPermissions failed for resource %q with permission %q after %.3fs",
resource, iamActAs, time.Since(ts).Seconds())
}
if !contains(resp.Permissions, iamActAs) {
v.cache.add(token, resource, false)
Expand Down

0 comments on commit 93af5fb

Please sign in to comment.