From 5c3ff5b62702792818437746b66c041009372aca Mon Sep 17 00:00:00 2001 From: owenpearson Date: Mon, 1 Jul 2024 13:15:19 +0100 Subject: [PATCH 1/3] docs: GCM->FCM GCM transport is deprecated in favour of FCM --- lib/ably/rest/push/admin.rb | 2 +- spec/acceptance/rest/push_admin_spec.rb | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/ably/rest/push/admin.rb b/lib/ably/rest/push/admin.rb index f6dc7cb6f..a46cd2e0b 100644 --- a/lib/ably/rest/push/admin.rb +++ b/lib/ably/rest/push/admin.rb @@ -21,7 +21,7 @@ def initialize(push) # Publish a push message directly to a single recipient # - # @param recipient [Hash] A recipient device, client_id or raw APNS/GCM target. Refer to push documentation + # @param recipient [Hash] A recipient device, client_id or raw APNS/FCM target. Refer to push documentation # @param data [Hash] The notification payload data and fields. Refer to push documentation # # @return [void] diff --git a/spec/acceptance/rest/push_admin_spec.rb b/spec/acceptance/rest/push_admin_spec.rb index 1df3c1400..210e45de6 100644 --- a/spec/acceptance/rest/push_admin_spec.rb +++ b/spec/acceptance/rest/push_admin_spec.rb @@ -181,7 +181,7 @@ client_id: client_id, push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registration_token: 'secret_token', } } @@ -250,7 +250,7 @@ client_id: client_id, push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registration_token: 'secret_token', } } @@ -268,7 +268,7 @@ expect(device).to be_a(Ably::Models::DeviceDetails) expect(device.platform).to eql('ios') expect(device.client_id).to eql(client_id) - expect(device.push.recipient.fetch(:transport_type)).to eql('gcm') + expect(device.push.recipient.fetch(:transport_type)).to eql('fcm') end it 'returns a DeviceDetails object if a DeviceDetails object is provided' do @@ -276,7 +276,7 @@ expect(device).to be_a(Ably::Models::DeviceDetails) expect(device.platform).to eql('ios') expect(device.client_id).to eql(client_id) - expect(device.push.recipient.fetch(:transport_type)).to eql('gcm') + expect(device.push.recipient.fetch(:transport_type)).to eql('fcm') end it 'raises a ResourceMissing exception if device ID does not exist' do @@ -350,14 +350,14 @@ expect(device_retrieved.push.recipient['foo_bar']).to eql('string') end - context 'with GCM target' do + context 'with FCM target' do let(:device_token) { random_str } it 'saves the associated DevicePushDetails' do subject.save(device_details.merge( push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registrationToken: device_token } } @@ -365,7 +365,7 @@ device_retrieved = subject.get(device_details.fetch(:id)) - expect(device_retrieved.push.recipient.fetch('transportType')).to eql('gcm') + expect(device_retrieved.push.recipient.fetch('transportType')).to eql('fcm') expect(device_retrieved.push.recipient[:registration_token]).to eql(device_token) end end @@ -462,7 +462,7 @@ client_id: client_id, push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registrationToken: 'secret_token', } } @@ -476,7 +476,7 @@ client_id: client_id, push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registration_token: 'secret_token', } } @@ -525,7 +525,7 @@ client_id: client_id, push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registration_token: 'secret_token', } } @@ -539,7 +539,7 @@ client_id: client_id, push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registration_token: 'secret_token', } } @@ -580,7 +580,7 @@ client_id: client_id, push: { recipient: { - transport_type: 'gcm', + transport_type: 'fcm', registration_token: 'secret_token', } } From 9a2134ba1b18c2dc273065101bb2a6597d94fd83 Mon Sep 17 00:00:00 2001 From: owenpearson Date: Mon, 1 Jul 2024 13:16:23 +0100 Subject: [PATCH 2/3] docs: add web as a push target --- lib/ably/rest/push/admin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ably/rest/push/admin.rb b/lib/ably/rest/push/admin.rb index a46cd2e0b..fcc177ea7 100644 --- a/lib/ably/rest/push/admin.rb +++ b/lib/ably/rest/push/admin.rb @@ -21,7 +21,7 @@ def initialize(push) # Publish a push message directly to a single recipient # - # @param recipient [Hash] A recipient device, client_id or raw APNS/FCM target. Refer to push documentation + # @param recipient [Hash] A recipient device, client_id or raw APNS/FCM/web target. Refer to push documentation # @param data [Hash] The notification payload data and fields. Refer to push documentation # # @return [void] From f207c79280d7dd9f9662701868de348e06408cce Mon Sep 17 00:00:00 2001 From: owenpearson Date: Mon, 1 Jul 2024 13:44:57 +0100 Subject: [PATCH 3/3] test: update web push recipient structure with structured encryptionKey This was changed server-side so that the endpoint rejects web push recipients with a string encryptionKey. --- spec/acceptance/rest/push_admin_spec.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/acceptance/rest/push_admin_spec.rb b/spec/acceptance/rest/push_admin_spec.rb index 210e45de6..a5e1433f0 100644 --- a/spec/acceptance/rest/push_admin_spec.rb +++ b/spec/acceptance/rest/push_admin_spec.rb @@ -372,7 +372,8 @@ context 'with web target' do let(:target_url) { 'http://foo.com/bar' } - let(:encryption_key) { random_str } + let(:p256dh) { random_str } + let(:auth) { random_str } it 'saves the associated DevicePushDetails' do subject.save(device_details.merge( @@ -380,7 +381,10 @@ recipient: { transport_type: 'web', targetUrl: target_url, - encryptionKey: encryption_key + encryptionKey: { + p256dh: p256dh, + auth: auth + } } } )) @@ -389,7 +393,8 @@ expect(device_retrieved.push.recipient[:transport_type]).to eql('web') expect(device_retrieved.push.recipient['targetUrl']).to eql(target_url) - expect(device_retrieved.push.recipient['encryptionKey']).to eql(encryption_key) + expect(device_retrieved.push.recipient['encryptionKey']['p256dh']).to eql(p256dh) + expect(device_retrieved.push.recipient['encryptionKey']['auth']).to eql(auth) end end