- Added the `isExpired` and `expiresSoon` getters to JWT tokens.

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-09-17 18:47:28 +02:00
parent 073910546b
commit 04304f106a
5 changed files with 56 additions and 3 deletions
+12
View File
@@ -59,6 +59,18 @@ void main() {
expect(expiry?.year, 2025); // Based on the exp value in the test token
});
test("jwt.isExpired checks expiration on tokens properly", () {
final bool isExpired = validToken.jwt.isExpired;
expect(isExpired, isNotNull);
expect(isExpired, true);
});
test("jwt.expiresSoon checks expiration on tokens properly", () {
final bool expiresSoon = validToken.jwt.expiresSoon;
expect(expiresSoon, isNotNull);
expect(expiresSoon, true);
});
test("jwt.expiryTime throws an exception for invalid token", () {
expect(
() => "invalid.token".jwt.expiryTime,