From 2b1ff577115429565d21bf7a7f51547bfa68ff60 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 5 Jun 2025 09:41:05 +0200 Subject: [PATCH 1/8] Remove requirement to pass channels in pubnub.add_channels_to_push --- pubnub/pubnub_core.py | 2 +- .../functional/push/test_add_channels_to_push.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pubnub/pubnub_core.py b/pubnub/pubnub_core.py index ea94f798..1553d7fa 100644 --- a/pubnub/pubnub_core.py +++ b/pubnub/pubnub_core.py @@ -629,7 +629,7 @@ def list_push_channels(self, device_id: str = None, push_type: PNPushType = None """ return ListPushProvisions(self, device_id=device_id, push_type=push_type, topic=topic, environment=environment) - def add_channels_to_push(self, channels: Union[str, List[str]], device_id: str = None, + def add_channels_to_push(self, channels: Union[str, List[str]] = None, device_id: str = None, push_type: PNPushType = None, topic: str = None, environment: PNPushEnvironment = None) -> AddChannelsToPush: """Register channels for push notifications. diff --git a/tests/functional/push/test_add_channels_to_push.py b/tests/functional/push/test_add_channels_to_push.py index 1665f319..59d688ea 100644 --- a/tests/functional/push/test_add_channels_to_push.py +++ b/tests/functional/push/test_add_channels_to_push.py @@ -10,8 +10,9 @@ import pubnub.enums from pubnub.endpoints.push.add_channels_to_push import AddChannelsToPush -from tests.helper import pnconf, sdk_name +from tests.helper import pnconf, pnconf_env_copy, sdk_name from pubnub.managers import TelemetryManager +from pubnub.enums import PNPushType, PNPushEnvironment class TestAddChannelsFromPush(unittest.TestCase): @@ -89,3 +90,15 @@ def test_push_add_single_channel_apns2(self): }) self.assertEqual(self.add_channels._channels, ['ch']) + + def test_add_channels_to_push_builder(self): + config = pnconf_env_copy() + pubnub = PubNub(config) + endpoint = pubnub.add_channels_to_push() \ + .channels(['ch1', 'ch2']) \ + .device_id("00000000000000000000000000000000") \ + .push_type(PNPushType.APNS2) \ + .environment(PNPushEnvironment.PRODUCTION) \ + .topic("testTopic") + result = endpoint.sync() + self.assertEqual(result.status.error, None) From f3af90544567aa43be58717a332c3463ca9461ef Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 5 Jun 2025 09:46:16 +0200 Subject: [PATCH 2/8] Fix typo in remove_channels_from_push.sync() --- pubnub/endpoints/push/remove_channels_from_push.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubnub/endpoints/push/remove_channels_from_push.py b/pubnub/endpoints/push/remove_channels_from_push.py index 813f159a..6dab32c4 100644 --- a/pubnub/endpoints/push/remove_channels_from_push.py +++ b/pubnub/endpoints/push/remove_channels_from_push.py @@ -98,7 +98,7 @@ def create_response(self, envelope) -> PNPushRemoveChannelResult: return PNPushRemoveChannelResult() def sync(self) -> PNPushRemoveChannelResultEnvelope: - return PNPushRemoveChannelResultEnvelope(self.process_sync()) + return PNPushRemoveChannelResultEnvelope(super().sync()) def is_auth_required(self): return True From ebd1b2b605dba7de5742cb3784210f7c9c905f99 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 5 Jun 2025 14:07:43 +0200 Subject: [PATCH 3/8] Tests part 1. --- .../apns2_basic_success.json | 64 ++++ .../apns2_development_environment.json | 64 ++++ .../apns2_production_environment.json | 64 ++++ .../apns2_topic_validation.json | 300 ++++++++++++++++ .../apns_basic_success.json | 64 ++++ .../gcm_basic_success.json | 64 ++++ .../invalid_device_id_error.json | 64 ++++ .../invalid_push_type_error.json | 64 ++++ .../special_characters_in_channels.json | 64 ++++ .../success_response_structure.json | 64 ++++ .../native_sync/test_add_channels_to_push.py | 324 ++++++++++++++++++ tests/unit/test_add_channels_to_push.py | 116 +++++++ tests/unit/test_list_push_channels.py | 91 +++++ tests/unit/test_remove_channels_from_push.py | 112 ++++++ tests/unit/test_remove_device_from_push.py | 89 +++++ 15 files changed, 1608 insertions(+) create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_development_environment.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_production_environment.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_topic_validation.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/apns_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/gcm_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_device_id_error.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_push_type_error.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/special_characters_in_channels.json create mode 100644 tests/integrational/fixtures/native_sync/add_channels_to_push/success_response_structure.json create mode 100644 tests/integrational/native_sync/test_add_channels_to_push.py create mode 100644 tests/unit/test_add_channels_to_push.py create mode 100644 tests/unit/test_list_push_channels.py create mode 100644 tests/unit/test_remove_channels_from_push.py create mode 100644 tests/unit/test_remove_device_from_push.py diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_basic_success.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_basic_success.json new file mode 100644 index 00000000..7388cc28 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_channel_1%2Capns2_channel_2&environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:00 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_development_environment.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_development_environment.json new file mode 100644 index 00000000..f210d7b4 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_development_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_dev_channel_1%2Capns2_dev_channel_2&environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:01 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_production_environment.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_production_environment.json new file mode 100644 index 00000000..07beb41d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_production_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_prod_channel_1%2Capns2_prod_channel_2&environment=production&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:02 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_topic_validation.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_topic_validation.json new file mode 100644 index 00000000..b6ccb643 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_topic_validation.json @@ -0,0 +1,300 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_topic_test_channel&environment=development&topic=com.example.app&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:02 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_topic_test_channel&environment=development&topic=com.example-app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:03 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_topic_test_channel&environment=development&topic=com.example_app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:03 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_topic_test_channel&environment=development&topic=com.EXAMPLE.APP.NOTIFICATIONS&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:03 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_topic_test_channel&environment=development&topic=com.example.app.notifications-dev&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:03 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/apns_basic_success.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns_basic_success.json new file mode 100644 index 00000000..6307f7b9 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/apns_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=test_channel_1%2Ctest_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:04 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/gcm_basic_success.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/gcm_basic_success.json new file mode 100644 index 00000000..5c315199 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/gcm_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=gcm_channel_1%2Cgcm_channel_2&type=gcm&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:05 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_device_id_error.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_device_id_error.json new file mode 100644 index 00000000..65b1f877 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_device_id_error.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/device_id_should_be_16_characters_long?add=test_channel_1%2Ctest_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 400, + "message": "Bad Request" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:05 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "33" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVMQAAAAAAAAB9lIwGc3RyaW5nlIwheyJlcnJvciI6ICJJbnZhbGlkIGRldmljZSB0b2tlbiJ9lHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_push_type_error.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_push_type_error.json new file mode 100644 index 00000000..02bd97fc --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_push_type_error.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=test_channel_1&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 400, + "message": "Bad Request" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:06 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "34" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVMgAAAAAAAAB9lIwGc3RyaW5nlIwieyJlcnJvciI6ICJJbnZhbGlkIHR5cGUgYXJndW1lbnQifZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/special_characters_in_channels.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/special_characters_in_channels.json new file mode 100644 index 00000000..ee06977e --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/special_characters_in_channels.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=channel-with-dash%2Cchannel_with_underscore%2Cchannel.with.dots&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:07 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/add_channels_to_push/success_response_structure.json b/tests/integrational/fixtures/native_sync/add_channels_to_push/success_response_structure.json new file mode 100644 index 00000000..425c7ec6 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/add_channels_to_push/success_response_structure.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=response_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 11:59:08 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/native_sync/test_add_channels_to_push.py b/tests/integrational/native_sync/test_add_channels_to_push.py new file mode 100644 index 00000000..e71c4192 --- /dev/null +++ b/tests/integrational/native_sync/test_add_channels_to_push.py @@ -0,0 +1,324 @@ +import unittest + +from pubnub.pubnub import PubNub +from pubnub.enums import PNPushType, PNPushEnvironment +from pubnub.exceptions import PubNubException +from tests.helper import pnconf_env_copy +from tests.integrational.vcr_helper import pn_vcr + + +class TestAddChannelsToPushIntegration(unittest.TestCase): + """Integration tests for add_channels_to_push endpoint.""" + + def setUp(self): + """Set up test fixtures before each test method.""" + self.pubnub = PubNub(pnconf_env_copy(uuid="test-uuid")) + + # ============================================== + # BASIC FUNCTIONALITY TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/apns_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_apns_basic_success(self): + """Test basic APNS channel addition functionality.""" + device_id = "0000000000000000" + channels = ["test_channel_1", "test_channel_2"] + + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/gcm_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_gcm_basic_success(self): + """Test basic GCM channel addition functionality.""" + device_id = "0000000000000000" + channels = ["gcm_channel_1", "gcm_channel_2"] + + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.GCM) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_apns2_basic_success(self): + """Test basic APNS2 channel addition functionality.""" + device_id = "0000000000000000" + channels = ["apns2_channel_1", "apns2_channel_2"] + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # ERROR RESPONSE TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_device_id_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_invalid_device_id_error(self): + """Test error response for invalid device ID.""" + device_id = "device_id_should_be_16_characters_long" + channels = ["test_channel_1", "test_channel_2"] + + try: + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.fail("Expected PubNubException for invalid device ID") + except PubNubException as e: + assert 400 == e.get_status_code() + assert "Invalid device token" == e.get_error_message() + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/missing_topic_apns2_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_missing_topic_apns2_error(self): + """Test error response for APNS2 without required topic.""" + device_id = "0000000000000000" + channels = ["error_channel"] + + try: + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .sync() + self.fail("Expected PubNubException for invalid device ID") + except PubNubException as e: + assert "Push notification topic is missing. Required only if push type is APNS2." == str(e) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/invalid_push_type_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_invalid_push_type_error(self): + """Test error response for invalid push type.""" + device_id = "0000000000000000" + channels = ["test_channel_1"] + + try: + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type("INVALID_PUSH_TYPE") \ + .sync() + self.fail("Expected PubNubException for invalid push type") + except PubNubException as e: + assert 400 == e.get_status_code() + assert "Invalid type argument" in e.get_error_message() + + # ============================================== + # EDGE CASE TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/special_characters_in_channels.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_special_characters_in_channels(self): + """Test adding channels with special characters.""" + device_id = "0000000000000000" + channels = ["channel-with-dash", "channel_with_underscore", "channel.with.dots"] + + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/empty_channel_list.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_empty_channel_list(self): + """Test behavior with empty channel list.""" + device_id = "0000000000000000" + channels = [] + + try: + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.fail("Expected PubNubException for empty channel list") + except PubNubException as e: + assert "Channel missing" in str(e) + + # ============================================== + # RESPONSE VALIDATION TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/success_response_structure.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_success_response_structure(self): + """Test success response structure and content.""" + device_id = "0000000000000000" + channels = ["response_test_channel"] + + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Validate envelope structure + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertIsNotNone(envelope.status) + + # Validate status + self.assertFalse(envelope.status.is_error()) + self.assertIsNotNone(envelope.status.status_code) + self.assertEqual(envelope.status.status_code, 200) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/error_response_structure.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_error_response_structure(self): + """Test error response structure and content.""" + # TODO: Implement test for error response validation + pass + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/response_status_codes.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_response_status_codes(self): + """Test various HTTP status codes in responses.""" + # TODO: Implement test for status code validation + pass + + # ============================================== + # APNS2 SPECIFIC TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_development_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_apns2_development_environment(self): + """Test APNS2 with development environment.""" + device_id = "0000000000000000" + channels = ["apns2_dev_channel_1", "apns2_dev_channel_2"] + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_production_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_apns2_production_environment(self): + """Test APNS2 with production environment.""" + device_id = "0000000000000000" + channels = ["apns2_prod_channel_1", "apns2_prod_channel_2"] + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.PRODUCTION) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/add_channels_to_push/apns2_topic_validation.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_add_channels_to_push_apns2_topic_validation(self): + """Test APNS2 topic validation and format requirements.""" + device_id = "0000000000000000" + channels = ["apns2_topic_test_channel"] + + # Test valid topic formats + valid_topics = [ + "com.example.app", + "com.example-app.notifications", + "com.example_app.notifications", + "com.EXAMPLE.APP.NOTIFICATIONS", + "com.example.app.notifications-dev" + ] + + for topic in valid_topics: + envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) diff --git a/tests/unit/test_add_channels_to_push.py b/tests/unit/test_add_channels_to_push.py new file mode 100644 index 00000000..a23686a3 --- /dev/null +++ b/tests/unit/test_add_channels_to_push.py @@ -0,0 +1,116 @@ +import unittest +import pytest +from pubnub.exceptions import PubNubException +from pubnub.pubnub import PubNub +from pubnub.endpoints.push.add_channels_to_push import AddChannelsToPush +from pubnub.enums import PNPushType, PNPushEnvironment +from tests.helper import mocked_config + + +class TestAddChannelsToPush(unittest.TestCase): + """Unit tests for the add_channels_to_push method in PubNub core.""" + + def test_add_channels_to_push_with_named_parameters(self): + """Test add_channels_to_push with named parameters.""" + pubnub = PubNub(mocked_config) + channels = ["alerts", "news", "updates"] + device_id = "test_device_456" + push_type = PNPushType.APNS2 + topic = "com.example.app.notifications" + environment = PNPushEnvironment.DEVELOPMENT + + endpoint = pubnub.add_channels_to_push( + channels=channels, + device_id=device_id, + push_type=push_type, + topic=topic, + environment=environment + ) + + self.assertIsInstance(endpoint, AddChannelsToPush) + self.assertEqual(endpoint._channels, channels) + self.assertEqual(endpoint._device_id, device_id) + self.assertEqual(endpoint._push_type, push_type) + self.assertEqual(endpoint._topic, topic) + self.assertEqual(endpoint._environment, environment) + + def test_add_channels_to_push_builder(self): + """Test that the returned object supports method chaining.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.add_channels_to_push() \ + .channels(["test_channel"]) \ + .device_id("test_device") \ + .push_type(PNPushType.GCM) \ + .topic("test_topic") \ + .environment(PNPushEnvironment.DEVELOPMENT) + + self.assertIsInstance(endpoint, AddChannelsToPush) + self.assertEqual(endpoint._channels, ["test_channel"]) + self.assertEqual(endpoint._device_id, "test_device") + self.assertEqual(endpoint._push_type, PNPushType.GCM) + + def test_add_channels_to_push_apns2_fails_without_topic(self): + """Test that APNS2 fails validation when no topic is provided.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.add_channels_to_push( + channels=["test_channel"], + device_id="test_device", + push_type=PNPushType.APNS2 + # No topic provided - should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push notification topic is missing", str(exc_info.value)) + + def test_add_channels_to_push_none_push_type_validation(self): + """Test that None push_type fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.add_channels_to_push( + channels=["test_channel"], + device_id="test_device", + push_type=None # None push_type should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push Type is missing", str(exc_info.value)) + + def test_add_channels_to_push_none_device_id_validation(self): + """Test that None device_id fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.add_channels_to_push( + channels=["test_channel"], + device_id=None, # None device_id should fail validation + push_type=PNPushType.APNS + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Device ID is missing", str(exc_info.value)) + + def test_add_channels_to_push_none_channels_validation(self): + """Test that None channels fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.add_channels_to_push( + channels=None, # None channels should fail validation + device_id="test_device", + push_type=PNPushType.APNS + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Channel missing", str(exc_info.value)) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/unit/test_list_push_channels.py b/tests/unit/test_list_push_channels.py new file mode 100644 index 00000000..c8e4ba67 --- /dev/null +++ b/tests/unit/test_list_push_channels.py @@ -0,0 +1,91 @@ +import unittest + +import pytest + +from pubnub.exceptions import PubNubException +from pubnub.pubnub import PubNub +from pubnub.endpoints.push.list_push_provisions import ListPushProvisions +from pubnub.enums import PNPushType, PNPushEnvironment +from tests.helper import mocked_config + + +class TestListPushChannels(unittest.TestCase): + """Unit tests for the list_push_channels method in PubNub core.""" + + def test_list_push_channels_with_named_parameters(self): + """Test list_push_channels with named parameters.""" + pubnub = PubNub(mocked_config) + device_id = "test_device_456" + push_type = PNPushType.APNS2 + topic = "com.example.app.notifications" + environment = PNPushEnvironment.DEVELOPMENT + + endpoint = pubnub.list_push_channels( + device_id=device_id, + push_type=push_type, + topic=topic, + environment=environment + ) + + self.assertIsInstance(endpoint, ListPushProvisions) + self.assertEqual(endpoint._device_id, device_id) + self.assertEqual(endpoint._push_type, push_type) + self.assertEqual(endpoint._topic, topic) + self.assertEqual(endpoint._environment, environment) + + def test_list_push_channels_builder(self): + """Test that the returned object supports method chaining.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.list_push_channels() \ + .device_id("test_device") \ + .push_type(PNPushType.GCM) \ + .topic("test_topic") \ + .environment(PNPushEnvironment.DEVELOPMENT) + + self.assertIsInstance(endpoint, ListPushProvisions) + self.assertEqual(endpoint._device_id, "test_device") + self.assertEqual(endpoint._push_type, PNPushType.GCM) + + def test_list_push_channels_apns2_fails_without_topic(self): + """Test that APNS2 fails validation when no topic is provided.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.list_push_channels( + device_id="test_device", + push_type=PNPushType.APNS2 + # No topic provided - should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push notification topic is missing", str(exc_info.value)) + + def test_list_push_channels_none_push_type_validation(self): + """Test that None push_type fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.list_push_channels( + device_id="test_device", + push_type=None # None push_type should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push Type is missing", str(exc_info.value)) + + def test_list_push_channels_none_device_id_validation(self): + """Test that None device_id fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.list_push_channels( + device_id=None, # None device_id should fail validation + push_type=PNPushType.APNS + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Device ID is missing", str(exc_info.value)) diff --git a/tests/unit/test_remove_channels_from_push.py b/tests/unit/test_remove_channels_from_push.py new file mode 100644 index 00000000..c1144eaf --- /dev/null +++ b/tests/unit/test_remove_channels_from_push.py @@ -0,0 +1,112 @@ +import unittest +import pytest +from pubnub.exceptions import PubNubException +from pubnub.pubnub import PubNub +from pubnub.endpoints.push.remove_channels_from_push import RemoveChannelsFromPush +from pubnub.enums import PNPushType, PNPushEnvironment +from tests.helper import mocked_config + + +class TestRemoveChannelsFromPush(unittest.TestCase): + """Unit tests for the remove_channels_from_push method in PubNub core.""" + + def test_remove_channels_from_push_with_named_parameters(self): + """Test remove_channels_from_push with named parameters.""" + pubnub = PubNub(mocked_config) + channels = ["alerts", "news", "updates"] + device_id = "test_device_456" + push_type = PNPushType.APNS2 + topic = "com.example.app.notifications" + environment = PNPushEnvironment.DEVELOPMENT + + endpoint = pubnub.remove_channels_from_push( + channels=channels, + device_id=device_id, + push_type=push_type, + topic=topic, + environment=environment + ) + + self.assertIsInstance(endpoint, RemoveChannelsFromPush) + self.assertEqual(endpoint._channels, channels) + self.assertEqual(endpoint._device_id, device_id) + self.assertEqual(endpoint._push_type, push_type) + self.assertEqual(endpoint._topic, topic) + self.assertEqual(endpoint._environment, environment) + + def test_remove_channels_from_push_builder(self): + """Test that the returned object supports method chaining.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_channels_from_push() \ + .channels(["test_channel"]) \ + .device_id("test_device") \ + .push_type(PNPushType.GCM) \ + .topic("test_topic") \ + .environment(PNPushEnvironment.DEVELOPMENT) + + self.assertIsInstance(endpoint, RemoveChannelsFromPush) + self.assertEqual(endpoint._channels, ["test_channel"]) + self.assertEqual(endpoint._device_id, "test_device") + self.assertEqual(endpoint._push_type, PNPushType.GCM) + + def test_remove_channels_from_push_apns2_fails_without_topic(self): + """Test that APNS2 fails validation when no topic is provided.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_channels_from_push( + channels=["test_channel"], + device_id="test_device", + push_type=PNPushType.APNS2 + # No topic provided - should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push notification topic is missing", str(exc_info.value)) + + def test_remove_channels_from_push_none_push_type_validation(self): + """Test that None push_type fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_channels_from_push( + channels=["test_channel"], + device_id="test_device", + push_type=None # None push_type should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push Type is missing", str(exc_info.value)) + + def test_remove_channels_from_push_none_device_id_validation(self): + """Test that None device_id fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_channels_from_push( + channels=["test_channel"], + device_id=None, # None device_id should fail validation + push_type=PNPushType.APNS + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Device ID is missing", str(exc_info.value)) + + def test_remove_channels_from_push_none_channels_validation(self): + """Test that None channels fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_channels_from_push( + channels=None, # None channels should fail validation + device_id="test_device", + push_type=PNPushType.APNS + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Channel missing", str(exc_info.value)) \ No newline at end of file diff --git a/tests/unit/test_remove_device_from_push.py b/tests/unit/test_remove_device_from_push.py new file mode 100644 index 00000000..619fea13 --- /dev/null +++ b/tests/unit/test_remove_device_from_push.py @@ -0,0 +1,89 @@ +import unittest +import pytest +from pubnub.exceptions import PubNubException +from pubnub.pubnub import PubNub +from pubnub.endpoints.push.remove_device import RemoveDeviceFromPush +from pubnub.enums import PNPushType, PNPushEnvironment +from tests.helper import mocked_config + + +class TestRemoveDeviceFromPush(unittest.TestCase): + """Unit tests for the remove_device_from_push method in PubNub core.""" + + def test_remove_device_from_push_with_named_parameters(self): + """Test remove_device_from_push with named parameters.""" + pubnub = PubNub(mocked_config) + device_id = "test_device_456" + push_type = PNPushType.APNS2 + topic = "com.example.app.notifications" + environment = PNPushEnvironment.DEVELOPMENT + + endpoint = pubnub.remove_device_from_push( + device_id=device_id, + push_type=push_type, + topic=topic, + environment=environment + ) + + self.assertIsInstance(endpoint, RemoveDeviceFromPush) + self.assertEqual(endpoint._device_id, device_id) + self.assertEqual(endpoint._push_type, push_type) + self.assertEqual(endpoint._topic, topic) + self.assertEqual(endpoint._environment, environment) + + def test_remove_device_from_push_builder(self): + """Test that the returned object supports method chaining.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_device_from_push() \ + .device_id("test_device") \ + .push_type(PNPushType.GCM) \ + .topic("test_topic") \ + .environment(PNPushEnvironment.DEVELOPMENT) + + self.assertIsInstance(endpoint, RemoveDeviceFromPush) + self.assertEqual(endpoint._device_id, "test_device") + self.assertEqual(endpoint._push_type, PNPushType.GCM) + + def test_remove_device_from_push_apns2_fails_without_topic(self): + """Test that APNS2 fails validation when no topic is provided.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_device_from_push( + device_id="test_device", + push_type=PNPushType.APNS2 + # No topic provided - should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push notification topic is missing", str(exc_info.value)) + + def test_remove_device_from_push_none_push_type_validation(self): + """Test that None push_type fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_device_from_push( + device_id="test_device", + push_type=None # None push_type should fail validation + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Push Type is missing", str(exc_info.value)) + + def test_remove_device_from_push_none_device_id_validation(self): + """Test that None device_id fails validation when required.""" + pubnub = PubNub(mocked_config) + + endpoint = pubnub.remove_device_from_push( + device_id=None, # None device_id should fail validation + push_type=PNPushType.APNS + ) + + with pytest.raises(PubNubException) as exc_info: + endpoint.validate_params() + + self.assertIn("Device ID is missing", str(exc_info.value)) \ No newline at end of file From 7a8a4145cf3191498fef0da012bcb234f54ea0b1 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 5 Jun 2025 14:59:14 +0200 Subject: [PATCH 4/8] Tests pt. 2 --- .../after_add_operations.json | 123 ++++ .../after_device_removal.json | 241 +++++++ .../after_mixed_operations.json | 300 +++++++++ .../after_remove_operations.json | 182 ++++++ .../apns2_basic_success.json | 64 ++ .../apns2_development_environment.json | 64 ++ .../apns2_production_environment.json | 64 ++ .../apns2_topic_validation.json | 300 +++++++++ .../apns_basic_success.json | 64 ++ .../cross_device_isolation.json | 241 +++++++ .../list_push_channels/empty_device.json | 64 ++ .../list_push_channels/gcm_basic_success.json | 64 ++ .../invalid_push_type_error.json | 64 ++ .../mpns_basic_success.json | 64 ++ .../list_push_channels/populated_device.json | 64 ++ .../success_response_structure.json | 64 ++ .../native_sync/test_list_push_channels.py | 601 ++++++++++++++++++ 17 files changed, 2628 insertions(+) create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/after_add_operations.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/after_device_removal.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/after_mixed_operations.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/after_remove_operations.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/apns2_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/apns2_development_environment.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/apns2_production_environment.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/apns2_topic_validation.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/apns_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/cross_device_isolation.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/empty_device.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/gcm_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/invalid_push_type_error.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/mpns_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/populated_device.json create mode 100644 tests/integrational/fixtures/native_sync/list_push_channels/success_response_structure.json create mode 100644 tests/integrational/native_sync/test_list_push_channels.py diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/after_add_operations.json b/tests/integrational/fixtures/native_sync/list_push_channels/after_add_operations.json new file mode 100644 index 00000000..53e25278 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/after_add_operations.json @@ -0,0 +1,123 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=test_channel_1%2Ctest_channel_2%2Ctest_channel_3&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:45 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:45 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "152" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVqAAAAAAAAAB9lIwGc3RyaW5nlIyYWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIiwgImRldmljZTFfY2gxIiwgImRldmljZTFfY2gyIiwgInNoYXJlZF9jaGFubmVsIiwgInRlc3RfY2hhbm5lbF8xIiwgInRlc3RfY2hhbm5lbF8yIiwgInRlc3RfY2hhbm5lbF8zIl2Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/after_device_removal.json b/tests/integrational/fixtures/native_sync/list_push_channels/after_device_removal.json new file mode 100644 index 00000000..7c316e71 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/after_device_removal.json @@ -0,0 +1,241 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=channel_1%2Cchannel_2%2Cchannel_3&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:46 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:46 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "165" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVtQAAAAAAAAB9lIwGc3RyaW5nlIylWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8yIiwgImNoYW5uZWxfMyIsICJkZXZpY2UxX2NoMSIsICJkZXZpY2UxX2NoMiIsICJzaGFyZWRfY2hhbm5lbCIsICJ0ZXN0X2NoYW5uZWxfMSIsICJ0ZXN0X2NoYW5uZWxfMiIsICJ0ZXN0X2NoYW5uZWxfMyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:46 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:47 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "2" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVEgAAAAAAAAB9lIwGc3RyaW5nlIwCW12Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/after_mixed_operations.json b/tests/integrational/fixtures/native_sync/list_push_channels/after_mixed_operations.json new file mode 100644 index 00000000..d857fd97 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/after_mixed_operations.json @@ -0,0 +1,300 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=ch_1%2Cch_2%2Cch_3&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:47 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=ch_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=ch_4%2Cch_5&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=ch_1&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWyJjaF8zIiwgImNoXzQiLCAiY2hfNSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/after_remove_operations.json b/tests/integrational/fixtures/native_sync/list_push_channels/after_remove_operations.json new file mode 100644 index 00000000..e318c2c1 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/after_remove_operations.json @@ -0,0 +1,182 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=channel_1%2Cchannel_2%2Cchannel_3%2Cchannel_4&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:49 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=channel_2%2Cchannel_4&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:49 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:49 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "50" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVQgAAAAAAAAB9lIwGc3RyaW5nlIwyWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIl2Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/apns2_basic_success.json b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_basic_success.json new file mode 100644 index 00000000..739e643c --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:50 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "84" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVZAAAAAAAAAB9lIwGc3RyaW5nlIxUWyJhcG5zMl9kZXZfY2hhbm5lbF8yIiwgImFwbnMyX2Rldl9jaGFubmVsXzEiLCAiYXBuczJfY2hhbm5lbF8yIiwgImFwbnMyX2NoYW5uZWxfMSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/apns2_development_environment.json b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_development_environment.json new file mode 100644 index 00000000..d971547b --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_development_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:51 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "84" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVZAAAAAAAAAB9lIwGc3RyaW5nlIxUWyJhcG5zMl9kZXZfY2hhbm5lbF8yIiwgImFwbnMyX2Rldl9jaGFubmVsXzEiLCAiYXBuczJfY2hhbm5lbF8yIiwgImFwbnMyX2NoYW5uZWxfMSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/apns2_production_environment.json b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_production_environment.json new file mode 100644 index 00000000..927e7ba8 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_production_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=production&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:51 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "48" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVQAAAAAAAAAB9lIwGc3RyaW5nlIwwWyJhcG5zMl9wcm9kX2NoYW5uZWxfMSIsICJhcG5zMl9wcm9kX2NoYW5uZWxfMiJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/apns2_topic_validation.json b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_topic_validation.json new file mode 100644 index 00000000..dd0264ee --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/apns2_topic_validation.json @@ -0,0 +1,300 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&topic=com.example.app&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "28" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLAAAAAAAAAB9lIwGc3RyaW5nlIwcWyJhcG5zMl90b3BpY190ZXN0X2NoYW5uZWwiXZRzLg==" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&topic=com.example-app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "28" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLAAAAAAAAAB9lIwGc3RyaW5nlIwcWyJhcG5zMl90b3BpY190ZXN0X2NoYW5uZWwiXZRzLg==" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&topic=com.example_app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:53 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "28" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLAAAAAAAAAB9lIwGc3RyaW5nlIwcWyJhcG5zMl90b3BpY190ZXN0X2NoYW5uZWwiXZRzLg==" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&topic=com.EXAMPLE.APP.NOTIFICATIONS&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:53 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "28" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLAAAAAAAAAB9lIwGc3RyaW5nlIwcWyJhcG5zMl90b3BpY190ZXN0X2NoYW5uZWwiXZRzLg==" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&topic=com.example.app.notifications-dev&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:53 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "28" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLAAAAAAAAAB9lIwGc3RyaW5nlIwcWyJhcG5zMl90b3BpY190ZXN0X2NoYW5uZWwiXZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/apns_basic_success.json b/tests/integrational/fixtures/native_sync/list_push_channels/apns_basic_success.json new file mode 100644 index 00000000..bc57f397 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/apns_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:54 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "50" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVQgAAAAAAAAB9lIwGc3RyaW5nlIwyWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIl2Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/cross_device_isolation.json b/tests/integrational/fixtures/native_sync/list_push_channels/cross_device_isolation.json new file mode 100644 index 00000000..4271dd43 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/cross_device_isolation.json @@ -0,0 +1,241 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=device1_ch1%2Cdevice1_ch2%2Cshared_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:54 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/1111111111111111?add=device2_ch1%2Cdevice2_ch2%2Cshared_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:55 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:55 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "98" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVcgAAAAAAAAB9lIwGc3RyaW5nlIxiWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIiwgImRldmljZTFfY2gxIiwgImRldmljZTFfY2gyIiwgInNoYXJlZF9jaGFubmVsIl2Ucy4=" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/1111111111111111?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:55 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "48" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVQAAAAAAAAAB9lIwGc3RyaW5nlIwwWyJkZXZpY2UyX2NoMSIsICJkZXZpY2UyX2NoMiIsICJzaGFyZWRfY2hhbm5lbCJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/empty_device.json b/tests/integrational/fixtures/native_sync/list_push_channels/empty_device.json new file mode 100644 index 00000000..3f171578 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/empty_device.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:56 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "98" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVcgAAAAAAAAB9lIwGc3RyaW5nlIxiWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIiwgImRldmljZTFfY2gxIiwgImRldmljZTFfY2gyIiwgInNoYXJlZF9jaGFubmVsIl2Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/gcm_basic_success.json b/tests/integrational/fixtures/native_sync/list_push_channels/gcm_basic_success.json new file mode 100644 index 00000000..a3d2dde6 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/gcm_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=gcm&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:56 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "34" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVMgAAAAAAAAB9lIwGc3RyaW5nlIwiWyJnY21fY2hhbm5lbF8xIiwgImdjbV9jaGFubmVsXzIiXZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/invalid_push_type_error.json b/tests/integrational/fixtures/native_sync/list_push_channels/invalid_push_type_error.json new file mode 100644 index 00000000..d802533e --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/invalid_push_type_error.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 400, + "message": "Bad Request" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:57 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "34" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVMgAAAAAAAAB9lIwGc3RyaW5nlIwieyJlcnJvciI6ICJJbnZhbGlkIHR5cGUgYXJndW1lbnQifZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/mpns_basic_success.json b/tests/integrational/fixtures/native_sync/list_push_channels/mpns_basic_success.json new file mode 100644 index 00000000..2ee627f0 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/mpns_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=mpns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:58 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "2" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVEgAAAAAAAAB9lIwGc3RyaW5nlIwCW12Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/populated_device.json b/tests/integrational/fixtures/native_sync/list_push_channels/populated_device.json new file mode 100644 index 00000000..0077dd25 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/populated_device.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:59 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "98" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVcgAAAAAAAAB9lIwGc3RyaW5nlIxiWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIiwgImRldmljZTFfY2gxIiwgImRldmljZTFfY2gyIiwgInNoYXJlZF9jaGFubmVsIl2Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/list_push_channels/success_response_structure.json b/tests/integrational/fixtures/native_sync/list_push_channels/success_response_structure.json new file mode 100644 index 00000000..0077dd25 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/list_push_channels/success_response_structure.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 12:42:59 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "98" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVcgAAAAAAAAB9lIwGc3RyaW5nlIxiWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIiwgImRldmljZTFfY2gxIiwgImRldmljZTFfY2gyIiwgInNoYXJlZF9jaGFubmVsIl2Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/native_sync/test_list_push_channels.py b/tests/integrational/native_sync/test_list_push_channels.py new file mode 100644 index 00000000..075492bc --- /dev/null +++ b/tests/integrational/native_sync/test_list_push_channels.py @@ -0,0 +1,601 @@ +import unittest + +from pubnub.pubnub import PubNub +from pubnub.enums import PNPushType, PNPushEnvironment +from pubnub.exceptions import PubNubException +from tests.helper import pnconf_env_copy +from tests.integrational.vcr_helper import pn_vcr + + +class TestListPushChannelsIntegration(unittest.TestCase): + """Integration tests for list_push_channels endpoint.""" + + def setUp(self): + """Set up test fixtures before each test method.""" + self.pubnub = PubNub(pnconf_env_copy(uuid="test-uuid")) + + def tearDown(self): + """Clean up after each test method.""" + pass + + # ============================================== + # BASIC FUNCTIONALITY TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/apns_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_apns_basic_success(self): + """Test basic APNS channel listing functionality.""" + device_id = "0000000000000000" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/gcm_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_gcm_basic_success(self): + """Test basic GCM channel listing functionality.""" + device_id = "0000000000000000" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.GCM) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/apns2_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_apns2_basic_success(self): + """Test basic APNS2 channel listing functionality.""" + device_id = "0000000000000000" + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/mpns_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_mpns_basic_success(self): + """Test basic MPNS channel listing functionality.""" + device_id = "0000000000000000" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.MPNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/empty_device.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_empty_device(self): + """Test listing channels for device with no registered channels.""" + device_id = "0000000000000000" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/populated_device.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_populated_device(self): + """Test listing channels for device with registered channels.""" + device_id = "0000000000000000" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + # ============================================== + # END-TO-END WORKFLOW TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/after_add_operations.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_after_add_operations(self): + """Test listing channels after adding channels to device.""" + device_id = "0000000000000000" + channels_to_add = ["test_channel_1", "test_channel_2", "test_channel_3"] + + # First, add channels to the device + add_envelope = self.pubnub.add_channels_to_push() \ + .channels(channels_to_add) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify add operation was successful + self.assertIsNotNone(add_envelope) + self.assertTrue(add_envelope.status.is_error() is False) + + # Now list the channels for the device + list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify list operation was successful + self.assertIsNotNone(list_envelope) + self.assertIsNotNone(list_envelope.result) + self.assertTrue(list_envelope.status.is_error() is False) + self.assertIsInstance(list_envelope.result.channels, list) + + # Verify that the added channels are present in the list + returned_channels = list_envelope.result.channels + for channel in channels_to_add: + self.assertIn(channel, returned_channels) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/after_remove_operations.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_after_remove_operations(self): + """Test listing channels after removing channels from device.""" + device_id = "0000000000000000" + initial_channels = ["channel_1", "channel_2", "channel_3", "channel_4"] + channels_to_remove = ["channel_2", "channel_4"] + + # First, add channels to the device + add_envelope = self.pubnub.add_channels_to_push() \ + .channels(initial_channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify add operation was successful + self.assertIsNotNone(add_envelope) + self.assertTrue(add_envelope.status.is_error() is False) + + # Remove some channels from the device + remove_envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels_to_remove) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify remove operation was successful + self.assertIsNotNone(remove_envelope) + self.assertTrue(remove_envelope.status.is_error() is False) + + # Now list the channels for the device + list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify list operation was successful + self.assertIsNotNone(list_envelope) + self.assertIsNotNone(list_envelope.result) + self.assertTrue(list_envelope.status.is_error() is False) + self.assertIsInstance(list_envelope.result.channels, list) + + # Verify that removed channels are not in the list + returned_channels = list_envelope.result.channels + for channel in channels_to_remove: + self.assertNotIn(channel, returned_channels) + + # Verify that remaining channels are still present + remaining_channels = [ch for ch in initial_channels if ch not in channels_to_remove] + for channel in remaining_channels: + self.assertIn(channel, returned_channels) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/after_mixed_operations.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_after_mixed_operations(self): + """Test listing channels after various add/remove operations.""" + device_id = "0000000000000000" + + # Step 1: Add initial set of channels + initial_channels = ["ch_1", "ch_2", "ch_3"] + add_envelope_1 = self.pubnub.add_channels_to_push() \ + .channels(initial_channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.assertTrue(add_envelope_1.status.is_error() is False) + + # Step 2: Remove some channels + channels_to_remove = ["ch_2"] + remove_envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels_to_remove) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.assertTrue(remove_envelope.status.is_error() is False) + + # Step 3: Add more channels + additional_channels = ["ch_4", "ch_5"] + add_envelope_2 = self.pubnub.add_channels_to_push() \ + .channels(additional_channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.assertTrue(add_envelope_2.status.is_error() is False) + + # Step 4: Remove another channel + more_channels_to_remove = ["ch_1"] + remove_envelope_2 = self.pubnub.remove_channels_from_push() \ + .channels(more_channels_to_remove) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.assertTrue(remove_envelope_2.status.is_error() is False) + + # Final step: List channels and verify the final state + list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify list operation was successful + self.assertIsNotNone(list_envelope) + self.assertIsNotNone(list_envelope.result) + self.assertTrue(list_envelope.status.is_error() is False) + self.assertIsInstance(list_envelope.result.channels, list) + + # Expected final channels: ch_3, ch_4, ch_5 (removed ch_1 and ch_2) + expected_channels = ["ch_3", "ch_4", "ch_5"] + removed_channels = ["ch_1", "ch_2"] + + returned_channels = list_envelope.result.channels + + # Verify expected channels are present + for channel in expected_channels: + self.assertIn(channel, returned_channels) + + # Verify removed channels are not present + for channel in removed_channels: + self.assertNotIn(channel, returned_channels) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/cross_device_isolation.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_cross_device_isolation(self): + """Test that listing channels shows only device-specific channels.""" + device_id_1 = "0000000000000000" + device_id_2 = "1111111111111111" + + device_1_channels = ["device1_ch1", "device1_ch2", "shared_channel"] + device_2_channels = ["device2_ch1", "device2_ch2", "shared_channel"] + + # Add channels to device 1 + add_envelope_1 = self.pubnub.add_channels_to_push() \ + .channels(device_1_channels) \ + .device_id(device_id_1) \ + .push_type(PNPushType.APNS) \ + .sync() + self.assertTrue(add_envelope_1.status.is_error() is False) + + # Add channels to device 2 + add_envelope_2 = self.pubnub.add_channels_to_push() \ + .channels(device_2_channels) \ + .device_id(device_id_2) \ + .push_type(PNPushType.APNS) \ + .sync() + self.assertTrue(add_envelope_2.status.is_error() is False) + + # List channels for device 1 + list_envelope_1 = self.pubnub.list_push_channels() \ + .device_id(device_id_1) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify list operation was successful for device 1 + self.assertIsNotNone(list_envelope_1) + self.assertIsNotNone(list_envelope_1.result) + self.assertTrue(list_envelope_1.status.is_error() is False) + self.assertIsInstance(list_envelope_1.result.channels, list) + + # List channels for device 2 + list_envelope_2 = self.pubnub.list_push_channels() \ + .device_id(device_id_2) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify list operation was successful for device 2 + self.assertIsNotNone(list_envelope_2) + self.assertIsNotNone(list_envelope_2.result) + self.assertTrue(list_envelope_2.status.is_error() is False) + self.assertIsInstance(list_envelope_2.result.channels, list) + + # Verify device isolation - device 1 should only have its channels + device_1_returned = list_envelope_1.result.channels + for channel in device_1_channels: + self.assertIn(channel, device_1_returned) + + # Device 1 should not have device 2 specific channels + device_2_specific = ["device2_ch1", "device2_ch2"] + for channel in device_2_specific: + self.assertNotIn(channel, device_1_returned) + + # Verify device isolation - device 2 should only have its channels + device_2_returned = list_envelope_2.result.channels + for channel in device_2_channels: + self.assertIn(channel, device_2_returned) + + # Device 2 should not have device 1 specific channels + device_1_specific = ["device1_ch1", "device1_ch2"] + for channel in device_1_specific: + self.assertNotIn(channel, device_2_returned) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/after_device_removal.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_after_device_removal(self): + """Test listing channels after device has been removed.""" + device_id = "0000000000000000" + channels_to_add = ["channel_1", "channel_2", "channel_3"] + + # First, add channels to the device + add_envelope = self.pubnub.add_channels_to_push() \ + .channels(channels_to_add) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify add operation was successful + self.assertIsNotNone(add_envelope) + self.assertTrue(add_envelope.status.is_error() is False) + + # Verify channels were added by listing them + initial_list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(initial_list_envelope) + self.assertTrue(initial_list_envelope.status.is_error() is False) + initial_channels = initial_list_envelope.result.channels + for channel in channels_to_add: + self.assertIn(channel, initial_channels) + + # Remove the entire device from push notifications + remove_device_envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify device removal was successful + self.assertIsNotNone(remove_device_envelope) + self.assertTrue(remove_device_envelope.status.is_error() is False) + + # Now list channels for the removed device + final_list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Verify list operation was successful + self.assertIsNotNone(final_list_envelope) + self.assertIsNotNone(final_list_envelope.result) + self.assertTrue(final_list_envelope.status.is_error() is False) + self.assertIsInstance(final_list_envelope.result.channels, list) + + # Verify that the device has no channels registered (empty list) + final_channels = final_list_envelope.result.channels + self.assertEqual(len(final_channels), 0, "Device should have no channels after removal") + + # ============================================== + # ERROR RESPONSE TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/missing_topic_apns2_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_missing_topic_apns2_error(self): + """Test error response for APNS2 without required topic.""" + device_id = "0000000000000000" + + try: + self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .sync() + self.fail("Expected PubNubException for missing topic") + except PubNubException as e: + assert "Push notification topic is missing. Required only if push type is APNS2." == str(e) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/invalid_push_type_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_invalid_push_type_error(self): + """Test error response for invalid push type.""" + device_id = "0000000000000000" + + try: + self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type("INVALID_PUSH_TYPE") \ + .sync() + self.fail("Expected PubNubException for invalid push type") + except PubNubException as e: + assert 400 == e.get_status_code() + assert "Invalid type argument" in e.get_error_message() + + # ============================================== + # RESPONSE VALIDATION TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/success_response_structure.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_success_response_structure(self): + """Test success response structure and content.""" + device_id = "0000000000000000" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Validate envelope structure + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertIsNotNone(envelope.status) + + # Validate status + self.assertFalse(envelope.status.is_error()) + self.assertIsNotNone(envelope.status.status_code) + self.assertEqual(envelope.status.status_code, 200) + + # Validate result structure + self.assertIsInstance(envelope.result.channels, list) + + # ============================================== + # APNS2 SPECIFIC TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/apns2_development_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_apns2_development_environment(self): + """Test APNS2 with development environment.""" + device_id = "0000000000000000" + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/apns2_production_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_apns2_production_environment(self): + """Test APNS2 with production environment.""" + device_id = "0000000000000000" + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.PRODUCTION) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/apns2_topic_validation.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_apns2_topic_validation(self): + """Test APNS2 topic validation and format requirements.""" + device_id = "0000000000000000" + + # Test valid topic formats + valid_topics = [ + "com.example.app", + "com.example-app.notifications", + "com.example_app.notifications", + "com.EXAMPLE.APP.NOTIFICATIONS", + "com.example.app.notifications-dev" + ] + + for topic in valid_topics: + envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + self.assertIsInstance(envelope.result.channels, list) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/list_push_channels/apns2_cross_environment_isolation.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_list_push_channels_apns2_cross_environment_isolation(self): + """Test that channels are isolated between environments.""" + # TODO: Implement test for cross-environment isolation + pass From ffedb65c53d2b53ae91600245fc2cc057665a18f Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 5 Jun 2025 15:12:49 +0200 Subject: [PATCH 5/8] Tests pt.3 --- .../apns2_basic_success.json | 64 ++ .../apns2_development_environment.json | 64 ++ .../apns2_production_environment.json | 64 ++ .../apns2_topic_validation.json | 300 +++++++ .../apns_basic_success.json | 64 ++ .../duplicate_channels.json | 64 ++ .../full_workflow_apns.json | 123 +++ .../full_workflow_apns2.json | 123 +++ .../gcm_basic_success.json | 64 ++ .../invalid_push_type_error.json | 64 ++ .../long_device_id.json | 64 ++ .../maximum_channels_boundary.json | 64 ++ .../mpns_basic_success.json | 64 ++ .../multiple_channels.json | 64 ++ .../network_timeout_error.json | 64 ++ .../nonexistent_channels.json | 64 ++ .../partial_removal.json | 123 +++ .../response_content_type.json | 64 ++ .../response_encoding.json | 64 ++ .../response_headers.json | 64 ++ .../response_status_codes.json | 64 ++ .../response_timing.json | 64 ++ .../single_channel.json | 64 ++ .../special_characters_in_channels.json | 64 ++ .../special_device_id_formats.json | 182 ++++ .../special_topic_formats.json | 300 +++++++ .../success_response_structure.json | 64 ++ .../then_list_verification.json | 182 ++++ .../unicode_device_id.json | 64 ++ .../test_remove_channels_from_push.py | 776 ++++++++++++++++++ tests/unit/test_add_channels_to_push.py | 4 - tests/unit/test_remove_channels_from_push.py | 2 +- tests/unit/test_remove_device_from_push.py | 2 +- 33 files changed, 3519 insertions(+), 6 deletions(-) create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_development_environment.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_production_environment.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_topic_validation.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/apns_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/duplicate_channels.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns2.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/gcm_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/invalid_push_type_error.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/long_device_id.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/maximum_channels_boundary.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/mpns_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/multiple_channels.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/network_timeout_error.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/nonexistent_channels.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/partial_removal.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/response_content_type.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/response_encoding.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/response_headers.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/response_status_codes.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/response_timing.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/single_channel.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/special_characters_in_channels.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/special_device_id_formats.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/special_topic_formats.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/success_response_structure.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/then_list_verification.json create mode 100644 tests/integrational/fixtures/native_sync/remove_channels_from_push/unicode_device_id.json create mode 100644 tests/integrational/native_sync/test_remove_channels_from_push.py diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_basic_success.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_basic_success.json new file mode 100644 index 00000000..1fe72799 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_remove_channel_1%2Capns2_remove_channel_2&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:04 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_development_environment.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_development_environment.json new file mode 100644 index 00000000..44b8d3e2 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_development_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_dev_remove_channel_1%2Capns2_dev_remove_channel_2&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:05 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_production_environment.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_production_environment.json new file mode 100644 index 00000000..c40f7cb7 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_production_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=production&remove=apns2_prod_remove_channel_1%2Capns2_prod_remove_channel_2&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:06 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_topic_validation.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_topic_validation.json new file mode 100644 index 00000000..0475a979 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_topic_validation.json @@ -0,0 +1,300 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_remove_test_channel&topic=com.example.app&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:06 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_remove_test_channel&topic=com.example-app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:07 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_remove_test_channel&topic=com.example_app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:07 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_remove_test_channel&topic=com.EXAMPLE.APP.NOTIFICATIONS&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:07 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_remove_test_channel&topic=com.example.app.notifications-dev&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:07 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns_basic_success.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns_basic_success.json new file mode 100644 index 00000000..32ff1fc6 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/apns_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=remove_channel_1%2Cremove_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:08 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/duplicate_channels.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/duplicate_channels.json new file mode 100644 index 00000000..e82d223f --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/duplicate_channels.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=duplicate_channel%2Cduplicate_channel%2Cunique_channel%2Cduplicate_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:09 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns.json new file mode 100644 index 00000000..aa9dfca8 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns.json @@ -0,0 +1,123 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=workflow_channel_1%2Cworkflow_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:10 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=workflow_channel_1%2Cworkflow_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:10 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns2.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns2.json new file mode 100644 index 00000000..3b436e56 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns2.json @@ -0,0 +1,123 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_workflow_channel_1%2Capns2_workflow_channel_2&environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:11 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_workflow_channel_1%2Capns2_workflow_channel_2&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:11 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/gcm_basic_success.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/gcm_basic_success.json new file mode 100644 index 00000000..30616e98 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/gcm_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=gcm_remove_channel_1%2Cgcm_remove_channel_2&type=gcm&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:11 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/invalid_push_type_error.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/invalid_push_type_error.json new file mode 100644 index 00000000..cee1fc23 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/invalid_push_type_error.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=test_channel_1&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 400, + "message": "Bad Request" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:12 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "34" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVMgAAAAAAAAB9lIwGc3RyaW5nlIwieyJlcnJvciI6ICJJbnZhbGlkIHR5cGUgYXJndW1lbnQifZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/long_device_id.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/long_device_id.json new file mode 100644 index 00000000..3f3a0cdb --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/long_device_id.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF?remove=test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:13 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/maximum_channels_boundary.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/maximum_channels_boundary.json new file mode 100644 index 00000000..6abdf690 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/maximum_channels_boundary.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=max_channel_0%2Cmax_channel_1%2Cmax_channel_2%2Cmax_channel_3%2Cmax_channel_4%2Cmax_channel_5%2Cmax_channel_6%2Cmax_channel_7%2Cmax_channel_8%2Cmax_channel_9%2Cmax_channel_10%2Cmax_channel_11%2Cmax_channel_12%2Cmax_channel_13%2Cmax_channel_14%2Cmax_channel_15%2Cmax_channel_16%2Cmax_channel_17%2Cmax_channel_18%2Cmax_channel_19%2Cmax_channel_20%2Cmax_channel_21%2Cmax_channel_22%2Cmax_channel_23%2Cmax_channel_24%2Cmax_channel_25%2Cmax_channel_26%2Cmax_channel_27%2Cmax_channel_28%2Cmax_channel_29%2Cmax_channel_30%2Cmax_channel_31%2Cmax_channel_32%2Cmax_channel_33%2Cmax_channel_34%2Cmax_channel_35%2Cmax_channel_36%2Cmax_channel_37%2Cmax_channel_38%2Cmax_channel_39%2Cmax_channel_40%2Cmax_channel_41%2Cmax_channel_42%2Cmax_channel_43%2Cmax_channel_44%2Cmax_channel_45%2Cmax_channel_46%2Cmax_channel_47%2Cmax_channel_48%2Cmax_channel_49%2Cmax_channel_50%2Cmax_channel_51%2Cmax_channel_52%2Cmax_channel_53%2Cmax_channel_54%2Cmax_channel_55%2Cmax_channel_56%2Cmax_channel_57%2Cmax_channel_58%2Cmax_channel_59%2Cmax_channel_60%2Cmax_channel_61%2Cmax_channel_62%2Cmax_channel_63%2Cmax_channel_64%2Cmax_channel_65%2Cmax_channel_66%2Cmax_channel_67%2Cmax_channel_68%2Cmax_channel_69%2Cmax_channel_70%2Cmax_channel_71%2Cmax_channel_72%2Cmax_channel_73%2Cmax_channel_74%2Cmax_channel_75%2Cmax_channel_76%2Cmax_channel_77%2Cmax_channel_78%2Cmax_channel_79%2Cmax_channel_80%2Cmax_channel_81%2Cmax_channel_82%2Cmax_channel_83%2Cmax_channel_84%2Cmax_channel_85%2Cmax_channel_86%2Cmax_channel_87%2Cmax_channel_88%2Cmax_channel_89%2Cmax_channel_90%2Cmax_channel_91%2Cmax_channel_92%2Cmax_channel_93%2Cmax_channel_94%2Cmax_channel_95%2Cmax_channel_96%2Cmax_channel_97%2Cmax_channel_98%2Cmax_channel_99&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:14 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/mpns_basic_success.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/mpns_basic_success.json new file mode 100644 index 00000000..833b2970 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/mpns_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=mpns_remove_channel_1%2Cmpns_remove_channel_2&type=mpns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:14 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/multiple_channels.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/multiple_channels.json new file mode 100644 index 00000000..cf99ff00 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/multiple_channels.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=multi_remove_1%2Cmulti_remove_2%2Cmulti_remove_3%2Cmulti_remove_4%2Cmulti_remove_5&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:15 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/network_timeout_error.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/network_timeout_error.json new file mode 100644 index 00000000..f0e2f559 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/network_timeout_error.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=timeout_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:16 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/nonexistent_channels.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/nonexistent_channels.json new file mode 100644 index 00000000..d52d91ba --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/nonexistent_channels.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=nonexistent_channel_1%2Cnonexistent_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:17 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/partial_removal.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/partial_removal.json new file mode 100644 index 00000000..23eebb61 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/partial_removal.json @@ -0,0 +1,123 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=partial_1%2Cpartial_2%2Cpartial_3%2Cpartial_4&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:17 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=partial_1%2Cpartial_3&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:17 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_content_type.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_content_type.json new file mode 100644 index 00000000..5252ad52 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_content_type.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=content_type_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:18 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_encoding.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_encoding.json new file mode 100644 index 00000000..d6a19ce9 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_encoding.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=encoding_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:19 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_headers.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_headers.json new file mode 100644 index 00000000..bc6e5149 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_headers.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=header_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:20 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_status_codes.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_status_codes.json new file mode 100644 index 00000000..6cf3b7f4 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_status_codes.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=status_code_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:20 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_timing.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_timing.json new file mode 100644 index 00000000..ff47b5e8 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/response_timing.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=timing_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:21 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/single_channel.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/single_channel.json new file mode 100644 index 00000000..dcf9c0b6 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/single_channel.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=single_remove_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:22 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_characters_in_channels.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_characters_in_channels.json new file mode 100644 index 00000000..1a89efcf --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_characters_in_channels.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=channel-with-dash%2Cchannel_with_underscore%2Cchannel.with.dots&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:23 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_device_id_formats.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_device_id_formats.json new file mode 100644 index 00000000..451eccd1 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_device_id_formats.json @@ -0,0 +1,182 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/ABCDEF1234567890?remove=test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:23 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/abcdef1234567890?remove=test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:23 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/1234567890123456?remove=test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:24 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_topic_formats.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_topic_formats.json new file mode 100644 index 00000000..4572e519 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/special_topic_formats.json @@ -0,0 +1,300 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_test_channel&topic=com.example.app&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:24 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_test_channel&topic=com.example-app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:25 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_test_channel&topic=com.example_app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:25 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_test_channel&topic=com.EXAMPLE.APP.NOTIFICATIONS&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:25 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=development&remove=apns2_topic_test_channel&topic=com.example.app.notifications-dev&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:25 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/success_response_structure.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/success_response_structure.json new file mode 100644 index 00000000..19f21a1d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/success_response_structure.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=response_test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:26 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/then_list_verification.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/then_list_verification.json new file mode 100644 index 00000000..cd330532 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/then_list_verification.json @@ -0,0 +1,182 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=verify_remove_channel_1%2Cverify_remove_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=verify_remove_channel_1&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "151" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVpwAAAAAAAAB9lIwGc3RyaW5nlIyXWyJjaF8zIiwgImNoXzQiLCAiY2hfNSIsICJjaGFubmVsXzEiLCAiY2hhbm5lbF8zIiwgImRldmljZTFfY2gxIiwgImRldmljZTFfY2gyIiwgInBhcnRpYWxfMiIsICJwYXJ0aWFsXzQiLCAic2hhcmVkX2NoYW5uZWwiLCAidmVyaWZ5X3JlbW92ZV9jaGFubmVsXzIiXZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_channels_from_push/unicode_device_id.json b/tests/integrational/fixtures/native_sync/remove_channels_from_push/unicode_device_id.json new file mode 100644 index 00000000..6b0b1e8d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_channels_from_push/unicode_device_id.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/%E6%B5%8B%E8%AF%95%E8%AE%BE%E5%A4%87ID123456?remove=test_channel&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:11:28 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/native_sync/test_remove_channels_from_push.py b/tests/integrational/native_sync/test_remove_channels_from_push.py new file mode 100644 index 00000000..a60bb02c --- /dev/null +++ b/tests/integrational/native_sync/test_remove_channels_from_push.py @@ -0,0 +1,776 @@ +import unittest + +from pubnub.pubnub import PubNub +from pubnub.enums import PNPushType, PNPushEnvironment +from pubnub.exceptions import PubNubException +from tests.helper import pnconf_env_copy +from tests.integrational.vcr_helper import pn_vcr + + +class TestRemoveChannelsFromPushIntegration(unittest.TestCase): + """Integration tests for remove_channels_from_push endpoint.""" + + def setUp(self): + """Set up test fixtures before each test method.""" + self.pubnub = PubNub(pnconf_env_copy(uuid="test-uuid")) + + # ============================================== + # BASIC FUNCTIONALITY TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/apns_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_apns_basic_success(self): + """Test basic APNS channel removal functionality.""" + device_id = "0000000000000000" + channels = ["remove_channel_1", "remove_channel_2"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/gcm_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_gcm_basic_success(self): + """Test basic GCM channel removal functionality.""" + device_id = "0000000000000000" + channels = ["gcm_remove_channel_1", "gcm_remove_channel_2"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.GCM) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_apns2_basic_success(self): + """Test basic APNS2 channel removal functionality.""" + device_id = "0000000000000000" + channels = ["apns2_remove_channel_1", "apns2_remove_channel_2"] + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/mpns_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_mpns_basic_success(self): + """Test basic MPNS channel removal functionality.""" + device_id = "0000000000000000" + channels = ["mpns_remove_channel_1", "mpns_remove_channel_2"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.MPNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/single_channel.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_single_channel(self): + """Test removing a single channel from push notifications.""" + device_id = "0000000000000000" + channels = ["single_remove_channel"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/multiple_channels.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_multiple_channels(self): + """Test removing multiple channels from push notifications.""" + device_id = "0000000000000000" + channels = ["multi_remove_1", "multi_remove_2", "multi_remove_3", "multi_remove_4", "multi_remove_5"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # END-TO-END WORKFLOW TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_full_workflow_apns(self): + """Test complete workflow: add channels, remove them, then verify.""" + device_id = "0000000000000000" + channels = ["workflow_channel_1", "workflow_channel_2"] + + # First add channels + add_envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(add_envelope) + self.assertTrue(add_envelope.status.is_error() is False) + + # Then remove them + remove_envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertIsNotNone(remove_envelope.result) + self.assertTrue(remove_envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/full_workflow_apns2.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_full_workflow_apns2(self): + """Test complete workflow: add channels with APNS2, remove them, then verify.""" + device_id = "0000000000000000" + channels = ["apns2_workflow_channel_1", "apns2_workflow_channel_2"] + topic = "com.example.testapp.notifications" + + # First add channels + add_envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(add_envelope) + self.assertTrue(add_envelope.status.is_error() is False) + + # Then remove them + remove_envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertIsNotNone(remove_envelope.result) + self.assertTrue(remove_envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/then_list_verification.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_then_list_verification(self): + """Test removing channels then listing to verify they were removed.""" + device_id = "0000000000000000" + channels = ["verify_remove_channel_1", "verify_remove_channel_2"] + + # Add channels first + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Remove some channels + remove_envelope = self.pubnub.remove_channels_from_push() \ + .channels(["verify_remove_channel_1"]) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertTrue(remove_envelope.status.is_error() is False) + + # List channels to verify removal + list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(list_envelope) + self.assertTrue(list_envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/partial_removal.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_partial_removal(self): + """Test removing some channels while leaving others.""" + device_id = "0000000000000000" + all_channels = ["partial_1", "partial_2", "partial_3", "partial_4"] + channels_to_remove = ["partial_1", "partial_3"] + + # Add all channels first + self.pubnub.add_channels_to_push() \ + .channels(all_channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Remove only some channels + remove_envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels_to_remove) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertIsNotNone(remove_envelope.result) + self.assertTrue(remove_envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/nonexistent_channels.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_nonexistent_channels(self): + """Test removing channels that were never added.""" + device_id = "0000000000000000" + channels = ["nonexistent_channel_1", "nonexistent_channel_2"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Should succeed even if channels don't exist + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # ERROR RESPONSE TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/missing_topic_apns2_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_missing_topic_apns2_error(self): + """Test error response for APNS2 without required topic.""" + device_id = "0000000000000000" + channels = ["error_channel"] + + try: + self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .sync() + self.fail("Expected PubNubException for missing topic") + except PubNubException as e: + assert "Push notification topic is missing. Required only if push type is APNS2." == str(e) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/invalid_push_type_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_invalid_push_type_error(self): + """Test error response for invalid push type.""" + device_id = "0000000000000000" + channels = ["test_channel_1"] + + try: + self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type("INVALID_PUSH_TYPE") \ + .sync() + self.fail("Expected PubNubException for invalid push type") + except PubNubException as e: + assert 400 == e.get_status_code() + assert "Invalid type argument" in e.get_error_message() + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/network_timeout_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_network_timeout_error(self): + """Test error handling for network timeout.""" + # This test would need special configuration to simulate timeout + # For now, we'll test the structure + device_id = "0000000000000000" + channels = ["timeout_test_channel"] + + try: + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + # If no timeout occurs, verify successful response + self.assertIsNotNone(envelope) + except Exception as e: + # If timeout or other network error occurs, ensure it's handled gracefully + self.assertIsInstance(e, (PubNubException, Exception)) + + # ============================================== + # EDGE CASE TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/special_characters_in_channels.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_special_characters_in_channels(self): + """Test removing channels with special characters.""" + device_id = "0000000000000000" + channels = ["channel-with-dash", "channel_with_underscore", "channel.with.dots"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/empty_channel_list.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_empty_channel_list(self): + """Test behavior with empty channel list.""" + device_id = "0000000000000000" + channels = [] + + try: + self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.fail("Expected PubNubException for empty channel list") + except PubNubException as e: + assert "Channel missing" in str(e) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/maximum_channels_boundary.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_maximum_channels_boundary(self): + """Test removing maximum allowed number of channels.""" + device_id = "0000000000000000" + # Test with a large number of channels (assuming 100 is near the limit) + channels = [f"max_channel_{i}" for i in range(100)] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/special_device_id_formats.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_special_device_id_formats(self): + """Test with various device ID formats and special characters.""" + channels = ["test_channel"] + special_device_ids = [ + "ABCDEF1234567890", # Uppercase hex + "abcdef1234567890", # Lowercase hex + "1234567890123456", # Numeric + ] + + for device_id in special_device_ids: + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/long_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_long_device_id(self): + """Test with very long device ID.""" + device_id = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" # 64 chars + channels = ["test_channel"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/special_topic_formats.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_special_topic_formats(self): + """Test APNS2 with various topic formats.""" + device_id = "0000000000000000" + channels = ["apns2_topic_test_channel"] + + # Test various topic formats + special_topics = [ + "com.example.app", + "com.example-app.notifications", + "com.example_app.notifications", + "com.EXAMPLE.APP.NOTIFICATIONS", + "com.example.app.notifications-dev" + ] + + for topic in special_topics: + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/unicode_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_unicode_device_id(self): + """Test with unicode characters in device ID.""" + device_id = "测试设备ID123456" # Unicode device ID + channels = ["test_channel"] + + try: + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + # May succeed or fail depending on validation + if envelope: + self.assertIsNotNone(envelope.result) + except PubNubException as e: + # Unicode device IDs may not be supported + self.assertIsInstance(e, PubNubException) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/duplicate_channels.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_duplicate_channels(self): + """Test removing duplicate channels in the same request.""" + device_id = "0000000000000000" + channels = ["duplicate_channel", "duplicate_channel", "unique_channel", "duplicate_channel"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # RESPONSE VALIDATION TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/success_response_structure.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_success_response_structure(self): + """Test success response structure and content.""" + device_id = "0000000000000000" + channels = ["response_test_channel"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Validate envelope structure + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertIsNotNone(envelope.status) + + # Validate status + self.assertFalse(envelope.status.is_error()) + self.assertIsNotNone(envelope.status.status_code) + self.assertEqual(envelope.status.status_code, 200) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/response_headers.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_response_headers(self): + """Test response headers are present and valid.""" + device_id = "0000000000000000" + channels = ["header_test_channel"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.status) + # Headers should be accessible through status + self.assertTrue(hasattr(envelope.status, 'status_code')) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/response_timing.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_response_timing(self): + """Test response timing is within acceptable limits.""" + import time + device_id = "0000000000000000" + channels = ["timing_test_channel"] + + start_time = time.time() + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + end_time = time.time() + + self.assertIsNotNone(envelope) + self.assertTrue(envelope.status.is_error() is False) + + # Response should be reasonably fast (less than 30 seconds) + response_time = end_time - start_time + self.assertLess(response_time, 30.0) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/response_status_codes.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_response_status_codes(self): + """Test various HTTP status codes in responses.""" + device_id = "0000000000000000" + channels = ["status_code_test_channel"] + + # Test successful response (200) + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.status) + self.assertEqual(envelope.status.status_code, 200) + self.assertFalse(envelope.status.is_error()) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/response_content_type.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_response_content_type(self): + """Test response content type is correct.""" + device_id = "0000000000000000" + channels = ["content_type_test_channel"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + # Result should be JSON-parseable + self.assertIsNotNone(envelope.result) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/response_encoding.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_response_encoding(self): + """Test response encoding is handled correctly.""" + device_id = "0000000000000000" + channels = ["encoding_test_channel"] + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # APNS2 SPECIFIC TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_development_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_apns2_development_environment(self): + """Test APNS2 with development environment.""" + device_id = "0000000000000000" + channels = ["apns2_dev_remove_channel_1", "apns2_dev_remove_channel_2"] + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_production_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_apns2_production_environment(self): + """Test APNS2 with production environment.""" + device_id = "0000000000000000" + channels = ["apns2_prod_remove_channel_1", "apns2_prod_remove_channel_2"] + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.PRODUCTION) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_channels_from_push/apns2_topic_validation.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_channels_from_push_apns2_topic_validation(self): + """Test APNS2 topic validation and format requirements.""" + device_id = "0000000000000000" + channels = ["apns2_topic_remove_test_channel"] + + # Test valid topic formats + valid_topics = [ + "com.example.app", + "com.example-app.notifications", + "com.example_app.notifications", + "com.EXAMPLE.APP.NOTIFICATIONS", + "com.example.app.notifications-dev" + ] + + for topic in valid_topics: + envelope = self.pubnub.remove_channels_from_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) diff --git a/tests/unit/test_add_channels_to_push.py b/tests/unit/test_add_channels_to_push.py index a23686a3..c1511b7d 100644 --- a/tests/unit/test_add_channels_to_push.py +++ b/tests/unit/test_add_channels_to_push.py @@ -110,7 +110,3 @@ def test_add_channels_to_push_none_channels_validation(self): endpoint.validate_params() self.assertIn("Channel missing", str(exc_info.value)) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file diff --git a/tests/unit/test_remove_channels_from_push.py b/tests/unit/test_remove_channels_from_push.py index c1144eaf..01809070 100644 --- a/tests/unit/test_remove_channels_from_push.py +++ b/tests/unit/test_remove_channels_from_push.py @@ -109,4 +109,4 @@ def test_remove_channels_from_push_none_channels_validation(self): with pytest.raises(PubNubException) as exc_info: endpoint.validate_params() - self.assertIn("Channel missing", str(exc_info.value)) \ No newline at end of file + self.assertIn("Channel missing", str(exc_info.value)) diff --git a/tests/unit/test_remove_device_from_push.py b/tests/unit/test_remove_device_from_push.py index 619fea13..2aca152f 100644 --- a/tests/unit/test_remove_device_from_push.py +++ b/tests/unit/test_remove_device_from_push.py @@ -86,4 +86,4 @@ def test_remove_device_from_push_none_device_id_validation(self): with pytest.raises(PubNubException) as exc_info: endpoint.validate_params() - self.assertIn("Device ID is missing", str(exc_info.value)) \ No newline at end of file + self.assertIn("Device ID is missing", str(exc_info.value)) From 03220eb926d119581b0a06bc11234994099b60f9 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 5 Jun 2025 15:22:07 +0200 Subject: [PATCH 6/8] Tests pt.4 Final --- .../after_channel_operations.json | 182 ++++ .../apns2_basic_success.json | 64 ++ .../apns2_cross_environment_removal.json | 241 ++++++ .../apns2_development_environment.json | 64 ++ .../apns2_production_environment.json | 64 ++ .../apns2_topic_validation.json | 300 +++++++ .../apns_basic_success.json | 64 ++ .../case_sensitive_device_id.json | 123 +++ .../complete_unregistration.json | 64 ++ .../full_workflow_apns.json | 123 +++ .../full_workflow_apns2.json | 123 +++ .../gcm_basic_success.json | 64 ++ .../invalid_push_type_error.json | 64 ++ .../mpns_basic_success.json | 64 ++ .../multiple_rapid_removals.json | 182 ++++ .../network_timeout_error.json | 64 ++ .../nonexistent_device.json | 64 ++ .../numeric_device_id.json | 64 ++ .../response_content_type.json | 64 ++ .../response_encoding.json | 64 ++ .../response_headers.json | 64 ++ .../response_status_codes.json | 64 ++ .../response_timing.json | 64 ++ .../special_device_id_formats.json | 182 ++++ .../special_topic_formats.json | 300 +++++++ .../success_response_structure.json | 64 ++ .../then_list_verification.json | 182 ++++ .../unicode_device_id.json | 64 ++ .../very_long_device_id.json | 64 ++ .../whitespace_device_id.json | 64 ++ .../test_remove_device_from_push.py | 790 ++++++++++++++++++ 31 files changed, 4008 insertions(+) create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/after_channel_operations.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_cross_environment_removal.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_development_environment.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_production_environment.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_topic_validation.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/apns_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/case_sensitive_device_id.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/complete_unregistration.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns2.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/gcm_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/invalid_push_type_error.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/mpns_basic_success.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/multiple_rapid_removals.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/network_timeout_error.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/nonexistent_device.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/numeric_device_id.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/response_content_type.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/response_encoding.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/response_headers.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/response_status_codes.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/response_timing.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/special_device_id_formats.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/special_topic_formats.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/success_response_structure.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/then_list_verification.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/unicode_device_id.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/very_long_device_id.json create mode 100644 tests/integrational/fixtures/native_sync/remove_device_from_push/whitespace_device_id.json create mode 100644 tests/integrational/native_sync/test_remove_device_from_push.py diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/after_channel_operations.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/after_channel_operations.json new file mode 100644 index 00000000..ed86ad40 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/after_channel_operations.json @@ -0,0 +1,182 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=channel_op_1%2Cchannel_op_2%2Cchannel_op_3&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?remove=channel_op_1&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_basic_success.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_basic_success.json new file mode 100644 index 00000000..92cf92ef --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:28 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_cross_environment_removal.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_cross_environment_removal.json new file mode 100644 index 00000000..fef40df1 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_cross_environment_removal.json @@ -0,0 +1,241 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=cross_env_channel_1%2Ccross_env_channel_2&environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:29 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=cross_env_channel_1%2Ccross_env_channel_2&environment=production&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:29 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:29 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?environment=production&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:29 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "94" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVbgAAAAAAAAB9lIwGc3RyaW5nlIxeWyJhcG5zMl9wcm9kX2NoYW5uZWxfMSIsICJhcG5zMl9wcm9kX2NoYW5uZWxfMiIsICJjcm9zc19lbnZfY2hhbm5lbF8yIiwgImNyb3NzX2Vudl9jaGFubmVsXzEiXZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_development_environment.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_development_environment.json new file mode 100644 index 00000000..865d6f8b --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_development_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:30 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_production_environment.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_production_environment.json new file mode 100644 index 00000000..971d10e7 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_production_environment.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=production&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:31 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_topic_validation.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_topic_validation.json new file mode 100644 index 00000000..58e4da49 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_topic_validation.json @@ -0,0 +1,300 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.app&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:32 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example-app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:32 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example_app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:32 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.EXAMPLE.APP.NOTIFICATIONS&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:32 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.app.notifications-dev&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:32 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/apns_basic_success.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns_basic_success.json new file mode 100644 index 00000000..1d2d1b83 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/apns_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:33 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/case_sensitive_device_id.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/case_sensitive_device_id.json new file mode 100644 index 00000000..01ebaa7d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/case_sensitive_device_id.json @@ -0,0 +1,123 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/abcdef1234567890/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:34 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/ABCDEF1234567890/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:34 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/complete_unregistration.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/complete_unregistration.json new file mode 100644 index 00000000..99aa1a5c --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/complete_unregistration.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:35 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns.json new file mode 100644 index 00000000..80098357 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns.json @@ -0,0 +1,123 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=workflow_channel_1%2Cworkflow_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:36 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:36 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns2.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns2.json new file mode 100644 index 00000000..f546fe1c --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns2.json @@ -0,0 +1,123 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000?add=apns2_workflow_channel_1%2Capns2_workflow_channel_2&environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:36 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.testapp.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:37 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/gcm_basic_success.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/gcm_basic_success.json new file mode 100644 index 00000000..a2d738f0 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/gcm_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=gcm&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:37 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/invalid_push_type_error.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/invalid_push_type_error.json new file mode 100644 index 00000000..5d5be18c --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/invalid_push_type_error.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 400, + "message": "Bad Request" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:38 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "34" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVMgAAAAAAAAB9lIwGc3RyaW5nlIwieyJlcnJvciI6ICJJbnZhbGlkIHR5cGUgYXJndW1lbnQifZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/mpns_basic_success.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/mpns_basic_success.json new file mode 100644 index 00000000..8a58bc3f --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/mpns_basic_success.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=mpns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:39 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/multiple_rapid_removals.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/multiple_rapid_removals.json new file mode 100644 index 00000000..96f3dc28 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/multiple_rapid_removals.json @@ -0,0 +1,182 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:40 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:40 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:40 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/network_timeout_error.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/network_timeout_error.json new file mode 100644 index 00000000..fc7ed839 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/network_timeout_error.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:41 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/nonexistent_device.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/nonexistent_device.json new file mode 100644 index 00000000..d0d4f4c5 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/nonexistent_device.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/nonexistent_device_123/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:42 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/numeric_device_id.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/numeric_device_id.json new file mode 100644 index 00000000..978e83c4 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/numeric_device_id.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/1234567890123456/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:42 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/response_content_type.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_content_type.json new file mode 100644 index 00000000..dbd55b8b --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_content_type.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:43 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/response_encoding.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_encoding.json new file mode 100644 index 00000000..6ae85ead --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_encoding.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:44 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/response_headers.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_headers.json new file mode 100644 index 00000000..e7800162 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_headers.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:45 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/response_status_codes.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_status_codes.json new file mode 100644 index 00000000..e7800162 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_status_codes.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:45 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/response_timing.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_timing.json new file mode 100644 index 00000000..ec3008af --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/response_timing.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:46 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/special_device_id_formats.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/special_device_id_formats.json new file mode 100644 index 00000000..ac00e309 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/special_device_id_formats.json @@ -0,0 +1,182 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/ABCDEF1234567890/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:47 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/abcdef1234567890/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:47 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/1234567890123456/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:47 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/special_topic_formats.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/special_topic_formats.json new file mode 100644 index 00000000..832cf06d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/special_topic_formats.json @@ -0,0 +1,300 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.app&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example-app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example_app.notifications&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.EXAMPLE.APP.NOTIFICATIONS&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:48 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v2/push/sub-key/{PN_KEY_SUBSCRIBE}/devices-apns2/0000000000000000/remove?environment=development&topic=com.example.app.notifications-dev&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:49 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/success_response_structure.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/success_response_structure.json new file mode 100644 index 00000000..b3da5163 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/success_response_structure.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:49 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/then_list_verification.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/then_list_verification.json new file mode 100644 index 00000000..f9327fc1 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/then_list_verification.json @@ -0,0 +1,182 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?add=verify_device_channel_1%2Cverify_device_channel_2&type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:50 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "24" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVKAAAAAAAAAB9lIwGc3RyaW5nlIwYWzEsICJNb2RpZmllZCBDaGFubmVscyJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:50 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0000000000000000?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:51 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "2" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVEgAAAAAAAAB9lIwGc3RyaW5nlIwCW12Ucy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/unicode_device_id.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/unicode_device_id.json new file mode 100644 index 00000000..1d15d979 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/unicode_device_id.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/%E6%B5%8B%E8%AF%95%E8%AE%BE%E5%A4%87ID123456/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:51 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/very_long_device_id.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/very_long_device_id.json new file mode 100644 index 00000000..de6942d3 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/very_long_device_id.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/remove_device_from_push/whitespace_device_id.json b/tests/integrational/fixtures/native_sync/remove_device_from_push/whitespace_device_id.json new file mode 100644 index 00000000..8edad236 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/remove_device_from_push/whitespace_device_id.json @@ -0,0 +1,64 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/v1/push/sub-key/{PN_KEY_SUBSCRIBE}/devices/%20%201234567890ABCDEF%20%20/remove?type=apns&uuid=test-uuid", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 05 Jun 2025 13:17:53 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "21" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET, POST, DELETE, OPTIONS" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVJQAAAAAAAAB9lIwGc3RyaW5nlIwVWzEsICJSZW1vdmVkIERldmljZSJdlHMu" + } + } + } + ] +} diff --git a/tests/integrational/native_sync/test_remove_device_from_push.py b/tests/integrational/native_sync/test_remove_device_from_push.py new file mode 100644 index 00000000..97a9a430 --- /dev/null +++ b/tests/integrational/native_sync/test_remove_device_from_push.py @@ -0,0 +1,790 @@ +import unittest + +from pubnub.pubnub import PubNub +from pubnub.enums import PNPushType, PNPushEnvironment +from pubnub.exceptions import PubNubException +from tests.helper import pnconf_env_copy +from tests.integrational.vcr_helper import pn_vcr + + +class TestRemoveDeviceFromPushIntegration(unittest.TestCase): + """Integration tests for remove_device_from_push endpoint.""" + + def setUp(self): + """Set up test fixtures before each test method.""" + self.pubnub = PubNub(pnconf_env_copy(uuid="test-uuid")) + + # ============================================== + # BASIC FUNCTIONALITY TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/apns_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_apns_basic_success(self): + """Test basic APNS device removal functionality.""" + device_id = "0000000000000000" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/gcm_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_gcm_basic_success(self): + """Test basic GCM device removal functionality.""" + device_id = "0000000000000000" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.GCM) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_apns2_basic_success(self): + """Test basic APNS2 device removal functionality.""" + device_id = "0000000000000000" + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/mpns_basic_success.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_mpns_basic_success(self): + """Test basic MPNS device removal functionality.""" + device_id = "0000000000000000" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.MPNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/complete_unregistration.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_complete_unregistration(self): + """Test complete device unregistration from all push notifications.""" + device_id = "0000000000000000" + + # Remove device completely from APNS + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # END-TO-END WORKFLOW TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_full_workflow_apns(self): + """Test complete workflow: register device, remove it, then verify.""" + device_id = "0000000000000000" + channels = ["workflow_channel_1", "workflow_channel_2"] + + # First add channels to device + add_envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(add_envelope) + self.assertTrue(add_envelope.status.is_error() is False) + + # Then remove the entire device + remove_envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertIsNotNone(remove_envelope.result) + self.assertTrue(remove_envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/full_workflow_apns2.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_full_workflow_apns2(self): + """Test complete workflow: register device with APNS2, remove it, then verify.""" + device_id = "0000000000000000" + channels = ["apns2_workflow_channel_1", "apns2_workflow_channel_2"] + topic = "com.example.testapp.notifications" + + # First add channels to device + add_envelope = self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(add_envelope) + self.assertTrue(add_envelope.status.is_error() is False) + + # Then remove the entire device + remove_envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertIsNotNone(remove_envelope.result) + self.assertTrue(remove_envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/then_list_verification.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_then_list_verification(self): + """Test removing device then listing to verify it was removed.""" + device_id = "0000000000000000" + channels = ["verify_device_channel_1", "verify_device_channel_2"] + + # Add channels to device first + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Remove the entire device + remove_envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertTrue(remove_envelope.status.is_error() is False) + + # List channels to verify device removal (should be empty or error) + try: + list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # If successful, channels list should be empty + if list_envelope and list_envelope.result: + self.assertEqual(len(list_envelope.result.channels), 0) + except PubNubException: + # Device not found is also acceptable after removal + pass + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/after_channel_operations.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_after_channel_operations(self): + """Test removing device after various channel add/remove operations.""" + device_id = "0000000000000000" + channels = ["channel_op_1", "channel_op_2", "channel_op_3"] + + # Add channels to device + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Remove some channels + self.pubnub.remove_channels_from_push() \ + .channels(["channel_op_1"]) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Now remove the entire device + remove_envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertIsNotNone(remove_envelope.result) + self.assertTrue(remove_envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/nonexistent_device.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_nonexistent_device(self): + """Test removing device that was never registered.""" + device_id = "nonexistent_device_123" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Should succeed even if device doesn't exist + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # ERROR RESPONSE TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/missing_topic_apns2_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_missing_topic_apns2_error(self): + """Test error response for APNS2 without required topic.""" + device_id = "0000000000000000" + + try: + self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .sync() + self.fail("Expected PubNubException for missing topic") + except PubNubException as e: + assert "Push notification topic is missing. Required only if push type is APNS2." == str(e) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/invalid_push_type_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_invalid_push_type_error(self): + """Test error response for invalid push type.""" + device_id = "0000000000000000" + + try: + self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type("INVALID_PUSH_TYPE") \ + .sync() + self.fail("Expected PubNubException for invalid push type") + except PubNubException as e: + assert 400 == e.get_status_code() + assert "Invalid type argument" in e.get_error_message() + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/network_timeout_error.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_network_timeout_error(self): + """Test error handling for network timeout.""" + device_id = "0000000000000000" + + try: + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + # If no timeout occurs, verify successful response + self.assertIsNotNone(envelope) + except Exception as e: + # If timeout or other network error occurs, ensure it's handled gracefully + self.assertIsInstance(e, (PubNubException, Exception)) + + # ============================================== + # EDGE CASE TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/special_device_id_formats.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_special_device_id_formats(self): + """Test with various device ID formats and special characters.""" + special_device_ids = [ + "ABCDEF1234567890", # Uppercase hex + "abcdef1234567890", # Lowercase hex + "1234567890123456", # Numeric + ] + + for device_id in special_device_ids: + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/unicode_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_unicode_device_id(self): + """Test with unicode characters in device ID.""" + device_id = "测试设备ID123456" # Unicode device ID + + try: + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + # May succeed or fail depending on validation + if envelope: + self.assertIsNotNone(envelope.result) + except PubNubException as e: + # Unicode device IDs may not be supported + self.assertIsInstance(e, PubNubException) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/very_long_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_very_long_device_id(self): + """Test with very long device ID.""" + device_id = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" # 64 chars + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/empty_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_empty_device_id(self): + """Test behavior with empty device ID.""" + device_id = "" + + try: + self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + self.fail("Expected PubNubException for empty device ID") + except PubNubException as e: + assert "Device ID is missing for push operation" in str(e) or "Invalid device" in str(e) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/special_topic_formats.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_special_topic_formats(self): + """Test APNS2 with various topic formats.""" + device_id = "0000000000000000" + + # Test various topic formats + special_topics = [ + "com.example.app", + "com.example-app.notifications", + "com.example_app.notifications", + "com.EXAMPLE.APP.NOTIFICATIONS", + "com.example.app.notifications-dev" + ] + + for topic in special_topics: + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/case_sensitive_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_case_sensitive_device_id(self): + """Test case sensitivity of device IDs.""" + device_id_lower = "abcdef1234567890" + device_id_upper = "ABCDEF1234567890" + + # Test both cases + for device_id in [device_id_lower, device_id_upper]: + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/whitespace_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_whitespace_device_id(self): + """Test device IDs with leading/trailing whitespace.""" + device_id_with_spaces = " 1234567890ABCDEF " + + try: + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id_with_spaces) \ + .push_type(PNPushType.APNS) \ + .sync() + # May succeed with trimmed ID or fail with validation error + if envelope: + self.assertIsNotNone(envelope.result) + except PubNubException as e: + # Whitespace in device IDs may not be supported + self.assertIsInstance(e, PubNubException) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/numeric_device_id.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_numeric_device_id(self): + """Test with purely numeric device IDs.""" + device_id = "1234567890123456" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/multiple_rapid_removals.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_multiple_rapid_removals(self): + """Test multiple rapid removal requests for the same device.""" + device_id = "0000000000000000" + + # Perform multiple rapid removal requests + for i in range(3): + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # RESPONSE VALIDATION TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/success_response_structure.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_success_response_structure(self): + """Test success response structure and content.""" + device_id = "0000000000000000" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + # Validate envelope structure + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertIsNotNone(envelope.status) + + # Validate status + self.assertFalse(envelope.status.is_error()) + self.assertIsNotNone(envelope.status.status_code) + self.assertEqual(envelope.status.status_code, 200) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/response_headers.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_response_headers(self): + """Test response headers are present and valid.""" + device_id = "0000000000000000" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.status) + # Headers should be accessible through status + self.assertTrue(hasattr(envelope.status, 'status_code')) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/response_timing.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_response_timing(self): + """Test response timing is within acceptable limits.""" + import time + device_id = "0000000000000000" + + start_time = time.time() + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + end_time = time.time() + + self.assertIsNotNone(envelope) + self.assertTrue(envelope.status.is_error() is False) + + # Response should be reasonably fast (less than 30 seconds) + response_time = end_time - start_time + self.assertLess(response_time, 30.0) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/response_status_codes.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_response_status_codes(self): + """Test various HTTP status codes in responses.""" + device_id = "0000000000000000" + + # Test successful response (200) + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.status) + self.assertEqual(envelope.status.status_code, 200) + self.assertFalse(envelope.status.is_error()) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/response_content_type.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_response_content_type(self): + """Test response content type is correct.""" + device_id = "0000000000000000" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + # Result should be JSON-parseable + self.assertIsNotNone(envelope.result) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/response_encoding.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_response_encoding(self): + """Test response encoding is handled correctly.""" + device_id = "0000000000000000" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + # ============================================== + # APNS2 SPECIFIC TESTS + # ============================================== + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_development_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_apns2_development_environment(self): + """Test APNS2 with development environment.""" + device_id = "0000000000000000" + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_production_environment.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_apns2_production_environment(self): + """Test APNS2 with production environment.""" + device_id = "0000000000000000" + topic = "com.example.testapp.notifications" + + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.PRODUCTION) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_topic_validation.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_apns2_topic_validation(self): + """Test APNS2 topic validation and format requirements.""" + device_id = "0000000000000000" + + # Test valid topic formats + valid_topics = [ + "com.example.app", + "com.example-app.notifications", + "com.example_app.notifications", + "com.EXAMPLE.APP.NOTIFICATIONS", + "com.example.app.notifications-dev" + ] + + for topic in valid_topics: + envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(envelope) + self.assertIsNotNone(envelope.result) + self.assertTrue(envelope.status.is_error() is False) + + @pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/remove_device_from_push/apns2_cross_environment_removal.json', + serializer='pn_json', + filter_query_parameters=['seqn', 'pnsdk', 'l_sig'] + ) + def test_remove_device_from_push_apns2_cross_environment_removal(self): + """Test removing device from one environment doesn't affect the other.""" + device_id = "0000000000000000" + topic = "com.example.testapp.notifications" + channels = ["cross_env_channel_1", "cross_env_channel_2"] + + # Add channels in both environments + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.pubnub.add_channels_to_push() \ + .channels(channels) \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.PRODUCTION) \ + .sync() + + # Remove device from development environment only + remove_envelope = self.pubnub.remove_device_from_push() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.DEVELOPMENT) \ + .sync() + + self.assertIsNotNone(remove_envelope) + self.assertIsNotNone(remove_envelope.result) + self.assertTrue(remove_envelope.status.is_error() is False) + + # Verify production environment is still active + prod_list_envelope = self.pubnub.list_push_channels() \ + .device_id(device_id) \ + .push_type(PNPushType.APNS2) \ + .topic(topic) \ + .environment(PNPushEnvironment.PRODUCTION) \ + .sync() + + self.assertIsNotNone(prod_list_envelope) + self.assertTrue(prod_list_envelope.status.is_error() is False) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From 8ac5981c293a512f33553187cd00c6c92962b970 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 5 Jun 2025 15:24:07 +0200 Subject: [PATCH 7/8] Tests pt.4 Final-2 --- .../integrational/native_sync/test_remove_device_from_push.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integrational/native_sync/test_remove_device_from_push.py b/tests/integrational/native_sync/test_remove_device_from_push.py index 97a9a430..3e472e81 100644 --- a/tests/integrational/native_sync/test_remove_device_from_push.py +++ b/tests/integrational/native_sync/test_remove_device_from_push.py @@ -784,7 +784,3 @@ def test_remove_device_from_push_apns2_cross_environment_removal(self): self.assertIsNotNone(prod_list_envelope) self.assertTrue(prod_list_envelope.status.is_error() is False) - - -if __name__ == '__main__': - unittest.main() \ No newline at end of file From 22f4fb37c1a9cb0a51c3c4d086050fd23fccaeb5 Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Thu, 5 Jun 2025 17:43:28 +0000 Subject: [PATCH 8/8] PubNub SDK 10.4.1 release. --- .pubnub.yml | 13 +++++++++---- CHANGELOG.md | 6 ++++++ setup.py | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index d50b6c31..36647343 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,5 @@ name: python -version: 10.4.0 +version: 10.4.1 schema: 1 scm: github.com/pubnub/python sdks: @@ -18,7 +18,7 @@ sdks: distributions: - distribution-type: library distribution-repository: package - package-name: pubnub-10.4.0 + package-name: pubnub-10.4.1 location: https://pypi.org/project/pubnub/ supported-platforms: supported-operating-systems: @@ -94,8 +94,8 @@ sdks: - distribution-type: library distribution-repository: git release - package-name: pubnub-10.4.0 - location: https://github.com/pubnub/python/releases/download/10.4.0/pubnub-10.4.0.tar.gz + package-name: pubnub-10.4.1 + location: https://github.com/pubnub/python/releases/download/10.4.1/pubnub-10.4.1.tar.gz supported-platforms: supported-operating-systems: Linux: @@ -169,6 +169,11 @@ sdks: license-url: https://github.com/encode/httpx/blob/master/LICENSE.md is-required: Required changelog: + - date: 2025-06-05 + version: 10.4.1 + changes: + - type: bug + text: "Fixed add_channel_to_push and remove_channel_from_push endpoints." - date: 2025-05-07 version: 10.4.0 changes: diff --git a/CHANGELOG.md b/CHANGELOG.md index 191316e7..d497adee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 10.4.1 +June 05 2025 + +#### Fixed +- Fixed add_channel_to_push and remove_channel_from_push endpoints. + ## 10.4.0 May 07 2025 diff --git a/setup.py b/setup.py index a504b89b..3a00ad56 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='pubnub', - version='10.4.0', + version='10.4.1', description='PubNub Real-time push service in the cloud', author='PubNub', author_email='support@pubnub.com',