mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
flake: Fixes TestServerOperatorModeUserInfoExpiration
Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
This commit is contained in:
@@ -6607,15 +6607,15 @@ func TestServerOperatorModeUserInfoExpiration(t *testing.T) {
|
|||||||
require_NoError(t, err)
|
require_NoError(t, err)
|
||||||
|
|
||||||
conf := createConfFile(t, []byte(fmt.Sprintf(`
|
conf := createConfFile(t, []byte(fmt.Sprintf(`
|
||||||
listen: 127.0.0.1:-1
|
listen: 127.0.0.1:-1
|
||||||
operator: %s
|
operator: %s
|
||||||
system_account: %s
|
system_account: %s
|
||||||
resolver: MEM
|
resolver: MEM
|
||||||
resolver_preload: {
|
resolver_preload: {
|
||||||
%s: %s
|
%s: %s
|
||||||
%s: %s
|
%s: %s
|
||||||
}
|
}
|
||||||
`, ojwt, spub, apub, accJwt, spub, sysJwt)))
|
`, ojwt, spub, apub, accJwt, spub, sysJwt)))
|
||||||
defer removeFile(t, conf)
|
defer removeFile(t, conf)
|
||||||
|
|
||||||
s, _ := RunServerWithConfig(conf)
|
s, _ := RunServerWithConfig(conf)
|
||||||
@@ -6637,7 +6637,14 @@ func TestServerOperatorModeUserInfoExpiration(t *testing.T) {
|
|||||||
|
|
||||||
userInfo := response.Data.(*UserInfo)
|
userInfo := response.Data.(*UserInfo)
|
||||||
require_True(t, userInfo.Expires != 0)
|
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) {
|
func TestJWTAccountNATSResolverWrongCreds(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user