Skip to content

Commit

Permalink
test: fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Nov 10, 2022
1 parent ccf2388 commit c417be1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion oauth2/oauth2_client_credentials_test.go
Expand Up @@ -6,6 +6,7 @@ package oauth2_test
import (
"context"
"encoding/json"
"math"
"net/url"
"strings"
"testing"
Expand Down Expand Up @@ -230,7 +231,7 @@ func TestClientCredentials(t *testing.T) {
token, err := getToken(t, conf)
require.NoError(t, err)

assert.EqualValues(t, time.Now().Add(duration).Round(time.Minute), token.Expiry.Round(time.Minute))
assert.True(t, math.Abs(float64(time.Now().Add(duration).Round(time.Minute).Unix())-float64(token.Expiry.Round(time.Minute).Unix())) < 5)

introspection := testhelpers.IntrospectToken(t, &goauth2.Config{ClientID: cl.GetID(), ClientSecret: conf.ClientSecret}, token.AccessToken, admin)
assert.EqualValues(t, time.Now().Add(duration).Round(time.Minute), time.Unix(introspection.Get("exp").Int(), 0).Round(time.Minute))
Expand Down

0 comments on commit c417be1

Please sign in to comment.