@@ -283,17 +283,15 @@ class ValidationTests: XCTestCase {
283
283
func testClaimJustExpiredWithoutLeeway( ) {
284
284
var claims = ClaimSet ( )
285
285
claims. expiration = Date ( ) . addingTimeInterval ( - 1 )
286
-
287
- let expectation = XCTestExpectation ( description: " Signature should be expired. " )
286
+
288
287
do {
289
288
try claims. validateExpiary ( )
290
289
XCTFail ( " InvalidToken.expiredSignature error should have been thrown. " )
291
290
} catch InvalidToken . expiredSignature {
292
- expectation . fulfill ( )
291
+ // Correct error thrown
293
292
} catch {
294
293
XCTFail ( " Unexpected error while validating exp claim. " )
295
294
}
296
- self . wait ( for: [ expectation] , timeout: 0.5 )
297
295
}
298
296
299
297
func testClaimJustNotExpiredWithoutLeeway( ) {
@@ -311,16 +309,14 @@ class ValidationTests: XCTestCase {
311
309
var claims = ClaimSet ( )
312
310
claims. notBefore = Date ( ) . addingTimeInterval ( 1 )
313
311
314
- let expectation = XCTestExpectation ( description: " Signature should be immature. " )
315
312
do {
316
313
try claims. validateNotBefore ( )
317
314
XCTFail ( " InvalidToken.immatureSignature error should have been thrown. " )
318
315
} catch InvalidToken . immatureSignature {
319
- expectation . fulfill ( )
316
+ // Correct error thrown
320
317
} catch {
321
318
XCTFail ( " Unexpected error while validating nbf claim. " )
322
319
}
323
- self . wait ( for: [ expectation] , timeout: 0.5 )
324
320
}
325
321
326
322
func testNotBeforeIsValidWithLeeway( ) {
@@ -337,17 +333,15 @@ class ValidationTests: XCTestCase {
337
333
func testIssuedAtIsInFutureWithoutLeeway( ) {
338
334
var claims = ClaimSet ( )
339
335
claims. issuedAt = Date ( ) . addingTimeInterval ( 1 )
340
-
341
- let expectation = XCTestExpectation ( description: " iat should be in the future. " )
336
+
342
337
do {
343
338
try claims. validateIssuedAt ( )
344
339
XCTFail ( " InvalidToken.invalidIssuedAt error should have been thrown. " )
345
340
} catch InvalidToken . invalidIssuedAt {
346
- expectation . fulfill ( )
341
+ // Correct error thrown
347
342
} catch {
348
343
XCTFail ( " Unexpected error while validating iat claim. " )
349
344
}
350
- self . wait ( for: [ expectation] , timeout: 0.5 )
351
345
}
352
346
353
347
func testIssuedAtIsValidWithLeeway( ) {
@@ -371,17 +365,15 @@ class IntegrationTests: XCTestCase {
371
365
builder. notBefore = Date ( ) . addingTimeInterval ( 1 ) // Token starts being valid in one second
372
366
builder. issuedAt = Date ( ) . addingTimeInterval ( 1 ) // Token is issued one second in the future
373
367
}
374
-
375
- let expectation = XCTestExpectation ( description: " Verification should fail. " )
368
+
376
369
do {
377
370
let _ = try JWT . decode ( token, algorithm: . none, leeway: 0 )
378
371
XCTFail ( " InvalidToken error should have been thrown. " )
379
372
} catch is InvalidToken {
380
- expectation . fulfill ( )
373
+ // Correct error thrown
381
374
} catch {
382
375
XCTFail ( " Unexpected error type while verifying token. " )
383
376
}
384
- self . wait ( for: [ expectation] , timeout: 0.5 )
385
377
}
386
378
387
379
func testVerificationSuccessWithLeeway( ) {
0 commit comments