fix(jwt): fix grace period for renewal check
This commit is contained in:
parent
a2bed1efb8
commit
7374123c5c
|
@ -141,5 +141,5 @@ store_jwt(#{resource_id := ResourceId, table := TId}, JWT) ->
|
|||
is_about_to_expire(JWT) ->
|
||||
#jose_jwt{fields = #{<<"exp">> := Exp}} = jose_jwt:peek(JWT),
|
||||
Now = erlang:system_time(seconds),
|
||||
GraceExp = Exp - timer:seconds(5),
|
||||
GraceExp = Exp - 5,
|
||||
Now >= GraceExp.
|
||||
|
|
|
@ -125,7 +125,7 @@ t_ensure_jwt(_Config) ->
|
|||
JWT0 = emqx_connector_jwt:ensure_jwt(JWTConfig),
|
||||
?assertNot(is_expired(JWT0)),
|
||||
%% should refresh 5 s before expiration
|
||||
ct:sleep(Expiration - 5500),
|
||||
ct:sleep(Expiration - 3000),
|
||||
JWT1 = emqx_connector_jwt:ensure_jwt(JWTConfig),
|
||||
?assertNot(is_expired(JWT1)),
|
||||
%% fully expired
|
||||
|
|
Loading…
Reference in New Issue