From d25a034735570787737b6ab2410f1d02be6127a5 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 22 May 2025 10:24:24 +0200 Subject: [PATCH 1/3] Message actions properly tested --- examples/native_sync/message_reactions.py | 219 ++++++++++++++++++ pubnub/enums.py | 1 + pubnub/managers.py | 24 ++ pubnub/models/consumer/message_actions.py | 19 +- tests/examples/native_sync/test_examples.py | 2 + .../asyncio/test_message_actions.py | 216 +++++++++++++++++ .../native_sync/test_message_actions.py | 214 +++++++++++++++++ 7 files changed, 694 insertions(+), 1 deletion(-) create mode 100644 examples/native_sync/message_reactions.py create mode 100644 tests/integrational/asyncio/test_message_actions.py create mode 100644 tests/integrational/native_sync/test_message_actions.py diff --git a/examples/native_sync/message_reactions.py b/examples/native_sync/message_reactions.py new file mode 100644 index 00000000..311acf96 --- /dev/null +++ b/examples/native_sync/message_reactions.py @@ -0,0 +1,219 @@ +import os +from typing import Dict, Any +from pubnub.models.consumer.message_actions import PNMessageAction +from pubnub.pnconfiguration import PNConfiguration +from pubnub.pubnub import PubNub + + +# snippet.init_pubnub +def initialize_pubnub( + publish_key: str, + subscribe_key: str, + user_id: str +) -> PubNub: + """ + Initialize a PubNub instance with the provided configuration. + + Args: + publish_key (str): PubNub publish key + subscribe_key (str): PubNub subscribe key + user_id (str): User identifier for PubNub + + Returns: + PubNub: Configured PubNub instance ready for publishing and subscribing + """ + pnconfig = PNConfiguration() + + # Configure keys with provided values + pnconfig.publish_key = publish_key + pnconfig.subscribe_key = subscribe_key + pnconfig.user_id = user_id + + return PubNub(pnconfig) +# snippet.end + + +# snippet.publish_message +def publish_message(pubnub: PubNub, channel: str, message: Any) -> Dict: + """ + Publish a message to a specific channel. + + Args: + pubnub (PubNub): PubNub instance + channel (str): Channel to publish to + message (Any): Message content to publish + + Returns: + Dict: Publish operation result containing timetoken + """ + envelope = pubnub.publish().channel(channel).message(message).sync() + return envelope.result +# snippet.end + + +# snippet.publish_reaction +def publish_reaction( + pubnub: PubNub, + channel: str, + message_timetoken: str, + reaction_type: str, + reaction_value: str, + user_id: str + +) -> Dict: + """ + Publish a reaction to a specific message. + + Args: + pubnub (PubNub): PubNub instance + channel (str): Channel where the original message was published + message_timetoken (str): Timetoken of the message to react to + reaction_type (str): Type of reaction (e.g. "smile", "thumbs_up") + + Returns: + Dict: Reaction publish operation result + """ + message_action = PNMessageAction().create( + type=reaction_type, + value=reaction_value, + message_timetoken=message_timetoken, + user_id=user_id + ) + envelope = pubnub.add_message_action().channel(channel).message_action(message_action).sync() + + return envelope.result +# snippet.end + + +# snippet.get_reactions +def get_reactions(pubnub: PubNub, channel: str, start_timetoken: str, end_timetoken: str, limit: str) -> Dict: + """ + Get reactions for a specific message. + + Args: + pubnub (PubNub): PubNub instance + channel (str): Channel where the original message was published + start_timetoken (str): Start timetoken of the message to get reactions for + end_timetoken (str): End timetoken of the message to get reactions for + limit (str): Limit the number of reactions to return + Returns: + Dict: Reactions for the message + """ + envelope = pubnub.get_message_actions() \ + .channel(channel) \ + .start(start_timetoken) \ + .end(end_timetoken) \ + .limit(limit) \ + .sync() + return envelope.result +# snippet.end + + +# snippet.remove_reaction +def remove_reaction(pubnub: PubNub, channel: str, message_timetoken: str, action_timetoken: str) -> Dict: + """ + Remove a reaction from a specific message. + + Args: + pubnub (PubNub): PubNub instance + channel (str): Channel where the original message was published + message_timetoken (str): Timetoken of the message to react to + action_timetoken (str): Timetoken of the reaction to remove + """ + envelope = pubnub.remove_message_action() \ + .channel(channel) \ + .message_timetoken(message_timetoken) \ + .action_timetoken(action_timetoken) \ + .sync() + return envelope.result +# snippet.end + + +def main() -> None: + """ + Main execution function. + """ + # Get configuration from environment variables or use defaults + publish_key = os.getenv('PUBLISH_KEY', 'demo') + subscribe_key = os.getenv('SUBSCRIBE_KEY', 'demo') + user_id = os.getenv('USER_ID', 'example-user') + + # snippet.usage_example + # Initialize PubNub instance with configuration + # If environment variables are not set, demo keys will be used + pubnub = initialize_pubnub( + publish_key=publish_key, + subscribe_key=subscribe_key, + user_id=user_id + ) + + # Channel where all the communication will happen + channel = "my_channel" + + # Message that will receive reactions + message = "Hello, PubNub!" + + # Step 1: Publish initial message + # The timetoken is needed to add reactions to this specific message + result = publish_message(pubnub, channel, message) + message_timetoken = result.timetoken + assert result.timetoken is not None, "Message publish failed - no timetoken returned" + assert isinstance(result.timetoken, (int, str)) and str(result.timetoken).isnumeric(), "Invalid timetoken format" + print(f"Published message with timetoken: {result.timetoken}") + + # Step 2: Add different types of reactions from different users + # First reaction: text-based reaction from guest_1 + reaction_type = "text" + reaction_value = "Hello" + first_reaction = publish_reaction(pubnub, channel, message_timetoken, reaction_type, reaction_value, "guest_1") + print(f"Added first reaction {first_reaction.__dict__}") + assert first_reaction is not None, "Reaction publish failed - no result returned" + assert isinstance(first_reaction, PNMessageAction), "Invalid reaction result type" + + # Second reaction: emoji-based reaction from guest_2 + reaction_type = "emoji" + reaction_value = "👋" + second_reaction = publish_reaction(pubnub, channel, message_timetoken, reaction_type, reaction_value, "guest_2") + print(f"Added second reaction {second_reaction.__dict__}") + assert second_reaction is not None, "Reaction publish failed - no result returned" + assert isinstance(second_reaction, PNMessageAction), "Invalid reaction result type" + + # Step 3: Fetch the message with its reactions from history + fetch_result = pubnub.fetch_messages()\ + .channels(channel)\ + .include_message_actions(True)\ + .count(1)\ + .sync() + + messages = fetch_result.result.channels[channel] + print(f"Fetched message with reactions: {messages[0].__dict__}") + assert len(messages) == 1, "Message not found in history" + assert hasattr(messages[0], 'actions'), "Message actions not included in response" + assert len(messages[0].actions) == 2, "Unexpected number of actions in history" + + # Step 4: Retrieve all reactions for the message + # We use a time window around the message timetoken to fetch reactions + # The window is 1000 time units before and after the message + start_timetoken = str(int(message_timetoken) - 1000) + end_timetoken = str(int(message_timetoken) + 1000) + reactions = get_reactions(pubnub, channel, start_timetoken, end_timetoken, "100") + print(f"Reactions found: {len(reactions.actions)}") + assert len(reactions.actions) == 2, "Unexpected number of reactions" + + # Step 5: Display and remove each reaction + for reaction in reactions.actions: + print(f" Reaction: {reaction.__dict__}") + # Remove the reaction and confirm removal + remove_reaction(pubnub, channel, reaction.message_timetoken, reaction.action_timetoken) + print(f"Removed reaction {reaction.__dict__}") + + # Step 6: Verify reactions were removed + # Fetch reactions again - should be empty now + reactions = get_reactions(pubnub, channel, start_timetoken, end_timetoken, "100") + print(f"Reactions found: {len(reactions.actions)}") + assert len(reactions.actions) == 0, "Unexpected number of reactions" + # snippet.end + + +if __name__ == '__main__': + main() diff --git a/pubnub/enums.py b/pubnub/enums.py index 1e1c8a43..98d07d6f 100644 --- a/pubnub/enums.py +++ b/pubnub/enums.py @@ -127,6 +127,7 @@ class PNOperationType(object): PNRemoveSpaceUsersOperation = 82 PNFetchUserMembershipsOperation = 85 PNFetchSpaceMembershipsOperation = 86 + # NOTE: remember to update PubNub.managers.TelemetryManager.endpoint_name_for_operation() when adding operations class PNHeartbeatNotificationOptions(object): diff --git a/pubnub/managers.py b/pubnub/managers.py index fc222869..48683793 100644 --- a/pubnub/managers.py +++ b/pubnub/managers.py @@ -470,6 +470,7 @@ def endpoint_name_for_operation(operation_type): endpoint = { PNOperationType.PNPublishOperation: 'pub', PNOperationType.PNFireOperation: 'pub', + PNOperationType.PNSendFileNotification: "pub", PNOperationType.PNHistoryOperation: 'hist', PNOperationType.PNHistoryDeleteOperation: 'hist', @@ -534,6 +535,29 @@ def endpoint_name_for_operation(operation_type): PNOperationType.PNDownloadFileAction: 'file', PNOperationType.PNSendFileAction: 'file', + + PNOperationType.PNFetchMessagesOperation: "hist", + + PNOperationType.PNCreateSpaceOperation: "obj", + PNOperationType.PNUpdateSpaceOperation: "obj", + PNOperationType.PNFetchSpaceOperation: "obj", + PNOperationType.PNFetchSpacesOperation: "obj", + PNOperationType.PNRemoveSpaceOperation: "obj", + + PNOperationType.PNCreateUserOperation: "obj", + PNOperationType.PNUpdateUserOperation: "obj", + PNOperationType.PNFetchUserOperation: "obj", + PNOperationType.PNFetchUsersOperation: "obj", + PNOperationType.PNRemoveUserOperation: "obj", + + PNOperationType.PNAddUserSpacesOperation: "obj", + PNOperationType.PNAddSpaceUsersOperation: "obj", + PNOperationType.PNUpdateUserSpacesOperation: "obj", + + PNOperationType.PNUpdateSpaceUsersOperation: "obj", + PNOperationType.PNFetchUserMembershipsOperation: "obj", + PNOperationType.PNFetchSpaceMembershipsOperation: "obj", + }[operation_type] return endpoint diff --git a/pubnub/models/consumer/message_actions.py b/pubnub/models/consumer/message_actions.py index a8ee2b12..930f79d0 100644 --- a/pubnub/models/consumer/message_actions.py +++ b/pubnub/models/consumer/message_actions.py @@ -1,4 +1,4 @@ -class PNMessageAction(object): +class PNMessageAction: def __init__(self, message_action=None): if message_action is not None: self.type = message_action['type'] @@ -13,6 +13,23 @@ def __init__(self, message_action=None): self.uuid = None self.action_timetoken = None + def create(self, *, type: str = None, value: str = None, message_timetoken: str = None, + user_id: str = None) -> 'PNMessageAction': + """ + Create a new message action convenience method. + + :param type: Type of the message action + :param value: Value of the message action + :param message_timetoken: Timetoken of the message + :param user_id: User ID of the message + """ + + self.type = type + self.value = value + self.message_timetoken = message_timetoken + self.uuid = user_id + return self + def __str__(self): return "Message action with tt: %s for uuid %s with value %s " % (self.action_timetoken, self.uuid, self.value) diff --git a/tests/examples/native_sync/test_examples.py b/tests/examples/native_sync/test_examples.py index d503a930..8a190f14 100644 --- a/tests/examples/native_sync/test_examples.py +++ b/tests/examples/native_sync/test_examples.py @@ -1,2 +1,4 @@ # flake8: noqa from examples.native_sync.file_handling import main as test_file_handling + +from examples.native_sync.message_reactions import main as test_message_reactions \ No newline at end of file diff --git a/tests/integrational/asyncio/test_message_actions.py b/tests/integrational/asyncio/test_message_actions.py new file mode 100644 index 00000000..e8201c3a --- /dev/null +++ b/tests/integrational/asyncio/test_message_actions.py @@ -0,0 +1,216 @@ +import unittest + +from pubnub.models.consumer.message_actions import PNMessageAction +from pubnub.pubnub_asyncio import PubNubAsyncio +from tests.helper import pnconf_env_copy + + +class TestMessageActions(unittest.IsolatedAsyncioTestCase): + pubnub: PubNubAsyncio = None + channel = "test_message_actions" + message_timetoken = None + + action_value_1 = "hello" + action_type_1 = "text" + action_timetoken_1 = None + + action_value_2 = "👋" + action_type_2 = "emoji" + action_timetoken_2 = None + + async def asyncSetUp(self): + self.pubnub = PubNubAsyncio(pnconf_env_copy()) + # Ensure message is published only once per class, not per test method instance + if TestMessageActions.message_timetoken is None: + message_content = "test message for actions" + result = await self.pubnub.publish().channel(TestMessageActions.channel).message(message_content).future() + self.assertFalse(result.status.is_error()) + self.assertIsNotNone(result.result.timetoken) + TestMessageActions.message_timetoken = result.result.timetoken + + self.message_timetoken = TestMessageActions.message_timetoken + self.assertIsNotNone(self.message_timetoken, "Message timetoken should be set in setUp") + + async def test_01_add_reactions(self): + # Add first reaction + add_result_1 = await self.pubnub.add_message_action() \ + .channel(self.channel) \ + .message_action(PNMessageAction().create( + type=self.action_type_1, + value=self.action_value_1, + message_timetoken=self.message_timetoken, + )) \ + .future() + self.assertFalse(add_result_1.status.is_error()) + self.assertIsNotNone(add_result_1.result) + self.assertEqual(add_result_1.result.type, self.action_type_1) + self.assertEqual(add_result_1.result.value, self.action_value_1) + self.assertIsNotNone(add_result_1.result.action_timetoken) + TestMessageActions.action_timetoken_1 = add_result_1.result.action_timetoken + + # Add second reaction + add_result_2 = await self.pubnub.add_message_action() \ + .channel(self.channel) \ + .message_action(PNMessageAction().create( + type=self.action_type_2, + value=self.action_value_2, + message_timetoken=self.message_timetoken, + )) \ + .future() + self.assertFalse(add_result_2.status.is_error()) + self.assertIsNotNone(add_result_2.result) + self.assertEqual(add_result_2.result.type, self.action_type_2) + self.assertEqual(add_result_2.result.value, self.action_value_2) + self.assertIsNotNone(add_result_2.result.action_timetoken) + TestMessageActions.action_timetoken_2 = add_result_2.result.action_timetoken + + async def test_02_get_added_reactions(self): + self.assertIsNotNone(TestMessageActions.action_timetoken_1, "Action timetoken 1 not set by previous test") + self.assertIsNotNone(TestMessageActions.action_timetoken_2, "Action timetoken 2 not set by previous test") + + # Get all reactions + get_reactions_result = await self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .future() + + self.assertFalse(get_reactions_result.status.is_error()) + self.assertIsNotNone(get_reactions_result.result) + self.assertEqual(len(get_reactions_result.result.actions), 2) + + # Verify reactions content (order might vary) + actions = get_reactions_result.result.actions + found_reaction_1 = False + found_reaction_2 = False + for action in actions: + if action.action_timetoken == TestMessageActions.action_timetoken_1: + self.assertEqual(action.type, self.action_type_1) + self.assertEqual(action.value, self.action_value_1) + self.assertEqual(action.uuid, self.pubnub.config.user_id) + found_reaction_1 = True + elif action.action_timetoken == TestMessageActions.action_timetoken_2: + self.assertEqual(action.type, self.action_type_2) + self.assertEqual(action.value, self.action_value_2) + self.assertEqual(action.uuid, self.pubnub.config.user_id) + found_reaction_2 = True + self.assertTrue(found_reaction_1, "Added reaction 1 not found in get_message_actions") + self.assertTrue(found_reaction_2, "Added reaction 2 not found in get_message_actions") + + # Get reactions with limit = 1 + get_reactions_limited_result = await self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .limit('1') \ + .future() + self.assertFalse(get_reactions_limited_result.status.is_error()) + self.assertIsNotNone(get_reactions_limited_result.result) + self.assertEqual(len(get_reactions_limited_result.result.actions), 1) + + async def test_03_get_message_history_with_reactions(self): + fetch_result = await self.pubnub.fetch_messages() \ + .channels(self.channel) \ + .include_message_actions(True) \ + .start(int(TestMessageActions.message_timetoken + 100)) \ + .end(int(TestMessageActions.message_timetoken - 100)) \ + .count(1) \ + .future() + self.assertIsNotNone(fetch_result.result) + self.assertIn(self.channel, fetch_result.result.channels) + messages_in_channel = fetch_result.result.channels[self.channel] + self.assertEqual(len(messages_in_channel), 1) + # Ensure reactions were added by previous tests + self.assertIsNotNone(TestMessageActions.action_timetoken_1, "Dependency: action_timetoken_1 not set") + self.assertIsNotNone(TestMessageActions.action_timetoken_2, "Dependency: action_timetoken_2 not set") + + message_with_actions = messages_in_channel[0] + self.assertEqual(int(message_with_actions.timetoken), TestMessageActions.message_timetoken) + self.assertTrue(hasattr(message_with_actions, 'actions')) + self.assertIsNotNone(message_with_actions.actions) + + total_actions_in_history = 0 + if message_with_actions.actions: + for reaction_type_key in message_with_actions.actions: + for reaction_value_key in message_with_actions.actions[reaction_type_key]: + action_list = message_with_actions.actions[reaction_type_key][reaction_value_key] + total_actions_in_history += len(action_list) + + self.assertEqual(total_actions_in_history, 2) + + actions_dict = message_with_actions.actions + self.assertIn(self.action_type_1, actions_dict) + self.assertIn(self.action_value_1, actions_dict[self.action_type_1]) + action1_list = actions_dict[self.action_type_1][self.action_value_1] + self.assertEqual(len(action1_list), 1) + self.assertEqual(action1_list[0]['uuid'], self.pubnub.config.user_id) + self.assertEqual(action1_list[0]['actionTimetoken'], TestMessageActions.action_timetoken_1) + + self.assertIn(self.action_type_2, actions_dict) + self.assertIn(self.action_value_2, actions_dict[self.action_type_2]) + action2_list = actions_dict[self.action_type_2][self.action_value_2] + self.assertEqual(len(action2_list), 1) + self.assertEqual(action2_list[0]['uuid'], self.pubnub.config.user_id) + self.assertEqual(action2_list[0]['actionTimetoken'], TestMessageActions.action_timetoken_2) + + async def test_04_remove_reactions(self): + # Ensure reactions were added by previous tests + self.assertIsNotNone(TestMessageActions.action_timetoken_1, "Dependency: action_timetoken_1 not set") + self.assertIsNotNone(TestMessageActions.action_timetoken_2, "Dependency: action_timetoken_2 not set") + + # Get all reactions to prepare for removal (specific ones added in this test class) + action_tt_to_remove_1 = TestMessageActions.action_timetoken_1 + action_tt_to_remove_2 = TestMessageActions.action_timetoken_2 + + # Remove first reaction + remove_result_1 = await self.pubnub.remove_message_action() \ + .channel(self.channel) \ + .message_timetoken(TestMessageActions.message_timetoken) \ + .action_timetoken(action_tt_to_remove_1) \ + .future() + self.assertFalse(remove_result_1.status.is_error()) + self.assertIsNotNone(remove_result_1.result) + self.assertEqual(remove_result_1.result, {}) + + # Remove second reaction + remove_result_2 = await self.pubnub.remove_message_action() \ + .channel(self.channel) \ + .message_timetoken(TestMessageActions.message_timetoken) \ + .action_timetoken(action_tt_to_remove_2) \ + .future() + self.assertFalse(remove_result_2.status.is_error()) + self.assertIsNotNone(remove_result_2.result) + self.assertEqual(remove_result_2.result, {}) + + # Verify these specific reactions were removed + get_reactions_after_removal_result = await self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .future() + + self.assertFalse(get_reactions_after_removal_result.status.is_error()) + self.assertIsNotNone(get_reactions_after_removal_result.result) + self.assertEqual(len(get_reactions_after_removal_result.result.actions), 0) + + async def test_05_remove_all_reactions(self): + envelope = await self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .limit("100") \ + .future() + + for action in envelope.result.actions: + remove_result = await self.pubnub.remove_message_action() \ + .channel(self.channel) \ + .message_timetoken(action.message_timetoken) \ + .action_timetoken(action.action_timetoken) \ + .future() + self.assertFalse(remove_result.status.is_error()) + self.assertIsNotNone(remove_result.result) + self.assertEqual(remove_result.result, {}) + + envelope = await self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .limit("100") \ + .future() + self.assertFalse(envelope.status.is_error()) + self.assertIsNotNone(envelope.result) + self.assertEqual(len(envelope.result.actions), 0) + + async def asyncTearDown(self): + if self.pubnub: + await self.pubnub.stop() \ No newline at end of file diff --git a/tests/integrational/native_sync/test_message_actions.py b/tests/integrational/native_sync/test_message_actions.py new file mode 100644 index 00000000..a0b5a5a8 --- /dev/null +++ b/tests/integrational/native_sync/test_message_actions.py @@ -0,0 +1,214 @@ +import unittest +from pubnub.models.consumer.message_actions import PNMessageAction +from pubnub.pubnub import PubNub +from tests.helper import pnconf_env_copy + + +class TestMessageActions(unittest.TestCase): + pubnub: PubNub = None + channel = "test_message_actions" + message_timetoken = None + + action_value_1 = "hello" + action_type_1 = "text" + action_timetoken_1 = None + + action_value_2 = "👋" + action_type_2 = "emoji" + action_timetoken_2 = None + + def setUp(self): + self.pubnub = PubNub(pnconf_env_copy()) + # Ensure message is published only once per class, not per test method instance + if TestMessageActions.message_timetoken is None: + message_content = "test message for actions" + result = self.pubnub.publish().channel(TestMessageActions.channel).message(message_content).sync() + self.assertFalse(result.status.is_error()) + self.assertIsNotNone(result.result.timetoken) + TestMessageActions.message_timetoken = result.result.timetoken + + self.message_timetoken = TestMessageActions.message_timetoken + self.assertIsNotNone(self.message_timetoken, "Message timetoken should be set in setUp") + + def test_01_add_reactions(self): + # Add first reaction + add_result_1 = self.pubnub.add_message_action() \ + .channel(self.channel) \ + .message_action(PNMessageAction().create( + type=self.action_type_1, + value=self.action_value_1, + message_timetoken=self.message_timetoken, + )) \ + .sync() + self.assertFalse(add_result_1.status.is_error()) + self.assertIsNotNone(add_result_1.result) + self.assertEqual(add_result_1.result.type, self.action_type_1) + self.assertEqual(add_result_1.result.value, self.action_value_1) + self.assertIsNotNone(add_result_1.result.action_timetoken) + TestMessageActions.action_timetoken_1 = add_result_1.result.action_timetoken + + # Add second reaction + add_result_2 = self.pubnub.add_message_action() \ + .channel(self.channel) \ + .message_action(PNMessageAction().create( + type=self.action_type_2, + value=self.action_value_2, + message_timetoken=self.message_timetoken, + )) \ + .sync() + self.assertFalse(add_result_2.status.is_error()) + self.assertIsNotNone(add_result_2.result) + self.assertEqual(add_result_2.result.type, self.action_type_2) + self.assertEqual(add_result_2.result.value, self.action_value_2) + self.assertIsNotNone(add_result_2.result.action_timetoken) + TestMessageActions.action_timetoken_2 = add_result_2.result.action_timetoken + + def test_02_get_added_reactions(self): + self.assertIsNotNone(TestMessageActions.action_timetoken_1, "Action timetoken 1 not set by previous test") + self.assertIsNotNone(TestMessageActions.action_timetoken_2, "Action timetoken 2 not set by previous test") + + # Get all reactions + get_reactions_result = self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .sync() + + self.assertFalse(get_reactions_result.status.is_error()) + self.assertIsNotNone(get_reactions_result.result) + self.assertEqual(len(get_reactions_result.result.actions), 2) + + # Verify reactions content (order might vary) + actions = get_reactions_result.result.actions + found_reaction_1 = False + found_reaction_2 = False + for action in actions: + if action.action_timetoken == TestMessageActions.action_timetoken_1: + self.assertEqual(action.type, self.action_type_1) + self.assertEqual(action.value, self.action_value_1) + self.assertEqual(action.uuid, self.pubnub.config.user_id) + found_reaction_1 = True + elif action.action_timetoken == TestMessageActions.action_timetoken_2: + self.assertEqual(action.type, self.action_type_2) + self.assertEqual(action.value, self.action_value_2) + self.assertEqual(action.uuid, self.pubnub.config.user_id) + found_reaction_2 = True + self.assertTrue(found_reaction_1, "Added reaction 1 not found in get_message_actions") + self.assertTrue(found_reaction_2, "Added reaction 2 not found in get_message_actions") + + # Get reactions with limit = 1 + get_reactions_limited_result = self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .limit('1') \ + .sync() + self.assertFalse(get_reactions_limited_result.status.is_error()) + self.assertIsNotNone(get_reactions_limited_result.result) + self.assertEqual(len(get_reactions_limited_result.result.actions), 1) + + def test_03_get_message_history_with_reactions(self): + # Ensure reactions were added by previous tests + self.assertIsNotNone(TestMessageActions.action_timetoken_1, "Dependency: action_timetoken_1 not set") + self.assertIsNotNone(TestMessageActions.action_timetoken_2, "Dependency: action_timetoken_2 not set") + + fetch_result = self.pubnub.fetch_messages() \ + .channels(self.channel) \ + .include_message_actions(True) \ + .start(int(TestMessageActions.message_timetoken + 100)) \ + .end(int(TestMessageActions.message_timetoken - 100)) \ + .count(1) \ + .sync() + + self.assertIsNotNone(fetch_result.result) + self.assertIn(self.channel, fetch_result.result.channels) + messages_in_channel = fetch_result.result.channels[self.channel] + self.assertEqual(len(messages_in_channel), 1) + + message_with_actions = messages_in_channel[0] + self.assertEqual(int(message_with_actions.timetoken), TestMessageActions.message_timetoken) + self.assertTrue(hasattr(message_with_actions, 'actions')) + self.assertIsNotNone(message_with_actions.actions) + + total_actions_in_history = 0 + if message_with_actions.actions: + for reaction_type_key in message_with_actions.actions: + for reaction_value_key in message_with_actions.actions[reaction_type_key]: + action_list = message_with_actions.actions[reaction_type_key][reaction_value_key] + total_actions_in_history += len(action_list) + + self.assertEqual(total_actions_in_history, 2) + + actions_dict = message_with_actions.actions + self.assertIn(self.action_type_1, actions_dict) + self.assertIn(self.action_value_1, actions_dict[self.action_type_1]) + action1_list = actions_dict[self.action_type_1][self.action_value_1] + self.assertEqual(len(action1_list), 1) + self.assertEqual(action1_list[0]['uuid'], self.pubnub.config.user_id) + self.assertEqual(action1_list[0]['actionTimetoken'], TestMessageActions.action_timetoken_1) + + self.assertIn(self.action_type_2, actions_dict) + self.assertIn(self.action_value_2, actions_dict[self.action_type_2]) + action2_list = actions_dict[self.action_type_2][self.action_value_2] + self.assertEqual(len(action2_list), 1) + self.assertEqual(action2_list[0]['uuid'], self.pubnub.config.user_id) + self.assertEqual(action2_list[0]['actionTimetoken'], TestMessageActions.action_timetoken_2) + + def test_04_remove_reactions(self): + # Ensure reactions were added by previous tests + self.assertIsNotNone(TestMessageActions.action_timetoken_1, "Dependency: action_timetoken_1 not set") + self.assertIsNotNone(TestMessageActions.action_timetoken_2, "Dependency: action_timetoken_2 not set") + + # Get all reactions to prepare for removal (specific ones added in this test class) + action_tt_to_remove_1 = TestMessageActions.action_timetoken_1 + action_tt_to_remove_2 = TestMessageActions.action_timetoken_2 + + # Remove first reaction + remove_result_1 = self.pubnub.remove_message_action() \ + .channel(self.channel) \ + .message_timetoken(TestMessageActions.message_timetoken) \ + .action_timetoken(action_tt_to_remove_1) \ + .sync() + self.assertFalse(remove_result_1.status.is_error()) + self.assertIsNotNone(remove_result_1.result) + self.assertEqual(remove_result_1.result, {}) + + # Remove second reaction + remove_result_2 = self.pubnub.remove_message_action() \ + .channel(self.channel) \ + .message_timetoken(TestMessageActions.message_timetoken) \ + .action_timetoken(action_tt_to_remove_2) \ + .sync() + self.assertFalse(remove_result_2.status.is_error()) + self.assertIsNotNone(remove_result_2.result) + self.assertEqual(remove_result_2.result, {}) + + # Verify these specific reactions were removed + get_reactions_after_removal_result = self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .sync() + + self.assertFalse(get_reactions_after_removal_result.status.is_error()) + self.assertIsNotNone(get_reactions_after_removal_result.result) + self.assertEqual(len(get_reactions_after_removal_result.result.actions), 0) + + def test_05_remove_all_reactions(self): + envelope = self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .limit("100") \ + .sync() + + for action in envelope.result.actions: + remove_result = self.pubnub.remove_message_action() \ + .channel(self.channel) \ + .message_timetoken(action.message_timetoken) \ + .action_timetoken(action.action_timetoken) \ + .sync() + self.assertFalse(remove_result.status.is_error()) + self.assertIsNotNone(remove_result.result) + self.assertEqual(remove_result.result, {}) + + envelope = self.pubnub.get_message_actions() \ + .channel(self.channel) \ + .limit("100") \ + .sync() + self.assertFalse(envelope.status.is_error()) + self.assertIsNotNone(envelope.result) + self.assertEqual(len(envelope.result.actions), 0) + From 8bcc93b3b2d54178d6b4c1acf4fa7a8ffa119c39 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Thu, 22 May 2025 10:30:19 +0200 Subject: [PATCH 2/3] Linter --- tests/integrational/asyncio/test_message_actions.py | 2 +- tests/integrational/native_sync/test_message_actions.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integrational/asyncio/test_message_actions.py b/tests/integrational/asyncio/test_message_actions.py index e8201c3a..b7f4856a 100644 --- a/tests/integrational/asyncio/test_message_actions.py +++ b/tests/integrational/asyncio/test_message_actions.py @@ -213,4 +213,4 @@ async def test_05_remove_all_reactions(self): async def asyncTearDown(self): if self.pubnub: - await self.pubnub.stop() \ No newline at end of file + await self.pubnub.stop() diff --git a/tests/integrational/native_sync/test_message_actions.py b/tests/integrational/native_sync/test_message_actions.py index a0b5a5a8..669cf566 100644 --- a/tests/integrational/native_sync/test_message_actions.py +++ b/tests/integrational/native_sync/test_message_actions.py @@ -211,4 +211,3 @@ def test_05_remove_all_reactions(self): self.assertFalse(envelope.status.is_error()) self.assertIsNotNone(envelope.result) self.assertEqual(len(envelope.result.actions), 0) - From 1a126b584ac15220f2a97d92e9eed5a6c40be9c8 Mon Sep 17 00:00:00 2001 From: Sebastian Molenda Date: Fri, 23 May 2025 13:44:02 +0200 Subject: [PATCH 3/3] Improved grant/revoke token tests with usage example --- examples/native_sync/using_tokens.py | 56 +++ .../pam/grant_token_authorization.json | 139 +++++ .../grant_token_channel_all_permissions.json | 72 +++ ..._token_channel_individual_permissions.json | 474 ++++++++++++++++++ .../pam/grant_token_exact_pattern.json | 72 +++ .../pam/grant_token_format_validation.json | 72 +++ .../pam/grant_token_groups_permissions.json | 72 +++ .../pam/grant_token_invalid_ttl.json | 72 +++ .../pam/grant_token_large_metadata.json | 72 +++ .../native_sync/pam/grant_token_max_ttl.json | 72 +++ .../native_sync/pam/grant_token_metadata.json | 72 +++ .../native_sync/pam/grant_token_min_ttl.json | 72 +++ .../pam/grant_token_mixed_patterns.json | 72 +++ .../pam/grant_token_mixed_resources.json | 72 +++ .../pam/grant_token_regex_patterns.json | 72 +++ .../pam/grant_token_reserved_metadata.json | 72 +++ .../pam/grant_token_spaces_permissions.json | 72 +++ .../pam/grant_token_substring_pattern.json | 72 +++ .../pam/grant_token_users_permissions.json | 72 +++ .../pam/grant_token_wildcard_pattern.json | 72 +++ .../native_sync/pam/revoke_expired_token.json | 131 +++++ .../native_sync/pam/revoke_token.json | 131 +++++ .../native_sync/pam/revoke_token.yaml | 84 ---- .../pam/revoke_token_verify_operations.json | 258 ++++++++++ .../native_sync/test_grant_token.py | 421 ++++++++++++++++ .../native_sync/test_revoke_v3.py | 91 +++- 26 files changed, 2916 insertions(+), 93 deletions(-) create mode 100644 examples/native_sync/using_tokens.py create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_authorization.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_channel_all_permissions.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_channel_individual_permissions.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_exact_pattern.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_format_validation.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_groups_permissions.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_invalid_ttl.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_large_metadata.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_max_ttl.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_metadata.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_min_ttl.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_mixed_patterns.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_mixed_resources.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_regex_patterns.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_reserved_metadata.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_spaces_permissions.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_substring_pattern.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_users_permissions.json create mode 100644 tests/integrational/fixtures/native_sync/pam/grant_token_wildcard_pattern.json create mode 100644 tests/integrational/fixtures/native_sync/pam/revoke_expired_token.json create mode 100644 tests/integrational/fixtures/native_sync/pam/revoke_token.json delete mode 100644 tests/integrational/fixtures/native_sync/pam/revoke_token.yaml create mode 100644 tests/integrational/fixtures/native_sync/pam/revoke_token_verify_operations.json diff --git a/examples/native_sync/using_tokens.py b/examples/native_sync/using_tokens.py new file mode 100644 index 00000000..e74bf885 --- /dev/null +++ b/examples/native_sync/using_tokens.py @@ -0,0 +1,56 @@ +import os +import time +from pubnub.exceptions import PubNubException +from pubnub.models.consumer.v3.channel import Channel +from pubnub.pubnub import PubNub +from pubnub.pnconfiguration import PNConfiguration + +# We are using keyset with Access Manager enabled. +# Admin has superpowers and can grant tokens, access to all channels, etc. Notice admin has secret key. +admin_config = PNConfiguration() +admin_config.publish_key = os.environ.get('PUBLISH_PAM_KEY', 'demo') +admin_config.subscribe_key = os.environ.get('SUBSCRIBE_PAM_KEY', 'demo') +admin_config.secret_key = os.environ.get('SECRET_PAM_KEY', 'demo') +admin_config.uuid = "example_admin" + +# User also has the same keyset as admin. +# User has limited access to the channels they are granted access to. Notice user has no secret key. +user_config = PNConfiguration() +user_config.publish_key = os.environ.get('PUBLISH_PAM_KEY', 'demo') +user_config.subscribe_key = os.environ.get('SUBSCRIBE_PAM_KEY', 'demo') +user_config.uuid = "example_user" + +admin = PubNub(admin_config) +user = PubNub(user_config) + +try: + user.publish().channel("test_channel").message("test message").sync() +except PubNubException as e: + print(f"User cannot publish to test_channel as expected.\nError: {e}") + +# admin can grant tokens to users +grant_envelope = admin.grant_token() \ + .channels([Channel.id("test_channel").read().write().manage().update().join().delete()]) \ + .authorized_uuid("example_user") \ + .ttl(1) \ + .sync() +assert grant_envelope.status.status_code == 200 + +token = grant_envelope.result.get_token() +assert token is not None + +user.set_token(token) +user.publish().channel("test_channel").message("test message").sync() + +# admin can revoke tokens +revoke_envelope = admin.revoke_token(token).sync() +assert revoke_envelope.status.status_code == 200 + +# We have to wait for the token revoke to propagate. +time.sleep(10) + +# user cannot publish to test_channel after token is revoked +try: + user.publish().channel("test_channel").message("test message").sync() +except PubNubException as e: + print(f"User cannot publish to test_channel any more.\nError: {e}") diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_authorization.json b/tests/integrational/fixtures/native_sync/pam/grant_token_authorization.json new file mode 100644 index 00000000..dd507a48 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_authorization.json @@ -0,0 +1,139 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVEwEAAAAAAABYDAEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdC1jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0LWNoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge30sICJ1dWlkIjogInNwZWNpZmljLXV1aWQifX2ULg==" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "268" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVHwEAAAAAAAB9lIwGc3RyaW5nlEIMAQAAH4sIAAAAAAAA/22Qy2rDMBREf6VonYJjkzY1ZBE/W+wK4qaWo50qGbt+yYmk+BHy71UK7Sqry9wZZuBcACOSAPsC2lwIUuTABh+KUi3AAkhe553+HP3A3NaBEbbF+c13PPaaiNAbPdqmc/+ZVCQMFEejgTNoxAjyA1opjAZnZ7KJRo5HLae661vpTI+Oz7K0x7dcGBj/fT7saOcWOwsOhye9mcGJ+8mSoabWV+IsKf/0VwYHjGCP26aKs3RJUOJRs+mQ6z4zpbiqQokLEnMYzWvxEq735ZSMbT+KqIzh8jGl/X5VbDbgugAiP52/6Y3D9hfDwzvpNJeTxiEkkUoA2zSM6w9Whp2yOQEAAJRzLg==" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVEwEAAAAAAABYDAEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdC1jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0LWNoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge30sICJ1dWlkIjogInNwZWNpZmljLXVzZXIifX2ULg==" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "268" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVIQEAAAAAAAB9lIwGc3RyaW5nlEIOAQAAH4sIAAAAAAAA/22Qy26DMBREf6XyOgsCbdogZcG7j9QVpGDjTeTalJY3GAIhyr/XqdSusrqaO6MZ6ZwApz0F+gmUiRA0TYAOdgNjUoAF6Os8qeSndVzVyF3FK9PDk2Pa/DEQnj3ZrIzmJgwy6rlDjSaFYKhsEaxjdDcQNJq+yo/sxbSZZmZXfS2aWWs6HEcNueQ8V/nvc2DFKiv1NTjGK7mJ4bF2giVHRS5vT3Dw9ac/MBwJgg0pi2yLo5ngZ5upRYUsa43I/mG9Ht7ad5ejlZbcorCNQrv9XKpW3rn7cDflsXEfCX+zAecFEEl3+GYXDsYvhptXWkkuncQhetoPAuiqopx/AIt9OFY5AQAAlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_channel_all_permissions.json b/tests/integrational/fixtures/native_sync/pam/grant_token_channel_all_permissions.json new file mode 100644 index 00000000..33d96e08 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_channel_all_permissions.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVFAEAAAAAAABYDQEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiYWxsX3Blcm1pc3Npb25zX2NoYW5uZWwiOiAyMzl9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHsiYWxsX3Blcm1pc3Npb25zX2NoYW5uZWwiOiAyMzl9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgIm1ldGEiOiB7fX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "269" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:28 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVGAEAAAAAAAB9lIwGc3RyaW5nlEIFAQAAH4sIAAAAAAAA/42QuW6DQBiEXyXa2gUBxUh0XgPrxArEJOFqoj24b3bBBsvvnnWK1K5+/aMZzei7AoYFBsYVNAnnOEuAAT4nSuUDNkB0VdJKpVdsdVfZCmqy+aBDkx08jsyLSRt/7b+9EiN76kKWE3RJKfIXEtQrVeuZtE4aqXlOmpeawHI+qWyhR2hSDZYP+TV/pQO0WOj38T2HbOW/z3Ja2u6zk+aco63cFDpLZ3nPLKgreUUcern0rDhg0evb3uU/7hfMzCH1hdiGShfX5MPNtPOiF+m4cHrUh2hbrA64bQBPxrmgdxa7PxRP77iVbEaJhAssJg4MVVFuv/qZl3E9AQAAlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_channel_individual_permissions.json b/tests/integrational/fixtures/native_sync/pam/grant_token_channel_individual_permissions.json new file mode 100644 index 00000000..d75d3d57 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_channel_individual_permissions.json @@ -0,0 +1,474 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV9wAAAAAAAACM83sidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiY2hhbm5lbF9yZWFkIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJjaGFubmVsX3JlYWQiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "243" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVBwEAAAAAAAB9lIwGc3RyaW5nlEP3H4sIAAAAAAAA/22PTW+CMACG/8rSsyQVopvcRAo4lQw22+KttoRN5GO0IGL871YPnjy9eT/yJs8FCKYYsC+gSKVkWQps8N1yrg0YAVXlaamTGnrmPPegX2RdMJ25Ioil7/YuL/BQb+MD8722Iv1D9wWW1Po8JiRyIlOc+cpxueUcXvYWHvi/gwTF9e6+8z34/ENhyctFFlnhKZk6rqDhuULxWJBjrlXtaPyrNwMjIll6448OzrARDJlhEWPRBNsQBe8rOunWZLnf9KcGrVk/+UFf4DoCMm26P35nnT9Q3zas1OyNRpaKqVYC24TwegPHw8t3HQEAAJRzLg==" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV+QAAAAAAAACM9XsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiY2hhbm5lbF93cml0ZSI6IDJ9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHsiY2hhbm5lbF93cml0ZSI6IDJ9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgIm1ldGEiOiB7fX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "245" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVHQEAAAAAAAB9lIwGc3RyaW5nlEIKAQAAH4sIAAAAAAAA/x2PW2+CMACF/8rSZ024ZCya7AGHlMzIQlEuvpDSsjJogdmCY8b/bvXp5Fxyku8KKFYYrK9AVFJiVoE1iEdCtAELoPq26nQyGL7ltr4BBZsCZ+XRAEno/XlEJP/DETUY+mOfmk8tRSIzm844Q9xtw450Hyyyw0vu+Cq36roUr7z0VzYR3DhFnx7NwrnfIpOmvO23epfFHMGwz1OHRRadyW7jEXvT6M4k9o6hIDFxGjMETU4hfHwPJ5OxeF9c3MmpcfFtfdHfZElRBUtBQ6Ly5aFogmY62G/G0Uujd3BbAFmdpx/y4HWfuC973Gn+s8aWCqtRgrVlGLc71Vi6NSEBAACUcy4=" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV+wAAAAAAAACM93sidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiY2hhbm5lbF9tYW5hZ2UiOiA0fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7ImNoYW5uZWxfbWFuYWdlIjogNH19LCAicGF0dGVybnMiOiB7ImNoYW5uZWxzIjoge30sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjoge319LCAibWV0YSI6IHt9fX2ULg==" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "247" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVHAEAAAAAAAB9lIwGc3RyaW5nlEIJAQAAH4sIAAAAAAAA/02QO2+DMACE/0rlOQOPJFKRMuCaR4sCBRQ7sBnzasFAMCSIKP+9bqZMp7vTDd/dQU4nCow74IUQtCqAAeKZMWnABkx9U3QyGRRbMxtbcXh1dffvKHcj4aAFMY7X4RT9Useee7J7asaxOGtqnXG7S8MIpfrXrbf8lTmBzPw+Ibs5JUuZEXtOSN5Cy1eZ7lWRi1VK4irUYZ172Eq0us4u8HUvO7yyC7TyMx5SD1oZwUpCIWJa25EP9K15N0SP7dJu+Tj4PqyV0baC0tuHnzg4lZlqVtsmiHszPBzAYwNEMV5/2D+z+UR+O9JOfjBKdDHRaRbA0BTl8QfVfCuoJQEAAJRzLg==" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV+wAAAAAAAACM93sidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiY2hhbm5lbF9kZWxldGUiOiA4fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7ImNoYW5uZWxfZGVsZXRlIjogOH19LCAicGF0dGVybnMiOiB7ImNoYW5uZWxzIjoge30sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjoge319LCAibWV0YSI6IHt9fX2ULg==" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "247" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVHQEAAAAAAAB9lIwGc3RyaW5nlEIKAQAAH4sIAAAAAAAA/02QO2+DMACE/0rlOQNxSKUgZcA8TEtDFCJs8GYMgYZnMI+UKP+9NFOn093phu8eIOE9B9oDVKmUPEuBBs6DEIsBK9A3RVovSavYUC9sBVfZ6LzvzMTxJTbvpqjI3Ab+lWN7aOj2pXFFZAj9MsZEYafcZJvPqbG8WeBjHldeE9HtwOj9wjCRLPRLw/LWYuNmvkPWnJ6z0wbliUusCOZ5fEP/90tHZnFDVhKSlrnIiilRIo5MAcuaGvolKGfoeVe3QR9FNuFj9JWpyQSZEakC0cOPOtBx5/RBN+334LkCMu3Gb/HHrL+Q3w68Xj7oFnTZ836QQIOK8vwFt/2qLCUBAACUcy4=" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV9wAAAAAAAACM83sidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiY2hhbm5lbF9nZXQiOiAzMn0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJjaGFubmVsX2dldCI6IDMyfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "243" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVBgEAAAAAAAB9lIwGc3RyaW5nlEP2H4sIAAAAAAAA/22PXW+CMBiF/8rSa5cw3FzGHVBAs9jNLhb0xtS2YRP6MVrcxPjfrV545dXJ+54nJ3mOgFNHQXQEUlhLawEi8NUz5g8wAk43QvmPCfIwbvKgkPV+OnmDfIptAf8hk2QwS7yjRd7r0l1zK4mtQt7ypK4XIT+w9wSycbK724/JwH6TjFfErC9ckQe3vQwpplLPoL/VJIG8Qged4Sdeto1Pt67wt2cGWvLVLE5Fq01TvjC06T5fF5vlI7IM96n8mD+rLXJwphUVhBgBTiNgRbf/YRfX+Kr6MKfKu3de2TrqeguiMAhOZ7kFTwAdAQAAlHMu" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV/QAAAAAAAACM+XsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiY2hhbm5lbF91cGRhdGUiOiA2NH0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJjaGFubmVsX3VwZGF0ZSI6IDY0fX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "249" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVCgEAAAAAAAB9lIwGc3RyaW5nlEP6H4sIAAAAAAAA/3WQT2+CMBjGv8rSswcGjGXcQCguKIkwy59bbRkoa+loUcH43Vc97Obpyfvklzf5PVdAscLAvQJWS4mbGrggGwnRB1gA1Xc1140woOl10IhYc1o5HwFdpTIKLgFhaBa79IgjOPb52yP3DMnCQucqgkaVtt7WpBOJ/YBY/vEpY6GZ/PohLZCo7qzu//+GCSd82Wyt5Fw6fkCLZOrD9JXmP51OVRVpq5kZ57T8jGNoZ/TC26T8ksKMNzBjaPfODlTY+bTG+2n9HS+doec2uC2ArIfTgdydvYfyywZzvcGg1aXCapTANQ3j9gdDmrOVJQEAAJRzLg==" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV+wAAAAAAAACM93sidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsiY2hhbm5lbF9qb2luIjogMTI4fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7ImNoYW5uZWxfam9pbiI6IDEyOH19LCAicGF0dGVybnMiOiB7ImNoYW5uZWxzIjoge30sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjoge319LCAibWV0YSI6IHt9fX2ULg==" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "247" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:27 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVHgEAAAAAAAB9lIwGc3RyaW5nlEILAQAAH4sIAAAAAAAA/x2PW2+CMACF/8rSZx+gbmSS7AEEinGgwMZlL6a0rI47FBBm/O9Wn07OJSf5roDiAQP1CqqMc8wyoIJgJEQYsAJDU2S1SFrJglphSahik61sDGr7HBmzQarwv/32c4yssYnmp6ZVyGPYTjh6TZjp1qTeMm/tXhLF4gk8n9PqrUytTZfCckQ73aCxuzSmL9OoLBpT7OKg9JHbJJHCPEgXstcNstZz0clkvWe+Hco4CpiP5JIi9Phuf2TGnFDDDtu9e/CTzNguLooSnujha0nT7tc5WEufn5zuqG2PyQe4rQDP+umPPHi1J+6Lg2vB3wtsPuBh5ECFknS7A8jvN5IhAQAAlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_exact_pattern.json b/tests/integrational/fixtures/native_sync/pam/grant_token_exact_pattern.json new file mode 100644 index 00000000..92e097c4 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_exact_pattern.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVLAEAAAAAAABYJQEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHsiXmV4YWN0LWNoYW5uZWwkIjogMywgIl5wcmVmaXgtWzAtOV0rJCI6IDF9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHsiXmV4YWN0LWNoYW5uZWwkIjogMywgIl5wcmVmaXgtWzAtOV0rJCI6IDF9fSwgIm1ldGEiOiB7fX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "293" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:51 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVQQEAAAAAAAB9lIwGc3RyaW5nlEIuAQAAH4sIAAAAAAAA/02Qy46CMABFf2XS9UwCKERNXPB2fJAISgu70nYUaQEtj0Hjvw+6muW9N/cszgNQ3GCweADBpMQnBhYgagkZA/gETVWwcmxqxdPMwlN8ceq+nblDV6H0nV+HiPheH8ML9r22coOSlPZpPwn6xLAcioKhckOVQl6MW5+giId+UCXQyDNV58z3LtRW399MxHJtBh0qrSGFac1sNdvZio4iWZjH/9x1h0Q8TWCgbOGLpbcp7AtTmzOyWvNU8Ok2lv32wOlm2Fv7SXwnV8ulKK7TjeVmMFYSbDlE4yW0nePtvGouV62zRC6brpjNuRH5hk7tmXaGYkDwp9cOA8y/zOUSPD+BZLcuJy9H5lvRxw6Xo7PbqEo2uGklWGiK8vwDWVMLTVUBAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_format_validation.json b/tests/integrational/fixtures/native_sync/pam/grant_token_format_validation.json new file mode 100644 index 00000000..f0dd3391 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_format_validation.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV9wAAAAAAAACM83sidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdF9jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0X2NoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "243" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:55:58 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVBgEAAAAAAAB9lIwGc3RyaW5nlEP2H4sIAAAAAAAA/22PTW+CMACG/8rSs4cOosm40RWKLpLAJl+3riUIjFJtK4Lxv6/usJOnN+9H3uS5AU41Bd4NDLVStKmBBz4NY9aAFdBjXwubSBg6fh9CMjSXSK8xj1JF8BWzIVvkIe0oCc2YX2FVxLBw4rHM16bKJ5Q4fGYfCDMXdU97N1vYCQW8yGT12JEQ/v8FsWDivUnceCo3CPMinscgfeX5T29VV0V6tJuF5rzcYoJPm0W0yJXf3G9nspskDmm/dQ7p0H297SQvj2bvJlEH7iug6vOlZQ9W/w/1ZU+FZT9bZKWpNgp4DoT3X/vgQAsdAQAAlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_groups_permissions.json b/tests/integrational/fixtures/native_sync/pam/grant_token_groups_permissions.json new file mode 100644 index 00000000..a4551c5a --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_groups_permissions.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV7QAAAAAAAACM6XsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjogeyJncm91cDEiOiAxLCAiZ3JvdXAyIjogNX0sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgIm1ldGEiOiB7fX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "233" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:00:14 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVBAEAAAAAAAB9lIwGc3RyaW5nlEP0H4sIAAAAAAAA/12PzVKDMACEX8XJuQdaSp1yA4GgFZwGCTS3mCACBpDw3+m7Gz32tLM73x6+K+C0p8C8ApFJSfMMmCAaGFMFbEDfVFmtllbzdlblaVDko380HO4jCZ3ZYQKvbYxKCr2hccOa1U8FEXz50PEU5FgQ/WXkqTVbcbgy+JafdbyyH9vlKW7JyXYY9LS7v2LC6XKwHZ6GS+OiLU++K5U9SdGXYlaa8Mvza7B3chrvveUQRW1iFMfHWZxJ6aOo7D5TZOH2/bSdDAJDcNsAmXVjwf7crH+1h4DWyrVTirKn/SCBudO02y/vc1QrDQEAAJRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_invalid_ttl.json b/tests/integrational/fixtures/native_sync/pam/grant_token_invalid_ttl.json new file mode 100644 index 00000000..7796502d --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_invalid_ttl.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV+gAAAAAAAACM9nsidHRsIjogNDMyMDEsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdF9jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0X2NoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "246" + ] + } + }, + "response": { + "status": { + "code": 400, + "message": "Bad Request" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:55:58 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVtwAAAAAAAAB9lIwGc3RyaW5nlEOnH4sIAAAAAAAA/02OPQvCMBCG/8pxk4JI/Ji6OTq4iJs4XJOjBtJEkkuhlP53r4rg+sDzPu+EnHPK2EzYcynUMTZ4jgMF70Ak4AZLqtkuuMsURYFjIR8KNvd/6UqxYyjPVIODlmEHkuB42BsDvY9VeFXWW7VDsiQ+RVW++z9wG1/LTpvciPNj1jDnwX/KJ2u1AxeK2srLJyGp+uBozPwGiusKf8MAAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_large_metadata.json b/tests/integrational/fixtures/native_sync/pam/grant_token_large_metadata.json new file mode 100644 index 00000000..442b1978 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_large_metadata.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVdgIAAAAAAABYbwIAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdC1jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0LWNoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjogeyJhcHBfZGF0YSI6IHsidmVyc2lvbiI6ICIxLjAuMCIsICJlbnZpcm9ubWVudCI6ICJwcm9kdWN0aW9uIiwgImZlYXR1cmVzIjogWyJjaGF0IiwgInByZXNlbmNlIiwgInB1c2giLCAic3RvcmFnZSJdLCAiY29uZmlnIjogeyJ0aW1lb3V0IjogNTAwMCwgInJldHJpZXMiOiAzLCAiY2FjaGVfc2l6ZSI6IDEwMDAsICJkZWJ1ZyI6IGZhbHNlfX0sICJ1c2VyX2RhdGEiOiB7ImlkIjogIjEyMzQ1IiwgInJvbGVzIjogWyJhZG1pbiIsICJtb2RlcmF0b3IiLCAidXNlciJdLCAicGVybWlzc2lvbnMiOiBbInJlYWQiLCAid3JpdGUiLCAiZGVsZXRlIl0sICJzZXR0aW5ncyI6IHsibm90aWZpY2F0aW9ucyI6IHRydWUsICJ0aGVtZSI6ICJkYXJrIiwgImxhbmd1YWdlIjogImVuIn19fX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "623" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVAQIAAAAAAAB9lIwGc3RyaW5nlELuAQAAH4sIAAAAAAAA/21Sy27bMBD8lULnBNAjMmADPUSxRNWNlZqxRWkvBR+uZIuUGOtlKci/lw7QnnLikrs7O5ydd0vQjlqrd0sd25YWR2tlvfacm4t1Z3VNdazNi7Yj97GKbKSK4UcYrEWMW7S+rrlKZ33AZ4qiviFXG7LEfiZJkxO/BzIGO1dM/Gew5l5w/jLvpTN/C0KRpRpudSiy/+OFSc3rp2LnJWO+MDOzZGpC7AgiK3N2kOGyUdLhbjplLi4FQlWuZAX7cNrOO4d6geTK0dxLNHP9uXDxBCSqIBMTzbAEhSVDqQ0knZh7lfwhkTnBHSW+ZmRp6jYGczlBnM4mbswcWyDZg/di+F1LpoSTEyFzlfaM+IPJKUoS0yMHVv9yDL8GiCMB4ZKrrsmzYPzHE1QyMAUaFvgtdyODl/7hrlwArtYLlFZANg78xrXR1+ZKSj4mtcHtgCwdEVT7E+okq0FztTSz014gPZq4EiSxKVn2FIHMM+zc9lOiTz1tGgeT0V8ylUiIA6NbWXMPD1xFNRDhmj/Ot16jX799ehiN7hqconh5pfScRfcdw5fCP7Th5hIjfNjfMzJqffL312cXx03goPG79XFntcfLcOI3Hz1+2ujbltbGVxdjp7ajXd9aK9e2P/4Crb3ijXkCAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_max_ttl.json b/tests/integrational/fixtures/native_sync/pam/grant_token_max_ttl.json new file mode 100644 index 00000000..3d616637 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_max_ttl.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV+gAAAAAAAACM9nsidHRsIjogNDMyMDAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdF9jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0X2NoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "246" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:55:58 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVDgEAAAAAAAB9lIwGc3RyaW5nlEP+H4sIAAAAAAAA/22PT2+CMADFv8rSswcENRmJByq0DUyMuhXhVlqECRSk/Mkwfvd1S3bb8b3fy0t+DyBYz4D9AHWmFMszYIPzwLkOYAH6psykbloDmU6JDFznI+nXriAnhdnNOVp+xTfUi82iSO9ICUxngV5vDKMhralyPkLJ5S4/WuEUb/7lS24F+YnQJYvOegcLEfz9QTex/Knxwpnjg2Z05nfoiQttkwB6aUSNmEGXm5WMds6qqVfJOsVmPL0R5lnXmdSHL1kRwjpUwksSmdd2P/vvo7PdgucCqKwbP/mPr/Or+7JnUvt3Wlv1rB8UsE3DeH4DiSSpaSEBAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_metadata.json b/tests/integrational/fixtures/native_sync/pam/grant_token_metadata.json new file mode 100644 index 00000000..e0d8ce38 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_metadata.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVOwEAAAAAAABYNAEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdC1jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0LWNoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjogeyJhcHBfaWQiOiAibXktYXBwIiwgInVzZXJfdHlwZSI6ICJhZG1pbiIsICJjdXN0b21fZmllbGQiOiAidmFsdWUifX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "308" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVQAEAAAAAAAB9lIwGc3RyaW5nlEItAQAAH4sIAAAAAAAA/22QzW7CMBCEX6XymYOTFCSQOGDyQwVNFdPajm/GSaHkxyl2EhLEu9f00FNPq90dzYy+G8iEEWBxA1WutTjmYAH2rZR2ARNgVJHX9tLA0F0VIYyqY/cSID/bYB35V19WZGw+8FlEYavoFXIWwx2NVUqnLac9StxskFvkSw+d//17ZJTfKMgYafhDF4Xwzy+Ia1mvj4kX9+nMZrJ4UAF2MloWdhrO8Em5/CQ36FNQXB1YYVKG+kMUO9LD3YHMK0GJ5hFxU3p1OC0d6ZKBeXgqI1KmFBtBp750y5qufb/qVrajGmdt+oagEvPLuxm7vs8Ss9+VuniuBybVtmHJcgnuE6DzS/clH7xWv7ieXkVt+V0sNm2EaTVYuBDefwB96fVUYQEAAJRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_min_ttl.json b/tests/integrational/fixtures/native_sync/pam/grant_token_min_ttl.json new file mode 100644 index 00000000..a68246ed --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_min_ttl.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV9gAAAAAAAACM8nsidHRsIjogMSwgInBlcm1pc3Npb25zIjogeyJyZXNvdXJjZXMiOiB7ImNoYW5uZWxzIjogeyJ0ZXN0X2NoYW5uZWwiOiAxfSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7InRlc3RfY2hhbm5lbCI6IDF9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgIm1ldGEiOiB7fX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "242" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:55:58 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVCgEAAAAAAAB9lIwGc3RyaW5nlEP6H4sIAAAAAAAA/22PyU7DMABEfwX53EpZlCJF4pAojQMlruoAWW7ecCArtZuQVv13DBK3HmfeaKR3AZxoAvwL6IRSRArgg+zEmAlgBfTQiN40oxU7QRNbsJNTor2IJ1gFr2ipin2LIRrKfFPTBLfMxe+lU9e081oaxFHlPs3DFp0Z3N/kvEDLsMU2z9vG7OayyP7/5MHhC9uFEXPDT8Ns5u4kTt5skmcSQ7vlEMqDi8bKltLLaPRCRzp080Z7X6IOnvH6LPo0qcLsHk02Wj9+i7QeLfUAriugxHH6YL+uwZ/qXUp64340ykoTfVLAdyzr+gPW3ttLHQEAAJRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_mixed_patterns.json b/tests/integrational/fixtures/native_sync/pam/grant_token_mixed_patterns.json new file mode 100644 index 00000000..5b0ddccd --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_mixed_patterns.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVPQEAAAAAAABYNgEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsic3BlY2lmaWMtY2hhbm5lbCI6IDN9LCAiZ3JvdXBzIjogeyJzcGVjaWZpYy1ncm91cCI6IDR9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7InNwZWNpZmljLWNoYW5uZWwiOiAzfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7ImNoYW5uZWxfKiI6IDF9LCAiZ3JvdXBzIjogeyJncm91cF8qIjogMX0sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHsiY2hhbm5lbF8qIjogMX19LCAibWV0YSI6IHt9fX2ULg==" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "310" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVNAEAAAAAAAB9lIwGc3RyaW5nlEIhAQAAH4sIAAAAAAAA/2WQTW+CMBjHv8rSsyYdjYeZeLAW6qaywWKL3EphMoTCLJQX43cf82C27Pj8n/9L8ruAWNQCzC+gSLQWxwTMwXsj5XiACajLU6JGpYKOtTw5kBZH82xjEq99TUlHZMGGau9ngjpNGeBBUpYJHlaH/vGmRQXTS+gqqVZppNw25G4VFnm25XEfIdZi2x0zr6lc//655YHPmpC3xENskF/YjgNWhRtMJHXgfY/n942gL7Fnxb3cOCpELyYO8Mfm6BCJcPbP97fTjjiDBzF2W7niK7JtTJruIxNg1Jm3mT9FNIi6hMt+uibZzhNPtPBRaRLXWyzAdQJ0cjaf8ofb8obtYSfUyPE84tO1qBsN5haE12+i4EAraQEAAJRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_mixed_resources.json b/tests/integrational/fixtures/native_sync/pam/grant_token_mixed_resources.json new file mode 100644 index 00000000..f66ee227 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_mixed_resources.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVJAEAAAAAAABYHQEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsic3BhY2UxIjogM30sICJncm91cHMiOiB7Imdyb3VwMSI6IDV9LCAidXVpZHMiOiB7InVzZXIxIjogOTZ9LCAidXNlcnMiOiB7InVzZXIxIjogOTZ9LCAic3BhY2VzIjogeyJzcGFjZTEiOiAzfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge30sICJ1dWlkIjogInRlc3RfdXNlciJ9fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "285" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:28 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLQEAAAAAAAB9lIwGc3RyaW5nlEIaAQAAH4sIAAAAAAAA/z2Qy1KDMBSGX8XJugsug47dlYZL7ZCWVAjNxokJF8tNCSDQ6bsbdXR15j/n/N/iuwLBegbWV1CnUrI8BWtwGjhXAaxA35ZpozYfjmtsSlfz6nz0H2wofCw9OEFex8t7hC/Mc4eW0IV77oU+OzA0xMz3bk3Np1Ekm8mOkLodCtqgzzNBVRAiKBI0tyTWuRHPAS5y7Mc6I6eCJvFCk93keTZUPO2f76CGN9s8NBXj3v7tO1gXpCrV7GmCi7/MElxxE2fqp+IlWhgR552rW5a2763tIqVFZNFFB4NlWWzCo1m8PC5HDunUvFrVaILbCsi0G9/4t4/Nj467gDXKT6e0yJ71gwRrQ9NuX0NYvrJBAQAAlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_regex_patterns.json b/tests/integrational/fixtures/native_sync/pam/grant_token_regex_patterns.json new file mode 100644 index 00000000..5588fde8 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_regex_patterns.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVKgEAAAAAAABYIwEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHsiXnNwYWNlLVthLXpBLVpdKyQiOiAzfSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7Il51c2VyLVswLTldKyQiOiAzMn0sICJ1c2VycyI6IHsiXnVzZXItWzAtOV0rJCI6IDMyfSwgInNwYWNlcyI6IHsiXnNwYWNlLVthLXpBLVpdKyQiOiAzfX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "291" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVQgEAAAAAAAB9lIwGc3RyaW5nlEIvAQAAH4sIAAAAAAAA/02QS3OCMBSF/0onaxc8fIzuQB5CkZZEQ3DTiYGCgkBN8BHH/97YVVd37r3nnDnzPUBOBQWLBzgVnNOyAAuABsbUAkZAdHXRqkuveYZVe5p/Ki+Bazv5CnLfuTnshGW/hUfqe0Pnxi1rl2VixtdsqjQkvncu1PO0qdXvmhHUQD/usnRaMTyRzPeOO6TvM6RPE6RTgnhtaf8zvBtp1UzjJsKiikhvR7jP3++Jk5hYsh9PkBbLHQlEKi3xgbVzaJclXGGdpqja44nODHyPML9Gm+blywIXih2BleojaZpnwedsNaeJyUO4HocsPAwz3fgar+3CD/rtt5xv9qYh+HIsJQfPEeDF+XJgL0bWH6K3NW0Vs7NCxQUVAwcLQ9Oev4JmoUZVAQAAlHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_reserved_metadata.json b/tests/integrational/fixtures/native_sync/pam/grant_token_reserved_metadata.json new file mode 100644 index 00000000..3926b323 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_reserved_metadata.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVRAEAAAAAAABYPQEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdC1jaGFubmVsIjogMX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJ0ZXN0LWNoYW5uZWwiOiAxfX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjogeyJwbi1hdXRoIjogImF1dGgta2V5IiwgInBuLXV1aWQiOiAic3BlY2lmaWMtdXVpZCIsICJjdXN0b21fZmllbGQiOiAidmFsdWUifX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "317" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:53 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVRwEAAAAAAAB9lIwGc3RyaW5nlEI0AQAAH4sIAAAAAAAA/22QTW+CMACG/8rS85aUsrlo4gGEsg9HJiotXExpmYpA0RZBjf991cNOO715P/IengsQTDMwuoAqV4qtczAC85ZzY8Aj0HKX1yZpIEbODsOgWh/ffeyJt0gFXu/xKj43y6hgAW4l6WFKQzgloUzIS5uSzp0hceKfrsdtt/i3t+Mz37u+oHGT3nYBhn9/fljzerKe2WGXDFxP0PAk/cgSpNwZ1SmNNhKJLtta9yyjYZeSsEmrspjS2GIkqnnwrBMaQxZsNoJGckp0mZO+MF8wQ9aP2ZZZEJWiwkqQ2OOorMnEEfjQzFeTRJNFJoYfrxrZ6Gmw6vdVN5BOWuHvpbc44uVQduMxuD4ClR+OW35j59zRPXyx2rA8GIRKM90qMEIQXn8BTzScmm0BAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_spaces_permissions.json b/tests/integrational/fixtures/native_sync/pam/grant_token_spaces_permissions.json new file mode 100644 index 00000000..41f1dbd8 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_spaces_permissions.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVJAEAAAAAAABYHQEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsic3BhY2UxIjogMSwgInNwYWNlMiI6IDMsICJzcGFjZTMiOiAxNX0sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJzcGFjZTEiOiAxLCAic3BhY2UyIjogMywgInNwYWNlMyI6IDE1fX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge319fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "285" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:28 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVIAEAAAAAAAB9lIwGc3RyaW5nlEINAQAAH4sIAAAAAAAA/22QyW6DMBRFf6XyOgtMqlSJ1AWU2LQEJMwU2ESOTU2ZhYFMyr/X6aabLN+5evdK5wY4HSnY3ECTS0lFDjYgmBhTB1iAsavyVpFeQ7pRIQ03YrbfTIvbRGLrbLEmvvYRKSlGU6dnV4ZRmYWfVtZ6pzTxave0btjSLFI9OhuR17L2Q/hLla28f548/bP43rt0WwJ5UlfdVvF9UBPsdWmyEr7OL8wxLdVRqgyypSOIHUOaBIJgWHOMHzt9BoVA8LiT8FiYBYkJWgXp2gyxUx4q7nx9B4fBH8NXe3ZctIvewX0BZD7MP+zhwfjT8OLSVnkZlA450nGSYKNr2v0XKNbNGTkBAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_substring_pattern.json b/tests/integrational/fixtures/native_sync/pam/grant_token_substring_pattern.json new file mode 100644 index 00000000..5f27eecb --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_substring_pattern.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV/wAAAAAAAACM+3sidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHsiY2hhdCI6IDEsICJyb29tLSI6IDJ9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHsiY2hhdCI6IDEsICJyb29tLSI6IDJ9fSwgIm1ldGEiOiB7fX19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "251" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:51 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVFgEAAAAAAAB9lIwGc3RyaW5nlEIDAQAAH4sIAAAAAAAA/03PS3OCMAAE4L/SydlDjK0VZzyER7A40gHK8xYSBizPEoiI438v9dTj7s4evjvgdKBgfwd1JgTNM7AH3sjYEsAKDG2ZNUvTQYJwSaBZ5/JDV3R+dIWpTzqrg7nz3W9qkrE17IY1Wu5s7Gu8VXUe2bfWcNc8rMplu8aRV7mm3cbh9pJElkwRHHD9/ELs//9aZYyKgmNSsVqRqQc1ZxPM7Ec1eBR0yUk10jCAMVV1hqom1LAvb8XOk/MJv9fnN7Qr1mWIesKtTxKFU+IrRNGir2w6vjqHA3isgMh6eWF/Vvykvpxps9j7hSwGOowC7BGEj19NOYf2HQEAAJRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_users_permissions.json b/tests/integrational/fixtures/native_sync/pam/grant_token_users_permissions.json new file mode 100644 index 00000000..1cb7de5f --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_users_permissions.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVOQEAAAAAAABYMgEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHsidXNlcjEiOiAzMiwgInVzZXIyIjogOTYsICJ1c2VyMyI6IDEwNH0sICJ1c2VycyI6IHsidXNlcjEiOiAzMiwgInVzZXIyIjogOTYsICJ1c2VyMyI6IDEwNH0sICJzcGFjZXMiOiB7fX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge30sICJ1dWlkIjogInRlc3RfdXNlciJ9fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "306" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 12:59:28 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLwEAAAAAAAB9lIwGc3RyaW5nlEIcAQAAH4sIAAAAAAAA/2WQy26DMBBFf6XyOpF4VKkSqYsQwEQJSHFag7OpXJua8gYDBaL8e92o6qbLO3N0Z3SugNOOgs0VFLGUVMRgA849YyqABeiqLC7VpHFcY5u5GizE4D1ZNveQhPZoswLP9StKKXT7yglKVu7EyQy+yEoxUTBVBtaZgSd/TKpLhOdLtB/hzsrVLmfpnhAH6TzMsz8uScR/zifUUZ3ROUcwqEi4EieDT+xg2cy0UnVXZ+ZBIA/rNDwLBPWcQ/ibUc0hnrm7vver3+qLLgQOjqajvbhtTLxHFqYwO37IU79vmh2M0ve1M+R+9LYk7pI9g9sCyLgdPtmPm+1dzYNPS+WqVYpkR7tego2habdvRCrC+U0BAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/grant_token_wildcard_pattern.json b/tests/integrational/fixtures/native_sync/pam/grant_token_wildcard_pattern.json new file mode 100644 index 00000000..68f80cb6 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/grant_token_wildcard_pattern.json @@ -0,0 +1,72 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASV9QAAAAAAAACM8XsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjogeyJncm91cF8qIjogMSwgImNoYW5uZWxfKl90c3QiOiA0fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjoge319LCAibWV0YSI6IHt9fX2ULg==" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "241" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Thu, 22 May 2025 13:01:52 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVFgEAAAAAAAB9lIwGc3RyaW5nlEIDAQAAH4sIAAAAAAAA/x2P226CMACGX2XptUuAbriY7AIGlMEkoQQB72qLdXIcLSgY333Vy/+UP98NMCIJ2NxAUwpBeAk2IBkpVQKsgOyqslVOr3mGVXkaavj07doO87FAztWhzW7pU3wmyBs7N2pp+8VjGF0KU3XyaO5crLOsrlR2KfKkxijqiszkscFmGgayME6nQ/NeH7yPvxzihVm43cNgYrl9DLnnUGif1VanMOTY3+kkSzhGes0Qevz0e53z17RcN0E410f0FiIrnbZ0MTNsQtqT6wCR6H7WsWx07qef4L4CohymX/rgtJ6YL1vSKu5B4QpJ5CjAxtC0+z+tcC0RGQEAAJRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/revoke_expired_token.json b/tests/integrational/fixtures/native_sync/pam/revoke_expired_token.json new file mode 100644 index 00000000..9e5d751e --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/revoke_expired_token.json @@ -0,0 +1,131 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVCQEAAAAAAABYAgEAAHsidHRsIjogMSwgInBlcm1pc3Npb25zIjogeyJyZXNvdXJjZXMiOiB7ImNoYW5uZWxzIjogeyJ0ZXN0X2NoYW5uZWwiOiAxfSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7InRlc3RfY2hhbm5lbCI6IDF9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHt9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHt9fSwgIm1ldGEiOiB7fSwgInV1aWQiOiAidGVzdCJ9fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "258" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Fri, 23 May 2025 11:04:31 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVEwEAAAAAAAB9lIwGc3RyaW5nlEIAAQAAH4sIAAAAAAAA/22Qy26DMBREf6XyOgswSiPYQQGTkkJrVB7ZGRtMggElJkVOlH+vW7W7LOfO1YzO3AAjMwHODQyNlIQ3wAHZhVItwArMU9+M+nIKQuj2oYEGvuRH22cRlu5novZlKjBKpqp47uoIC2rhtoJdVw9rUbuhv7delylIrhSlD31WJmoKsMkK0eu/pSqz/zz+AZmisedTyztqz6RWzHGUm6TIOEamYAj9adwzlF+Z7iEFq7YvXTTagyXyxmSx3K2zXepvItW+260XbLZQwT5NcnbgJwXuKyCb89eB/nC7v9hPb2TUO5w1vpzJfJHAgYZx/wY5VfQeKQEAAJRzLg==" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant/qEF2AkF0GmgwVj9DdHRsAUNyZXOlRGNoYW6hbHRlc3RfY2hhbm5lbAFDZ3JwoENzcGOhbHRlc3RfY2hhbm5lbAFDdXNyoER1dWlkoENwYXSlRGNoYW6gQ2dycKBDc3BjoEN1c3KgRHV1aWSgRG1ldGGgRHV1aWRkdGVzdENzaWdYIChHn9m3lVe1dKsL5SLOD7HyfP9fBE7I2y2kONVdigqy", + "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": [ + "Fri, 23 May 2025 11:05:32 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Content-Length": [ + "180" + ], + "Connection": [ + "keep-alive" + ], + "Access-Control-Allow-Methods": [ + "DELETE" + ], + "Access-Control-Allow-Headers": [ + "Origin, X-Requested-With, Content-Type, Accept" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVxAAAAAAAAAB9lIwGc3RyaW5nlIy0eyJlcnJvciI6eyJkZXRhaWxzIjpbeyJsb2NhdGlvbiI6InRva2VuIiwibG9jYXRpb25UeXBlIjoicGF0aCIsIm1lc3NhZ2UiOiJUb2tlbiBpcyBleHBpcmVkLiJ9XSwibWVzc2FnZSI6IkludmFsaWQgdG9rZW4iLCJzb3VyY2UiOiJyZXZva2UifSwic2VydmljZSI6IkFjY2VzcyBNYW5hZ2VyIiwic3RhdHVzIjo0MDB9lHMu" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/revoke_token.json b/tests/integrational/fixtures/native_sync/pam/revoke_token.json new file mode 100644 index 00000000..189f2544 --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/revoke_token.json @@ -0,0 +1,131 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVDgEAAAAAAABYBwEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsidGVzdF9jaGFubmVsIjogMjA3fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7InRlc3RfY2hhbm5lbCI6IDIwN319LCAicGF0dGVybnMiOiB7ImNoYW5uZWxzIjoge30sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjoge319LCAibWV0YSI6IHt9LCAidXVpZCI6ICJ0ZXN0In19lC4=" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "263" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Fri, 23 May 2025 09:14:05 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVIAEAAAAAAAB9lIwGc3RyaW5nlEINAQAAH4sIAAAAAAAA/y2QSY+CMACF/8qkZw8URhK5IUudMHS0OGwXU1uGjGUZLYti/O9Tice35CXvuwNOOwqsO6gLKWlZAAtEPWNKgAXoWlE0yjl7vm4LX0N1OW596PINkci9uqyOp79vcqLI79vkquUp1lIdt1my7PNkzCYNN6xxyp2Bx8z0JUfxxP3V3D/WsUThyuUpvrUegTypROupXhpVBD03zHKn8xsL1i4z1ieVQWYEJdnEkCZRSRCsOEIvTcS87eGJJjz7CG1nf6gbkbfV8mDsITe/5PFdOCnMDYkHYYax83Megq3xCR4LIIvL8Mue3+35+ltIG8XiohDIjna9BJauaY9/UwdsXS0BAACUcy4=" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant/qEF2AkF0GmgwPF1DdHRsGDxDcmVzpURjaGFuoWx0ZXN0X2NoYW5uZWwYz0NncnCgQ3NwY6FsdGVzdF9jaGFubmVsGM9DdXNyoER1dWlkoENwYXSlRGNoYW6gQ2dycKBDc3BjoEN1c3KgRHV1aWSgRG1ldGGgRHV1aWRkdGVzdENzaWdYIMACT_mnkZol5_3T1d6Osb4kCX1Z3sNvk6MVCfqvKP3L", + "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": [ + "Fri, 23 May 2025 09:14:06 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Content-Length": [ + "70" + ], + "Connection": [ + "keep-alive" + ], + "Access-Control-Allow-Methods": [ + "DELETE" + ], + "Access-Control-Allow-Headers": [ + "Origin, X-Requested-With, Content-Type, Accept" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVVgAAAAAAAAB9lIwGc3RyaW5nlIxGeyJkYXRhIjp7Im1lc3NhZ2UiOiJTdWNjZXNzIn0sInNlcnZpY2UiOiJBY2Nlc3MgTWFuYWdlciIsInN0YXR1cyI6MjAwfZRzLg==" + } + } + } + ] +} diff --git a/tests/integrational/fixtures/native_sync/pam/revoke_token.yaml b/tests/integrational/fixtures/native_sync/pam/revoke_token.yaml deleted file mode 100644 index 482c2e05..00000000 --- a/tests/integrational/fixtures/native_sync/pam/revoke_token.yaml +++ /dev/null @@ -1,84 +0,0 @@ -interactions: -- request: - body: '{"ttl": 60, "permissions": {"resources": {"channels": {"test_channel": - 207}, "groups": {}, "uuids": {}, "users": {}, "spaces": {}}, "patterns": {"channels": - {}, "groups": {}, "uuids": {}, "users": {}, "spaces": {}}, "meta": {}, "uuid": - "test"}}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '244' - Content-type: - - application/json - User-Agent: - - PubNub-Python/5.4.0 - method: POST - uri: https://ps.pndsn.com/v3/pam/sub-c-stub/grant - response: - body: - string: '{"data":{"message":"Success","token":"qEF2AkF0GmGFTxxDdHRsGDxDcmVzpURjaGFuoWx0ZXN0X2NoYW5uZWwYz0NncnCgQ3VzcqBDc3BjoER1dWlkoENwYXSlRGNoYW6gQ2dycKBDdXNyoENzcGOgRHV1aWSgRG1ldGGgRHV1aWRkdGVzdENzaWdYIMD7y8nuLytwo00ZNv2Dv9_nQU46Zg5f7qql6Yw9dkhr"},"service":"Access - Manager","status":200}' - headers: - Access-Control-Allow-Headers: - - Origin, X-Requested-With, Content-Type, Accept - Access-Control-Allow-Methods: - - GET - Access-Control-Allow-Origin: - - '*' - Cache-Control: - - no-cache, no-store, must-revalidate - Connection: - - keep-alive - Content-Length: - - '281' - Content-Type: - - text/javascript; charset=UTF-8 - Date: - - Fri, 05 Nov 2021 15:34:52 GMT - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - PubNub-Python/5.4.0 - method: DELETE - uri: https://ps.pndsn.com/v3/pam/sub-c-stub/grant/qEF2AkF0GmGFTxxDdHRsGDxDcmVzpURjaGFuoWx0ZXN0X2NoYW5uZWwYz0NncnCgQ3VzcqBDc3BjoER1dWlkoENwYXSlRGNoYW6gQ2dycKBDdXNyoENzcGOgRHV1aWSgRG1ldGGgRHV1aWRkdGVzdENzaWdYIMD7y8nuLytwo00ZNv2Dv9_nQU46Zg5f7qql6Yw9dkhr - response: - body: - string: '{"data":{"message":"Success"},"service":"Access Manager","status":200}' - headers: - Access-Control-Allow-Headers: - - Origin, X-Requested-With, Content-Type, Accept - Access-Control-Allow-Methods: - - GET - Access-Control-Allow-Origin: - - '*' - Cache-Control: - - no-cache, no-store, must-revalidate - Connection: - - keep-alive - Content-Length: - - '70' - Content-Type: - - text/javascript; charset=UTF-8 - Date: - - Fri, 05 Nov 2021 15:34:52 GMT - status: - code: 200 - message: OK -version: 1 diff --git a/tests/integrational/fixtures/native_sync/pam/revoke_token_verify_operations.json b/tests/integrational/fixtures/native_sync/pam/revoke_token_verify_operations.json new file mode 100644 index 00000000..c0daa9de --- /dev/null +++ b/tests/integrational/fixtures/native_sync/pam/revoke_token_verify_operations.json @@ -0,0 +1,258 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant", + "body": { + "pickle": "gASVGwEAAAAAAABYFAEAAHsidHRsIjogMSwgInBlcm1pc3Npb25zIjogeyJyZXNvdXJjZXMiOiB7ImNoYW5uZWxzIjogeyJ0ZXN0X2NoYW5uZWwiOiAyMDd9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHsidGVzdF9jaGFubmVsIjogMjA3fX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7fSwgImdyb3VwcyI6IHt9LCAidXVpZHMiOiB7fSwgInVzZXJzIjoge30sICJzcGFjZXMiOiB7fX0sICJtZXRhIjoge30sICJ1dWlkIjogInRlc3RfcmV2b2tlX3ZlcmlmeSJ9fZQu" + }, + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ], + "content-type": [ + "application/json" + ], + "content-length": [ + "276" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Date": [ + "Fri, 23 May 2025 10:17:15 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "cache-control": [ + "no-cache, no-store, must-revalidate" + ], + "content-encoding": [ + "gzip" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVMAEAAAAAAAB9lIwGc3RyaW5nlEIdAQAAH4sIAAAAAAAA/y2QTW+CMACG/8rSs4daxjJNPFBBGQQUjAV6WUrLQOXTgg6M/33oPL4feQ7PDQjWMjC/gSKRkqUJmINdx/kYwAS01Skpx6YxVkg7reC6SK+7vtWF6Utt7/Y03OT+2q2i4COLTT/niv8ToSyLCzWP8XHrIdFzG+tcwccq+IU0dGGIHn+1o8E1GqA75Yqd+iaZsmCXegrOhE2MJ6PBOlWsa2W4A19vxo0MvMGGCElNbWzEAYERe2XT+mcrVi6K2ZmSGaKhVdMy1znKy2C5rL/08bzU8FblF1V81rCUB6dJW3/a4fdq79jE0Sz2bXjeYgHuEyCT8+XAHz60p443h5Wjn/OoRbas7SSYIwjvf6lroTVBAQAAlHMu" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/publish/{PN_KEY_PAM_PUBLISH}/{PN_KEY_PAM_SUBSCRIBE}/0/test_channel/0/%22test%20message%22?auth=qEF2AkF0GmgwSytDdHRsAUNyZXOlRGNoYW6hbHRlc3RfY2hhbm5lbBjPQ2dycKBDc3BjoWx0ZXN0X2NoYW5uZWwYz0N1c3KgRHV1aWSgQ3BhdKVEY2hhbqBDZ3JwoENzcGOgQ3VzcqBEdXVpZKBEbWV0YaBEdXVpZHJ0ZXN0X3Jldm9rZV92ZXJpZnlDc2lnWCCpIDaBECABP5cv5d8p0nsiMqgtR1uB4oUMKVMAJa_EQQ%3D%3D", + "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": [ + "Fri, 23 May 2025 10:17:15 GMT" + ], + "Content-Type": [ + "text/javascript; charset=\"UTF-8\"" + ], + "Content-Length": [ + "30" + ], + "Connection": [ + "keep-alive" + ], + "Cache-Control": [ + "no-cache" + ], + "Access-Control-Allow-Methods": [ + "GET" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVLgAAAAAAAAB9lIwGc3RyaW5nlIweWzEsIlNlbnQiLCIxNzQ3OTk1NDM1MjkwNjAyNCJdlHMu" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant/qEF2AkF0GmgwSytDdHRsAUNyZXOlRGNoYW6hbHRlc3RfY2hhbm5lbBjPQ2dycKBDc3BjoWx0ZXN0X2NoYW5uZWwYz0N1c3KgRHV1aWSgQ3BhdKVEY2hhbqBDZ3JwoENzcGOgQ3VzcqBEdXVpZKBEbWV0YaBEdXVpZHJ0ZXN0X3Jldm9rZV92ZXJpZnlDc2lnWCCpIDaBECABP5cv5d8p0nsiMqgtR1uB4oUMKVMAJa_EQQ%3D%3D", + "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": [ + "Fri, 23 May 2025 10:17:15 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Content-Length": [ + "70" + ], + "Connection": [ + "keep-alive" + ], + "Access-Control-Allow-Methods": [ + "DELETE" + ], + "Access-Control-Allow-Headers": [ + "Origin, X-Requested-With, Content-Type, Accept" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ] + }, + "body": { + "pickle": "gASVVgAAAAAAAAB9lIwGc3RyaW5nlIxGeyJkYXRhIjp7Im1lc3NhZ2UiOiJTdWNjZXNzIn0sInNlcnZpY2UiOiJBY2Nlc3MgTWFuYWdlciIsInN0YXR1cyI6MjAwfZRzLg==" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://ps.pndsn.com/publish/{PN_KEY_PAM_PUBLISH}/{PN_KEY_PAM_SUBSCRIBE}/0/test_channel/0/%22test%20message%22?auth=qEF2AkF0GmgwSytDdHRsAUNyZXOlRGNoYW6hbHRlc3RfY2hhbm5lbBjPQ2dycKBDc3BjoWx0ZXN0X2NoYW5uZWwYz0N1c3KgRHV1aWSgQ3BhdKVEY2hhbqBDZ3JwoENzcGOgQ3VzcqBEdXVpZKBEbWV0YaBEdXVpZHJ0ZXN0X3Jldm9rZV92ZXJpZnlDc2lnWCCpIDaBECABP5cv5d8p0nsiMqgtR1uB4oUMKVMAJa_EQQ%3D%3D", + "body": "", + "headers": { + "host": [ + "ps.pndsn.com" + ], + "accept": [ + "*/*" + ], + "accept-encoding": [ + "gzip, deflate" + ], + "connection": [ + "keep-alive" + ], + "user-agent": [ + "PubNub-Python/10.4.0" + ] + } + }, + "response": { + "status": { + "code": 403, + "message": "Forbidden" + }, + "headers": { + "Date": [ + "Fri, 23 May 2025 10:17:23 GMT" + ], + "Content-Type": [ + "text/javascript; charset=UTF-8" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Connection": [ + "keep-alive" + ], + "Access-Control-Allow-Methods": [ + "GET" + ], + "X-Pn-Cause": [ + "4001" + ], + "Cache-Control": [ + "no-cache, no-store, must-revalidate" + ], + "Access-Control-Allow-Headers": [ + "Origin, X-Requested-With, Content-Type, Accept" + ], + "Access-Control-Allow-Credentials": [ + "true" + ], + "Access-Control-Expose-Headers": [ + "*" + ], + "Content-Encoding": [ + "gzip" + ] + }, + "body": { + "pickle": "gASVcgAAAAAAAAB9lIwGc3RyaW5nlENiH4sIAAAAAAAAA6tWSi0qyi9SsiopKk3VUSouSSwpLVayMjEwBnJSi8oyk1OVrJQck5NTi4sVfBPzEtNTi5R0lHKBXCATKBWSn52ap5BZrFCUWgZkpijVcgEAFMheNFQAAACUcy4=" + } + } + } + ] +} diff --git a/tests/integrational/native_sync/test_grant_token.py b/tests/integrational/native_sync/test_grant_token.py index bd39e0c4..2dbb17ff 100644 --- a/tests/integrational/native_sync/test_grant_token.py +++ b/tests/integrational/native_sync/test_grant_token.py @@ -1,4 +1,6 @@ +import pytest +from pubnub.exceptions import PubNubException from pubnub.pubnub import PubNub from pubnub.models.consumer.v3.access_manager import PNGrantTokenResult from pubnub.models.consumer.v3.channel import Channel @@ -52,3 +54,422 @@ def test_grant_auth_key_with_user_id_and_spaces(): .sync() assert isinstance(envelope.result, PNGrantTokenResult) assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_min_ttl.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_min_ttl(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_grant_min_ttl" + + envelope = pubnub.grant_token() \ + .ttl(1) \ + .channels([Channel().id('test_channel').read()]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_max_ttl.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_max_ttl(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_grant_max_ttl" + + envelope = pubnub.grant_token() \ + .ttl(43200) \ + .channels([Channel().id('test_channel').read()]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_invalid_ttl.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_invalid_ttl(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_grant_invalid_ttl" + + # Test with TTL below minimum (should raise exception) + with pytest.raises(PubNubException): + pubnub.grant_token() \ + .ttl(0) \ + .channels([Channel().id('test_channel').read()]) \ + .sync() + + # Test with TTL above maximum (should raise exception) + with pytest.raises(PubNubException): + pubnub.grant_token() \ + .ttl(43201) \ + .channels([Channel().id('test_channel').read()]) \ + .sync() + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_format_validation.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_format_validation(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_grant_format" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .channels([Channel().id('test_channel').read()]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + # Basic format validation - token should be a non-empty string + assert isinstance(envelope.result.token, str) + assert len(envelope.result.token) > 0 + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_channel_individual_permissions.json', + serializer='pn_json', filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_channel_individual_permissions(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_channel_permissions" + + # Test each permission individually + permissions = { + "read_only": Channel().id('channel_read').read(), + "write_only": Channel().id('channel_write').write(), + "manage_only": Channel().id('channel_manage').manage(), + "delete_only": Channel().id('channel_delete').delete(), + "get_only": Channel().id('channel_get').get(), + "update_only": Channel().id('channel_update').update(), + "join_only": Channel().id('channel_join').join() + } + + for permission_name, channel in permissions.items(): + envelope = pubnub.grant_token() \ + .ttl(60) \ + .channels([channel]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_channel_all_permissions.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_channel_all_permissions(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_channel_all_perms" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .channels([Channel().id('all_permissions_channel').read().write().manage().delete().get().update().join()]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_groups_permissions.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_group_permissions(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_group_permissions" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .groups([ + Group().id('group1').read(), # Read-only group + Group().id('group2').read().manage(), # Read + manage group + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_users_permissions.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_users_permissions(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_users_permissions" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .authorized_user('test_user') \ + .uuids([ + UUID().id('user1').get(), # Get only + UUID().id('user2').get().update(), # Get + update + UUID().id('user3').get().update().delete() # All user permissions + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_spaces_permissions.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_spaces_permissions(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_spaces_permissions" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .spaces([ + Space().id('space1').read(), # Read only + Space().id('space2').read().write(), # Read + write + Space().id('space3').read().write().manage().delete() # All space permissions + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_mixed_resources.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_mixed_resources(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_mixed_resources" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .authorized_uuid('test_user') \ + .channels([ + Channel().id('channel1').read().write() + ]) \ + .groups([ + Group().id('group1').read().manage() + ]) \ + .uuids([ + UUID().id('user1').get().update() + ]) \ + .spaces([ + Space().id('space1').read().write() + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_exact_pattern.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_exact_pattern(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_exact_pattern" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .channels([ + Channel().pattern('^exact-channel$').read().write(), # Exact match + Channel().pattern('^prefix-[0-9]+$').read() # Exact match with regex + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_substring_pattern.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_substring_pattern(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_substring_pattern" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .channels([ + Channel().pattern('chat').read(), # Matches any channel containing 'chat' + Channel().pattern('room-').write() # Matches any channel containing 'room-' + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_wildcard_pattern.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_wildcard_pattern(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_wildcard_pattern" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .groups([ + Group().pattern('group_*').read(), # Matches groups starting with 'group_' + Group().pattern('channel_*_tst').manage() # Matches groups starting with 'channel_' and ending with '_tst' + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_regex_patterns.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_regex_patterns(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_regex_patterns" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .users([ + UUID().pattern('^user-[0-9]+$').get(), # Matches user-123, user-456, etc. + ]) \ + .spaces([ + Space().pattern('^space-[a-zA-Z]+$').read().write() # Matches space-abc, space-XYZ, etc. + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_mixed_patterns.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_mixed_patterns(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_mixed_patterns" + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .channels([ + Channel().id('specific-channel').read().write(), # Exact channel + Channel().pattern('channel_*').read() # Pattern-based channel + ]) \ + .groups([ + Group().id('specific-group').manage(), # Exact group + Group().pattern('group_*').read() # Pattern-based group + ]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_authorization.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_authorization(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_authorization" + + # Test with authorized_uuid + uuid_envelope = pubnub.grant_token() \ + .ttl(60) \ + .authorized_uuid('specific-uuid') \ + .channels([Channel().id('test-channel').read()]) \ + .sync() + + assert isinstance(uuid_envelope.result, PNGrantTokenResult) + assert uuid_envelope.result.token + + # Test with authorized_user + user_envelope = pubnub.grant_token() \ + .ttl(60) \ + .authorized_user('specific-user') \ + .channels([Channel().id('test-channel').read()]) \ + .sync() + + assert isinstance(user_envelope.result, PNGrantTokenResult) + assert user_envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_metadata.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_metadata(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_metadata" + + # Test with custom metadata + custom_meta = { + "app_id": "my-app", + "user_type": "admin", + "custom_field": "value" + } + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .meta(custom_meta) \ + .channels([Channel().id('test-channel').read()]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token + + +@pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/grant_token_large_metadata.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] +) +def test_grant_token_large_metadata(): + pubnub = PubNub(pnconf_pam_env_copy()) + pubnub.config.uuid = "test_large_metadata" + + # Test with large metadata payload + large_meta = { + "app_data": { + "version": "1.0.0", + "environment": "production", + "features": ["chat", "presence", "push", "storage"], + "config": { + "timeout": 5000, + "retries": 3, + "cache_size": 1000, + "debug": False + } + }, + "user_data": { + "id": "12345", + "roles": ["admin", "moderator", "user"], + "permissions": ["read", "write", "delete"], + "settings": { + "notifications": True, + "theme": "dark", + "language": "en" + } + } + } + + envelope = pubnub.grant_token() \ + .ttl(60) \ + .meta(large_meta) \ + .channels([Channel().id('test-channel').read()]) \ + .sync() + + assert isinstance(envelope.result, PNGrantTokenResult) + assert envelope.result.token diff --git a/tests/integrational/native_sync/test_revoke_v3.py b/tests/integrational/native_sync/test_revoke_v3.py index 3f983ce5..5898cdec 100644 --- a/tests/integrational/native_sync/test_revoke_v3.py +++ b/tests/integrational/native_sync/test_revoke_v3.py @@ -1,23 +1,25 @@ +import pytest +import time +from pubnub.exceptions import PubNubException from pubnub.pubnub import PubNub from pubnub.models.consumer.v3.channel import Channel from tests.integrational.vcr_helper import pn_vcr -from tests.helper import pnconf_pam_stub_copy +from tests.helper import pnconf_pam_env_copy from pubnub.models.consumer.v3.access_manager import PNGrantTokenResult, PNRevokeTokenResult -pubnub = PubNub(pnconf_pam_stub_copy()) -pubnub.config.uuid = "test_revoke" +pubnub = PubNub(pnconf_pam_env_copy(uuid="test_revoke")) +pubnub_with_token = PubNub(pnconf_pam_env_copy(uuid="test_revoke_verify", auth_key=None, secret_key=None)) @pn_vcr.use_cassette( - 'tests/integrational/fixtures/native_sync/pam/revoke_token.yaml', + 'tests/integrational/fixtures/native_sync/pam/revoke_token.json', serializer='pn_json', filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] ) def test_grant_and_revoke_token(): - - grant_envelope = pubnub.grant_token()\ - .channels([Channel.id("test_channel").read().write().manage().update().join().delete()])\ - .authorized_uuid("test")\ - .ttl(60)\ + grant_envelope = pubnub.grant_token() \ + .channels([Channel.id("test_channel").read().write().manage().update().join().delete()]) \ + .authorized_uuid("test") \ + .ttl(60) \ .sync() assert isinstance(grant_envelope.result, PNGrantTokenResult) @@ -27,3 +29,74 @@ def test_grant_and_revoke_token(): revoke_envelope = pubnub.revoke_token(token).sync() assert isinstance(revoke_envelope.result, PNRevokeTokenResult) assert revoke_envelope.result.status == 200 + + +def test_revoke_token_verify_operations(): + with pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/revoke_token_verify_operations.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] + ) as cassette: + recording = (True if len(cassette.data) == 0 else False) # we are recording blank cassette + + grant_envelope = pubnub.grant_token()\ + .channels([Channel.id("test_channel").read().write().manage().update().join().delete()])\ + .authorized_uuid("test_revoke_verify")\ + .ttl(1)\ + .sync() + token = grant_envelope.result.get_token() + assert token + + # Configure a new PubNub instance with the token + pubnub_with_token.set_token(token) + + # Verify the token works before revocation + try: + pubnub_with_token.publish()\ + .channel("test_channel")\ + .message("test message")\ + .sync() + except PubNubException: + pytest.fail("Token should be valid before revocation") + + # Revoke the token + revoke_envelope = pubnub.revoke_token(token).sync() + assert revoke_envelope.result.status == 200 + + if recording: + time.sleep(10) + + # Verify operations fail after revocation + with pytest.raises(PubNubException) as exc_info: + pubnub_with_token.publish() \ + .channel("test_channel") \ + .message("test message") \ + .sync() + assert "Token is revoked" in str(exc_info.value) + + +def test_revoke_expired_token(): + with pn_vcr.use_cassette( + 'tests/integrational/fixtures/native_sync/pam/revoke_expired_token.json', serializer='pn_json', + filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature'] + ) as cassette: + recording = (True if len(cassette.data) == 0 else False) # we are recording blank cassette + + # Grant a token with minimum TTL (1 minute) + grant_envelope = pubnub.grant_token()\ + .channels([Channel.id("test_channel").read()])\ + .authorized_uuid("test")\ + .ttl(1)\ + .sync() + + token = grant_envelope.result.get_token() + + # Wait for token to expire (in real scenario) + # Note: In the test environment with VCR cassettes, + # we're testing the API response for an expired token + if recording: + time.sleep(61) # Wait for token to expire + + # Attempt to revoke expired token + with pytest.raises(PubNubException) as exc_info: + pubnub.revoke_token(token).sync() + assert "Invalid token" in str(exc_info.value) or "Token expired" in str(exc_info.value)