@@ -33,7 +33,7 @@ class EncodeTests: XCTestCase {
3333class PayloadTests : XCTestCase {
3434 func testIssuer( ) {
3535 _ = JWT . encode ( . none) { builder in
36- builder. issuer = " fuller.li "
36+ builder. issuer = " fuller.li "
3737 XCTAssertEqual ( builder. issuer, " fuller.li " )
3838 XCTAssertEqual ( builder [ " iss " ] as? String , " fuller.li " )
3939 }
@@ -106,26 +106,26 @@ class DecodeTests: XCTestCase {
106106
107107 func testDisablingVerify( ) {
108108 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w "
109- assertSuccess ( try decode ( jwt, algorithm: . none, verify: false , issuer: " fuller.li " ) )
109+ assertSuccess ( try decode ( jwt, algorithm: . none, verify: false , issuer: " fuller.li " ) )
110110 }
111111
112112 // MARK: Issuer claim
113113
114114 func testSuccessfulIssuerValidation( ) {
115115 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJmdWxsZXIubGkifQ.d7B7PAQcz1E6oNhrlxmHxHXHgg39_k7X7wWeahl8kSQ "
116- assertSuccess ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " fuller.li " ) ) { payload in
116+ assertSuccess ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " fuller.li " ) ) { payload in
117117 XCTAssertEqual ( payload as! [ String : String ] , [ " iss " : " fuller.li " ] )
118118 }
119119 }
120120
121121 func testIncorrectIssuerValidation( ) {
122122 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJmdWxsZXIubGkifQ.wOhJ9_6lx-3JGJPmJmtFCDI3kt7uMAMmhHIslti7ryI "
123- assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " querykit.org " ) )
123+ assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " querykit.org " ) )
124124 }
125125
126126 func testMissingIssuerValidation( ) {
127127 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w "
128- assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " fuller.li " ) )
128+ assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , issuer: " fuller.li " ) )
129129 }
130130
131131 // MARK: Expiration claim
@@ -147,7 +147,7 @@ class DecodeTests: XCTestCase {
147147 XCTAssertEqual ( payload as! [ String : Int ] , [ " exp " : 1728188491 ] )
148148 }
149149 }
150-
150+
151151 func testUnexpiredClaimString( ) {
152152 // If this just started failing, hello 2024!
153153 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNzI4MTg4NDkxIn0.y4w7lNLrfRRPzuNUfM-ZvPkoOtrTU_d8ZVYasLdZGpk "
@@ -164,7 +164,7 @@ class DecodeTests: XCTestCase {
164164 XCTAssertEqual ( payload as! [ String : Int ] , [ " nbf " : 1428189720 ] )
165165 }
166166 }
167-
167+
168168 func testNotBeforeClaimString( ) {
169169 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOiIxNDI4MTg5NzIwIn0.qZsj36irdmIAeXv6YazWDSFbpuxHtEh4Deof5YTpnVI "
170170 assertSuccess ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) ) ) { payload in
@@ -215,34 +215,34 @@ class DecodeTests: XCTestCase {
215215
216216 func testAudiencesClaim( ) {
217217 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsibWF4aW5lIiwia2F0aWUiXX0.-PKvdNLCClrWG7CvesHP6PB0-vxu-_IZcsYhJxBy5JM "
218- assertSuccess ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " maxine " ) ) { payload in
218+ assertSuccess ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " maxine " ) ) { payload in
219219 XCTAssertEqual ( payload. count, 1 )
220220 XCTAssertEqual ( payload [ " aud " ] as! [ String ] , [ " maxine " , " katie " ] )
221221 }
222222 }
223223
224224 func testAudienceClaim( ) {
225225 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJreWxlIn0.dpgH4JOwueReaBoanLSxsGTc7AjKUvo7_M1sAfy_xVE "
226- assertSuccess ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " kyle " ) ) { payload in
226+ assertSuccess ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " kyle " ) ) { payload in
227227 XCTAssertEqual ( payload as! [ String : String ] , [ " aud " : " kyle " ] )
228228 }
229229 }
230230
231231 func testMismatchAudienceClaim( ) {
232232 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJreWxlIn0.VEB_n06pTSLlTXPFkc46ARADJ9HXNUBUPo3VhL9RDe4 " // kyle
233- assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " maxine " ) )
233+ assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " maxine " ) )
234234 }
235235
236236 func testMissingAudienceClaim( ) {
237237 let jwt = " eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w "
238- assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " kyle " ) )
238+ assertFailure ( try decode ( jwt, algorithm: . hs256( " secret " . data ( using: . utf8) !) , audience: " kyle " ) )
239239 }
240240
241241 // MARK: Signature verification
242242
243243 func testNoneAlgorithm( ) {
244244 let jwt = " eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ0ZXN0IjoiaW5nIn0. "
245- assertSuccess ( try decode ( jwt, algorithm: . none) ) { payload in
245+ assertSuccess ( try decode ( jwt, algorithm: . none) ) { payload in
246246 XCTAssertEqual ( payload as! [ String : String ] , [ " test " : " ing " ] )
247247 }
248248 }
@@ -274,7 +274,7 @@ class DecodeTests: XCTestCase {
274274
275275// MARK: Helpers
276276
277- func assertSuccess( _ decoder: @autoclosure ( ) throws -> Payload , closure: ( ( Payload ) -> ( ) ) ? = nil ) {
277+ func assertSuccess( _ decoder: @autoclosure ( ) throws -> Payload , closure: ( ( Payload ) -> Void ) ? = nil ) {
278278 do {
279279 let payload = try decoder ( )
280280 closure ? ( payload)
@@ -283,7 +283,7 @@ func assertSuccess(_ decoder: @autoclosure () throws -> Payload, closure:((Paylo
283283 }
284284}
285285
286- func assertFailure( _ decoder: @autoclosure ( ) throws -> Payload , closure: ( ( InvalidToken ) -> ( ) ) ? = nil ) {
286+ func assertFailure( _ decoder: @autoclosure ( ) throws -> Payload , closure: ( ( InvalidToken ) -> Void ) ? = nil ) {
287287 do {
288288 _ = try decoder ( )
289289 XCTFail ( " Decoding succeeded, expected a failure. " )
@@ -294,7 +294,7 @@ func assertFailure(_ decoder: @autoclosure () throws -> Payload, closure:((Inval
294294 }
295295}
296296
297- func assertDecodeError( _ decoder: @autoclosure ( ) throws -> Payload , error: String ) {
297+ func assertDecodeError( _ decoder: @autoclosure ( ) throws -> Payload , error: String ) {
298298 assertFailure ( try decoder ( ) ) { failure in
299299 switch failure {
300300 case . decodeError( let decodeError) :
0 commit comments