@@ -13,6 +13,36 @@ import Testing
1313import WebPushTesting
1414
1515@Suite struct SubscriberTests {
16+ @Suite struct Initialization {
17+ @Test func fromKeyMaterial( ) {
18+ let privateKey = P256 . KeyAgreement. PrivateKey ( )
19+ let subscriber = Subscriber (
20+ endpoint: URL ( string: " https://example.com/subscriber " ) !,
21+ userAgentKeyMaterial: UserAgentKeyMaterial (
22+ publicKey: privateKey. publicKey,
23+ authenticationSecret: Data ( )
24+ ) ,
25+ vapidKeyID: . mockedKeyID1
26+ )
27+ #expect( subscriber. endpoint == URL ( string: " https://example.com/subscriber " ) !)
28+ #expect( subscriber. userAgentKeyMaterial == UserAgentKeyMaterial (
29+ publicKey: privateKey. publicKey,
30+ authenticationSecret: Data ( )
31+ ) )
32+ #expect( subscriber. vapidKeyID == . mockedKeyID1)
33+ }
34+
35+ @Test func fromOtherSubscriber( ) {
36+ let subscriber = Subscriber ( . mockedSubscriber( ) )
37+ #expect( subscriber == . mockedSubscriber)
38+ }
39+
40+ @Test func identifiable( ) {
41+ let subscriber = Subscriber . mockedSubscriber
42+ #expect( subscriber. id == " https://example.com/subscriber " )
43+ }
44+ }
45+
1646 @Suite struct UserAgentKeyMaterialTests {
1747 @Suite struct Initialization {
1848 @Test func actualKeys( ) {
0 commit comments