flake: Fixes TestServerOperatorModeUserInfoExpiration

Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
This commit is contained in:
Piotr Piotrowski
2023-09-13 11:57:53 +02:00
parent 23aab24323
commit e08442fbfc

View File

@@ -6637,7 +6637,14 @@ func TestServerOperatorModeUserInfoExpiration(t *testing.T) {
userInfo := response.Data.(*UserInfo)
require_True(t, userInfo.Expires != 0)
require_True(t, expires.Sub(now).Truncate(time.Second) == userInfo.Expires)
// We need to round the expiration time to the second because the server
// will truncate the expiration time to the second.
expiresDurRounded := expires.Sub(now).Truncate(time.Second)
// Checking range to avoid flaky tests where the expiration time is
// off by a couple of seconds.
require_True(t, expiresDurRounded >= userInfo.Expires-2*time.Second && expiresDurRounded <= userInfo.Expires+2*time.Second)
}
func TestJWTAccountNATSResolverWrongCreds(t *testing.T) {