Fixed a unit test related to JWT

This commit is contained in:
Daniele Teti 2023-04-17 23:55:48 +02:00
parent 6ac9590618
commit cae2e4e088
2 changed files with 6 additions and 3 deletions

View File

@ -12,7 +12,7 @@ from pathlib import Path
init() init()
DEFAULT_DELPHI_VERSION = "11.2" DEFAULT_DELPHI_VERSION = "11.3"
g_releases_path = "releases" g_releases_path = "releases"
g_output = "bin" g_output = "bin"
@ -53,6 +53,7 @@ def build_delphi_project(
"11": {"path": "22.0", "desc": "Delphi 11 Alexandria"}, "11": {"path": "22.0", "desc": "Delphi 11 Alexandria"},
"11.1": {"path": "22.0", "desc": "Delphi 11.1 Alexandria"}, "11.1": {"path": "22.0", "desc": "Delphi 11.1 Alexandria"},
"11.2": {"path": "22.0", "desc": "Delphi 11.2 Alexandria"}, "11.2": {"path": "22.0", "desc": "Delphi 11.2 Alexandria"},
"11.3": {"path": "22.0", "desc": "Delphi 11.3 Alexandria"},
} }
assert delphi_version in delphi_versions, ( assert delphi_version in delphi_versions, (

View File

@ -1613,12 +1613,14 @@ var
lToken: string; lToken: string;
lJWT: TJWT; lJWT: TJWT;
lError: string; lError: string;
lExp: TDateTime;
begin begin
lExp := Now + OneHour * 2;
FJWT.Claims.Issuer := 'bit Time Professionals'; FJWT.Claims.Issuer := 'bit Time Professionals';
FJWT.Claims.Subject := 'DelphiMVCFramework'; FJWT.Claims.Subject := 'DelphiMVCFramework';
FJWT.Claims.Audience := 'DelphiDevelopers'; FJWT.Claims.Audience := 'DelphiDevelopers';
FJWT.Claims.IssuedAt := EncodeDateTime(2011, 11, 17, 17, 30, 0, 0); FJWT.Claims.IssuedAt := EncodeDateTime(2011, 11, 17, 17, 30, 0, 0);
FJWT.Claims.ExpirationTime := Now + OneHour * 2; FJWT.Claims.ExpirationTime := lExp;
FJWT.Claims.NotBefore := EncodeDateTime(2011, 11, 17, 17, 30, 0, 0); FJWT.Claims.NotBefore := EncodeDateTime(2011, 11, 17, 17, 30, 0, 0);
FJWT.Claims.JWT_ID := '123456'; FJWT.Claims.JWT_ID := '123456';
FJWT.CustomClaims['username'] := 'dteti'; FJWT.CustomClaims['username'] := 'dteti';
@ -1635,7 +1637,7 @@ begin
Assert.areEqual('DelphiDevelopers', lJWT.Claims.Audience); Assert.areEqual('DelphiDevelopers', lJWT.Claims.Audience);
Assert.areEqual('123456', lJWT.Claims.JWT_ID); Assert.areEqual('123456', lJWT.Claims.JWT_ID);
Assert.areEqual(EncodeDateTime(2011, 11, 17, 17, 30, 0, 0), lJWT.Claims.IssuedAt); Assert.areEqual(EncodeDateTime(2011, 11, 17, 17, 30, 0, 0), lJWT.Claims.IssuedAt);
Assert.areEqual(Roundto(lJWT.Claims.IssuedAt + OneHour * 2, 4), Roundto(lJWT.Claims.ExpirationTime, 4)); Assert.areEqual(Roundto(lExp, 4), Roundto(lJWT.Claims.ExpirationTime, 4));
Assert.areEqual(EncodeDateTime(2011, 11, 17, 17, 30, 0, 0), lJWT.Claims.NotBefore); Assert.areEqual(EncodeDateTime(2011, 11, 17, 17, 30, 0, 0), lJWT.Claims.NotBefore);
Assert.areEqual('dteti', lJWT.CustomClaims['username']); Assert.areEqual('dteti', lJWT.CustomClaims['username']);
Assert.areEqual('admin', lJWT.CustomClaims['userrole']); Assert.areEqual('admin', lJWT.CustomClaims['userrole']);