diff --git a/oauth2/oauth2_client_credentials_test.go b/oauth2/oauth2_client_credentials_test.go index cb1ad8d6ec2..5f0de59aef8 100644 --- a/oauth2/oauth2_client_credentials_test.go +++ b/oauth2/oauth2_client_credentials_test.go @@ -6,6 +6,7 @@ package oauth2_test import ( "context" "encoding/json" + "math" "net/url" "strings" "testing" @@ -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))