@@ -260,6 +260,54 @@ struct VAPIDConfigurationTests {
260
260
"""
261
261
)
262
262
}
263
+
264
+ @Test func decodesIncompleteConfiguration( ) throws {
265
+ #expect(
266
+ try JSONDecoder ( ) . decode ( VAPID . Configuration. self, from: Data (
267
+ """
268
+ {
269
+ " contactInformation " : " mailto:test@example.com " ,
270
+ " expirationDuration " : 79200,
271
+ " primaryKey " : " FniTgSrf0l+BdfeC6LiblKXBbY4LQm0S+4STNCoJI+0= " ,
272
+ " validityDuration " : 72000
273
+ }
274
+ """ . utf8
275
+ ) ) ==
276
+ VAPID . Configuration (
277
+ key: key1,
278
+ contactInformation: . email( " test@example.com " )
279
+ )
280
+ )
281
+ }
282
+
283
+ @Test func decodesWholeConfiguration( ) throws {
284
+ #expect(
285
+ try JSONDecoder ( ) . decode ( VAPID . Configuration. self, from: Data (
286
+ """
287
+ {
288
+ " contactInformation " : " mailto:test@example.com " ,
289
+ " deprecatedKeys " : [
290
+ " bcZgo/p2WFqXaKFzmYaDKO/gARjWvGi3oXyHM2QNlfE= "
291
+ ],
292
+ " expirationDuration " : 3600,
293
+ " keys " : [
294
+ " wyQaGWNwvXKzVmPIhkqVQvQ+FKx1SNqHJ+re8n2ORrk= "
295
+ ],
296
+ " primaryKey " : " FniTgSrf0l+BdfeC6LiblKXBbY4LQm0S+4STNCoJI+0= " ,
297
+ " validityDuration " : 36000
298
+ }
299
+ """ . utf8
300
+ ) ) ==
301
+ VAPID . Configuration (
302
+ primaryKey: key1,
303
+ keys: [ key2] ,
304
+ deprecatedKeys: [ key1, key2, key3] ,
305
+ contactInformation: . email( " test@example.com " ) ,
306
+ expirationDuration: . hours( 1 ) ,
307
+ validityDuration: . hours( 10 )
308
+ )
309
+ )
310
+ }
263
311
}
264
312
265
313
@Suite
@@ -303,6 +351,11 @@ struct VAPIDConfigurationTests {
303
351
#expect( VAPID . Configuration. Duration. seconds ( 175 ) > VAPID . Configuration. Duration. minutes ( 2 ) )
304
352
}
305
353
354
+ @Test func addingToDates( ) {
355
+ let now = Date ( )
356
+ #expect( now. adding ( . seconds( 5 ) ) == now. addingTimeInterval ( 5 ) )
357
+ }
358
+
306
359
@Test func coding( ) throws {
307
360
#expect( String ( decoding: try JSONEncoder ( ) . encode ( VAPID . Configuration. Duration ( 60 ) ) , as: UTF8 . self) == " 60 " )
308
361
0 commit comments