Пример #1
0
    def test_encrypted(self):
        ch = "history-native-sync-ch"
        pubnub = PubNub(pnconf_enc_copy())
        pubnub.config.uuid = "history-native-sync-uuid"

        for i in range(COUNT):
            envelope = pubnub.publish().channel(ch).message("hey-%s" %
                                                            i).sync()
            assert isinstance(envelope.result, PNPublishResult)
            assert envelope.result.timetoken > 0

        time.sleep(5)

        envelope = pubnub.history().channel(ch).count(COUNT).sync()

        assert isinstance(envelope.result, PNHistoryResult)
        assert envelope.result.start_timetoken > 0
        assert envelope.result.end_timetoken > 0
        assert len(envelope.result.messages) == 5

        assert envelope.result.messages[0].entry == 'hey-0'
        assert envelope.result.messages[1].entry == 'hey-1'
        assert envelope.result.messages[2].entry == 'hey-2'
        assert envelope.result.messages[3].entry == 'hey-3'
        assert envelope.result.messages[4].entry == 'hey-4'
Пример #2
0
def test_publish_mixed_via_post_encrypted(event_loop):
    pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop)
    yield from asyncio.gather(
        asyncio.ensure_future(assert_success_publish_post(pubnub, "hi")),
        asyncio.ensure_future(assert_success_publish_post(pubnub, 5)),
        asyncio.ensure_future(assert_success_publish_post(pubnub, True)),
        asyncio.ensure_future(assert_success_publish_post(pubnub, ["hi", "hi2", "hi3"])))

    pubnub.stop()
Пример #3
0
async def test_publish_object_via_post_encrypted(event_loop):
    pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop)
    await asyncio.ensure_future(
        assert_success_publish_post(pubnub, {
            "name": "Alex",
            "online": True
        }))

    await pubnub.stop()
Пример #4
0
def test_publish_mixed_via_post_encrypted(event_loop):
    pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop)
    yield from asyncio.gather(
        asyncio.ensure_future(assert_success_publish_post(pubnub, "hi")),
        asyncio.ensure_future(assert_success_publish_post(pubnub, 5)),
        asyncio.ensure_future(assert_success_publish_post(pubnub, True)),
        asyncio.ensure_future(assert_success_publish_post(pubnub, ["hi", "hi2", "hi3"])))

    pubnub.stop()
Пример #5
0
async def test_publish_mixed_via_get_encrypted(event_loop):
    with patch("pubnub.crypto.PubNubCryptodome.get_initialization_vector", return_value="knightsofni12345"):
        pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop)
        await asyncio.gather(
            asyncio.ensure_future(assert_success_publish_get(pubnub, "hi")),
            asyncio.ensure_future(assert_success_publish_get(pubnub, 5)),
            asyncio.ensure_future(assert_success_publish_get(pubnub, True)),
            asyncio.ensure_future(assert_success_publish_get(pubnub, ["hi", "hi2", "hi3"])))

    await pubnub.stop()
Пример #6
0
    def test_encrypted(self):
        ch = "history-native-sync-ch"
        pubnub = PubNub(pnconf_enc_copy())
        pubnub.config.uuid = "history-native-sync-uuid"

        for i in range(COUNT):
            envelope = pubnub.publish().channel(ch).message("hey-%s" % i).sync()
            assert isinstance(envelope.result, PNPublishResult)
            assert envelope.result.timetoken > 0

        time.sleep(5)

        envelope = pubnub.history().channel(ch).count(COUNT).sync()

        assert isinstance(envelope.result, PNHistoryResult)
        assert envelope.result.start_timetoken > 0
        assert envelope.result.end_timetoken > 0
        assert len(envelope.result.messages) == 5

        assert envelope.result.messages[0].entry == 'hey-0'
        assert envelope.result.messages[1].entry == 'hey-1'
        assert envelope.result.messages[2].entry == 'hey-2'
        assert envelope.result.messages[3].entry == 'hey-3'
        assert envelope.result.messages[4].entry == 'hey-4'
Пример #7
0
def test_publish_object_via_post_encrypted(event_loop):
    pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop)
    yield from asyncio.ensure_future(assert_success_publish_post(pubnub, {"name": "Alex", "online": True}))

    pubnub.stop()
Пример #8
0
 def assert_success_encrypted_publish_get(self, message):
     pubnub = PubNubTwisted(pnconf_enc_copy())
     publish = pubnub.publish().channel(channel).message(message)
     envelope = yield self.deferred(publish)
     self.assert_valid_publish_envelope(envelope)
     returnValue(envelope)
Пример #9
0
async def test_publish_object_via_post_encrypted(event_loop):
    with patch("pubnub.crypto.PubNubCryptodome.get_initialization_vector", return_value="knightsofni12345"):
        pubnub = PubNubAsyncio(pnconf_enc_copy(), custom_event_loop=event_loop)
        await asyncio.ensure_future(assert_success_publish_post(pubnub, {"name": "Alex", "online": True}))

    await pubnub.stop()
Пример #10
0
 def assert_success_encrypted_publish_get(self, message):
     pubnub = PubNubTwisted(pnconf_enc_copy())
     publish = pubnub.publish().channel(channel).message(message)
     envelope = yield self.deferred(publish)
     self.assert_valid_publish_envelope(envelope)
     returnValue(envelope)