File: test_client_side_socks.py

package info (click to toggle)
aioftp 0.26.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 624 kB
  • sloc: python: 5,566; makefile: 172
file content (35 lines) | stat: -rw-r--r-- 920 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
try:
    from siosocks.exceptions import SocksException
    HAS_SIOSOCKS = True
except ImportError:
    HAS_SIOSOCKS = False


@pytest.mark.skipif(not HAS_SIOSOCKS, reason="requires siosocks package")
@pytest.mark.asyncio
async def test_socks_success(pair_factory, Client, socks):
    client = Client(
        socks_host=socks.host,
        socks_port=socks.port,
        socks_version=5,
        username="foo",
        password="bar",
    )
    async with pair_factory(client):
        pass


@pytest.mark.skipif(not HAS_SIOSOCKS, reason="requires siosocks package")
@pytest.mark.asyncio
async def test_socks_fail(pair_factory, Client, socks):
    client = Client(
        socks_host=socks.host,
        socks_port=socks.port,
        socks_version=5,
        username="bar",
        password="bar",
    )
    with pytest.raises(SocksException):
        async with pair_factory(client):
            pass