@@ -16,80 +16,80 @@ def get_settings():
16
16
with pytest .raises (TypeError ,match = r"missing 1 required positional argument" ):
17
17
Authorize .create_access_token ()
18
18
19
- with pytest .raises (TypeError ,match = r"identity " ):
20
- Authorize .create_access_token (identity = 0.123 )
19
+ with pytest .raises (TypeError ,match = r"subject " ):
20
+ Authorize .create_access_token (subject = 0.123 )
21
21
22
22
with pytest .raises (TypeError ,match = r"fresh" ):
23
- Authorize .create_access_token (identity = "test" ,fresh = "lol" )
23
+ Authorize .create_access_token (subject = "test" ,fresh = "lol" )
24
24
25
25
with pytest .raises (ValueError ,match = r"dictionary update sequence element" ):
26
- Authorize .create_access_token (identity = 1 ,headers = "test" )
26
+ Authorize .create_access_token (subject = 1 ,headers = "test" )
27
27
28
28
def test_create_refresh_token (Authorize ):
29
29
with pytest .raises (TypeError ,match = r"missing 1 required positional argument" ):
30
30
Authorize .create_refresh_token ()
31
31
32
- with pytest .raises (TypeError ,match = r"identity " ):
33
- Authorize .create_refresh_token (identity = 0.123 )
32
+ with pytest .raises (TypeError ,match = r"subject " ):
33
+ Authorize .create_refresh_token (subject = 0.123 )
34
34
35
35
with pytest .raises (ValueError ,match = r"dictionary update sequence element" ):
36
- Authorize .create_refresh_token (identity = 1 ,headers = "test" )
36
+ Authorize .create_refresh_token (subject = 1 ,headers = "test" )
37
37
38
38
def test_create_dynamic_access_token_expires (Authorize ):
39
39
expires_time = int (datetime .now (timezone .utc ).timestamp ()) + 90
40
- token = Authorize .create_access_token (identity = 1 ,expires_time = 90 )
40
+ token = Authorize .create_access_token (subject = 1 ,expires_time = 90 )
41
41
assert jwt .decode (token ,"testing" ,algorithms = "HS256" )['exp' ] == expires_time
42
42
43
43
expires_time = int (datetime .now (timezone .utc ).timestamp ()) + 86400
44
- token = Authorize .create_access_token (identity = 1 ,expires_time = timedelta (days = 1 ))
44
+ token = Authorize .create_access_token (subject = 1 ,expires_time = timedelta (days = 1 ))
45
45
assert jwt .decode (token ,"testing" ,algorithms = "HS256" )['exp' ] == expires_time
46
46
47
47
expires_time = int (datetime .now (timezone .utc ).timestamp ()) + 2
48
- token = Authorize .create_access_token (identity = 1 ,expires_time = True )
48
+ token = Authorize .create_access_token (subject = 1 ,expires_time = True )
49
49
assert jwt .decode (token ,"testing" ,algorithms = "HS256" )['exp' ] == expires_time
50
50
51
- token = Authorize .create_access_token (identity = 1 ,expires_time = False )
51
+ token = Authorize .create_access_token (subject = 1 ,expires_time = False )
52
52
assert 'exp' not in jwt .decode (token ,"testing" ,algorithms = "HS256" )
53
53
54
54
with pytest .raises (TypeError ,match = r"expires_time" ):
55
- Authorize .create_access_token (identity = 1 ,expires_time = "test" )
55
+ Authorize .create_access_token (subject = 1 ,expires_time = "test" )
56
56
57
57
def test_create_dynamic_refresh_token_expires (Authorize ):
58
58
expires_time = int (datetime .now (timezone .utc ).timestamp ()) + 90
59
- token = Authorize .create_refresh_token (identity = 1 ,expires_time = 90 )
59
+ token = Authorize .create_refresh_token (subject = 1 ,expires_time = 90 )
60
60
assert jwt .decode (token ,"testing" ,algorithms = "HS256" )['exp' ] == expires_time
61
61
62
62
expires_time = int (datetime .now (timezone .utc ).timestamp ()) + 86400
63
- token = Authorize .create_refresh_token (identity = 1 ,expires_time = timedelta (days = 1 ))
63
+ token = Authorize .create_refresh_token (subject = 1 ,expires_time = timedelta (days = 1 ))
64
64
assert jwt .decode (token ,"testing" ,algorithms = "HS256" )['exp' ] == expires_time
65
65
66
66
expires_time = int (datetime .now (timezone .utc ).timestamp ()) + 4
67
- token = Authorize .create_refresh_token (identity = 1 ,expires_time = True )
67
+ token = Authorize .create_refresh_token (subject = 1 ,expires_time = True )
68
68
assert jwt .decode (token ,"testing" ,algorithms = "HS256" )['exp' ] == expires_time
69
69
70
- token = Authorize .create_refresh_token (identity = 1 ,expires_time = False )
70
+ token = Authorize .create_refresh_token (subject = 1 ,expires_time = False )
71
71
assert 'exp' not in jwt .decode (token ,"testing" ,algorithms = "HS256" )
72
72
73
73
with pytest .raises (TypeError ,match = r"expires_time" ):
74
- Authorize .create_refresh_token (identity = 1 ,expires_time = "test" )
74
+ Authorize .create_refresh_token (subject = 1 ,expires_time = "test" )
75
75
76
76
def test_create_token_invalid_type_data_audience (Authorize ):
77
77
with pytest .raises (TypeError ,match = r"audience" ):
78
- Authorize .create_access_token (identity = 1 ,audience = 1 )
78
+ Authorize .create_access_token (subject = 1 ,audience = 1 )
79
79
80
80
with pytest .raises (TypeError ,match = r"audience" ):
81
- Authorize .create_refresh_token (identity = 1 ,audience = 1 )
81
+ Authorize .create_refresh_token (subject = 1 ,audience = 1 )
82
82
83
83
def test_create_token_invalid_algorithm (Authorize ):
84
84
with pytest .raises (ValueError ,match = r"Algorithm" ):
85
- Authorize .create_access_token (identity = 1 ,algorithm = "test" )
85
+ Authorize .create_access_token (subject = 1 ,algorithm = "test" )
86
86
87
87
with pytest .raises (ValueError ,match = r"Algorithm" ):
88
- Authorize .create_refresh_token (identity = 1 ,algorithm = "test" )
88
+ Authorize .create_refresh_token (subject = 1 ,algorithm = "test" )
89
89
90
90
def test_create_token_invalid_type_data_algorithm (Authorize ):
91
91
with pytest .raises (TypeError ,match = r"algorithm" ):
92
- Authorize .create_access_token (identity = 1 ,algorithm = 1 )
92
+ Authorize .create_access_token (subject = 1 ,algorithm = 1 )
93
93
94
94
with pytest .raises (TypeError ,match = r"algorithm" ):
95
- Authorize .create_refresh_token (identity = 1 ,algorithm = 1 )
95
+ Authorize .create_refresh_token (subject = 1 ,algorithm = 1 )
0 commit comments