Skip to content

Commit

Permalink
cleanup for PR and failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jasdel committed Apr 22, 2022
1 parent 93d3ca7 commit a665fbb
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 24 deletions.
8 changes: 0 additions & 8 deletions auth/bearer/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ type Signer interface {
SignWithBearerToken(context.Context, Token, Message) (Message, error)
}

// // SignerFunc provides a wrapper around a function to implement the Signer interface.
// type SignerFunc func(context.Context, Token, Message) (Message, error)
//
// // SignWithBearerToken invokes the wrapped function to satisfy the Signer interface.
// func (fn SignerFunc) SignWithBearerToken(ctx context.Context, token Token, message Message) (Message, error) {
// return fn(ctx, token, message)
// }

// AuthenticationMiddleware provides the Finalize middleware step for signing
// an request message with a bearer token.
type AuthenticationMiddleware struct {
Expand Down
3 changes: 2 additions & 1 deletion auth/bearer/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func (t Token) Expired(now time.Time) bool {
if !t.CanExpire {
return false
}
return now.Round(0).Equal(t.Expires) || now.After(t.Expires)
now = now.Round(0)
return now.Equal(t.Expires) || now.After(t.Expires)
}

// TokenProvider provides interface for retrieving bearer tokens.
Expand Down
13 changes: 0 additions & 13 deletions auth/bearer/token_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type TokenCacheOptions struct {
// flight, the next call to RetrieveBearerToken will block on that refresh
// to return.
RefreshBeforeExpires time.Duration
// TODO probably need RefreshBeforeExpires jitter factor

// The timeout the underlying TokenProvider's RetrieveBearerToken call must
// return within, or will be canceled. Defaults to 0, no timeout.
Expand Down Expand Up @@ -207,15 +206,3 @@ func (p *TokenCache) getCachedToken() (Token, bool) {

return *t, true
}

type suppressedContext struct {
context.Context
}

func (s *suppressedContext) Deadline() (deadline time.Time, ok bool) {
return time.Time{}, false
}

func (s *suppressedContext) Done() <-chan struct{} { return nil }

func (s *suppressedContext) Err() error { return nil }
3 changes: 1 addition & 2 deletions auth/bearer/token_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestTokenCache_cancelled(t *testing.T) {
}))

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cancel()

// Retrieve that will have its context canceled, should return error, but
// underlying provider retrieve will continue to block in the background.
Expand All @@ -181,7 +181,6 @@ func TestTokenCache_cancelled(t *testing.T) {
}()

<-providerRunning
cancel()

// Retrieve that will be added to existing single flight group, (or create
// a new group). Returning valid token.
Expand Down

0 comments on commit a665fbb

Please sign in to comment.