@@ -131,6 +131,14 @@ class JWTDecodeTests : XCTestCase {
131
131
XCTAssertEqual ( payload as NSDictionary , [ " exp " : 1728188491 ] )
132
132
}
133
133
}
134
+
135
+ func testUnexpiredClaimString( ) {
136
+ // If this just started failing, hello 2024!
137
+ let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNzI4MTg4NDkxIn0.y4w7lNLrfRRPzuNUfM-ZvPkoOtrTU_d8ZVYasLdZGpk "
138
+ assertSuccess ( try decode ( jwt, algorithm: . HS256( " secret " ) ) ) { payload in
139
+ XCTAssertEqual ( payload as NSDictionary , [ " exp " : " 1728188491 " ] )
140
+ }
141
+ }
134
142
135
143
// MARK: Not before claim
136
144
@@ -140,6 +148,13 @@ class JWTDecodeTests : XCTestCase {
140
148
XCTAssertEqual ( payload as NSDictionary , [ " nbf " : 1428189720 ] )
141
149
}
142
150
}
151
+
152
+ func testNotBeforeClaimString( ) {
153
+ let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOiIxNDI4MTg5NzIwIn0.qZsj36irdmIAeXv6YazWDSFbpuxHtEh4Deof5YTpnVI "
154
+ assertSuccess ( try decode ( jwt, algorithm: . HS256( " secret " ) ) ) { payload in
155
+ XCTAssertEqual ( payload as NSDictionary , [ " nbf " : " 1428189720 " ] )
156
+ }
157
+ }
143
158
144
159
func testInvalidNotBeforeClaim( ) {
145
160
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOlsxNDI4MTg5NzIwXX0.PUL1FQubzzJa4MNXe2D3d5t5cMaqFr3kYlzRUzly-C8 "
@@ -160,6 +175,13 @@ class JWTDecodeTests : XCTestCase {
160
175
XCTAssertEqual ( payload as NSDictionary , [ " iat " : 1428189720 ] )
161
176
}
162
177
}
178
+
179
+ func testIssuedAtClaimInThePastString( ) {
180
+ let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNDI4MTg5NzIwIn0.M8veWtsY52oBwi7LRKzvNnzhjK0QBS8Su1r0atlns2k "
181
+ assertSuccess ( try decode ( jwt, algorithm: . HS256( " secret " ) ) ) { payload in
182
+ XCTAssertEqual ( payload as NSDictionary , [ " iat " : " 1428189720 " ] )
183
+ }
184
+ }
163
185
164
186
func testIssuedAtClaimInTheFuture( ) {
165
187
// If this just started failing, hello 2024!
0 commit comments