@@ -18,7 +18,7 @@ class DecodeTests: XCTestCase {
18
18
}
19
19
20
20
func testFailsToDecodeInvalidStringWithoutThreeSegments( ) {
21
- XCTAssertThrowsError ( try decode ( " a.b " , algorithm: . none) , " Not enough segments " )
21
+ XCTAssertThrowsError ( try decode ( " a.b " , algorithm: . none) as ClaimSet , " Not enough segments " )
22
22
}
23
23
24
24
// MARK: Disable verify
@@ -39,24 +39,24 @@ class DecodeTests: XCTestCase {
39
39
40
40
func testIncorrectIssuerValidation( ) {
41
41
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJmdWxsZXIubGkifQ.wOhJ9_6lx-3JGJPmJmtFCDI3kt7uMAMmhHIslti7ryI "
42
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " querykit.org " ) )
42
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " querykit.org " ) as ClaimSet )
43
43
}
44
44
45
45
func testMissingIssuerValidation( ) {
46
46
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w "
47
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " fuller.li " ) )
47
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " fuller.li " ) as ClaimSet )
48
48
}
49
49
50
50
// MARK: Expiration claim
51
51
52
52
func testExpiredClaim( ) {
53
53
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0MjgxODg0OTF9.cy6b2szsNkKnHFnz2GjTatGjoHBTs8vBKnPGZgpp91I "
54
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) )
54
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) as ClaimSet )
55
55
}
56
56
57
57
func testInvalidExpiaryClaim( ) {
58
58
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOlsiMTQyODE4ODQ5MSJdfQ.OwF-wd3THjxrEGUhh6IdnNhxQZ7ydwJ3Z6J_dfl9MBs "
59
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) )
59
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) as ClaimSet )
60
60
}
61
61
62
62
func testUnexpiredClaim( ) throws {
@@ -99,7 +99,7 @@ class DecodeTests: XCTestCase {
99
99
func testUnmetNotBeforeClaim( ) {
100
100
// If this just started failing, hello 2024!
101
101
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3MjgxODg0OTF9.Tzhu1tu-7BXcF5YEIFFE1Vmg4tEybUnaz58FR4PcblQ "
102
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) )
102
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) as ClaimSet )
103
103
}
104
104
105
105
// MARK: Issued at claim
@@ -121,7 +121,7 @@ class DecodeTests: XCTestCase {
121
121
func testIssuedAtClaimInTheFuture( ) {
122
122
// If this just started failing, hello 2024!
123
123
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MjgxODg0OTF9.owHiJyJmTcW1lBW5y_Rz3iBfSbcNiXlbZ2fY9qR7-aU "
124
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) )
124
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) as ClaimSet )
125
125
}
126
126
127
127
func testInvalidIssuedAtClaim( ) {
@@ -149,12 +149,12 @@ class DecodeTests: XCTestCase {
149
149
150
150
func testMismatchAudienceClaim( ) {
151
151
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJreWxlIn0.VEB_n06pTSLlTXPFkc46ARADJ9HXNUBUPo3VhL9RDe4 " // kyle
152
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " maxine " ) )
152
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " maxine " ) as ClaimSet )
153
153
}
154
154
155
155
func testMissingAudienceClaim( ) {
156
156
let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w "
157
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " kyle " ) )
157
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " kyle " ) as ClaimSet )
158
158
}
159
159
160
160
// MARK: Signature verification
@@ -168,7 +168,7 @@ class DecodeTests: XCTestCase {
168
168
169
169
func testNoneFailsWithSecretAlgorithm( ) {
170
170
let jwt = " eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ0ZXN0IjoiaW5nIn0. "
171
- XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) )
171
+ XCTAssertThrowsError ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) as ClaimSet )
172
172
}
173
173
174
174
func testMatchesAnyAlgorithm( ) {
0 commit comments