Beispiel #1
0
async def test_base_reader_limit(loop):
    proto = BaseSocksProtocol(None, None, ('python.org', 80),
                              None, None, reader_limit=10, loop=loop)
    assert proto.reader._limit == 10

    proto = BaseSocksProtocol(None, None, ('python.org', 80),
                              None, None, reader_limit=15, loop=loop)
    assert proto.reader._limit == 15
Beispiel #2
0
 def test_incomplete_error(self):
     proto = BaseSocksProtocol(None, None, ('python.org', 80),
                               None, None, reader_limit=10,
                               loop=self.loop)
     proto._stream_reader.readexactly = fake_coroutine(
         asyncio.IncompleteReadError(b'part', 5))
     with self.assertRaises(aiosocks.InvalidServerReply):
         self.loop.run_until_complete(proto.read_response(4))
Beispiel #3
0
 def test_incomplete_error(self):
     proto = BaseSocksProtocol(None,
                               None, ('python.org', 80),
                               None,
                               None,
                               reader_limit=10,
                               loop=self.loop)
     proto._stream_reader.readexactly = fake_coroutine(
         asyncio.IncompleteReadError(b'part', 5))
     with self.assertRaises(aiosocks.InvalidServerReply):
         self.loop.run_until_complete(proto.read_response(4))
Beispiel #4
0
def test_base_ctor(loop):
    with pytest.raises(ValueError):
        BaseSocksProtocol(None, None, None, loop=loop,
                          waiter=None, app_protocol_factory=None)

    with pytest.raises(ValueError):
        BaseSocksProtocol(None, None, 123, loop=loop,
                          waiter=None, app_protocol_factory=None)

    with pytest.raises(ValueError):
        BaseSocksProtocol(None, None, ('python.org',), loop=loop,
                          waiter=None, app_protocol_factory=None)
Beispiel #5
0
    def test_reader_limit(self):
        proto = BaseSocksProtocol(None,
                                  None, ('python.org', 80),
                                  None,
                                  None,
                                  reader_limit=10,
                                  loop=self.loop)
        self.assertEqual(proto.reader._limit, 10)

        proto = BaseSocksProtocol(None,
                                  None, ('python.org', 80),
                                  None,
                                  None,
                                  reader_limit=15,
                                  loop=self.loop)
        self.assertEqual(proto.reader._limit, 15)
Beispiel #6
0
async def test_base_incomplete_error(loop):
    proto = BaseSocksProtocol(None, None, ('python.org', 80),
                              None, None, reader_limit=10, loop=loop)
    proto._stream_reader.readexactly = make_mocked_coro(
        raise_exception=asyncio.IncompleteReadError(b'part', 5))
    with pytest.raises(aiosocks.InvalidServerReply):
        await proto.read_response(4)
Beispiel #7
0
def make_base(loop, *, dst=None, waiter=None, ap_factory=None, ssl=None):
    dst = dst or ('python.org', 80)

    proto = BaseSocksProtocol(None, None, dst=dst, ssl=ssl,
                              loop=loop, waiter=waiter,
                              app_protocol_factory=ap_factory)
    return proto
Beispiel #8
0
    def test_init(self):
        with self.assertRaises(ValueError):
            BaseSocksProtocol(None,
                              None,
                              None,
                              loop=self.loop,
                              waiter=None,
                              app_protocol_factory=None)

        with self.assertRaises(ValueError):
            BaseSocksProtocol(None,
                              None,
                              123,
                              loop=self.loop,
                              waiter=None,
                              app_protocol_factory=None)

        with self.assertRaises(ValueError):
            BaseSocksProtocol(None,
                              None, ('python.org', ),
                              loop=self.loop,
                              waiter=None,
                              app_protocol_factory=None)