-
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathtls_test.py
More file actions
50 lines (40 loc) · 1.44 KB
/
tls_test.py
File metadata and controls
50 lines (40 loc) · 1.44 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pytest
import wreq
from wreq.emulation import Emulation
from wreq.tls import CertStore
@pytest.mark.asyncio
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_badssl():
client = wreq.Client(tls_verify=False)
resp = await client.get("https://self-signed.badssl.com/")
async with resp:
assert resp.status.is_success()
@pytest.mark.asyncio
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_badssl_invalid_cert():
url = "https://self-signed.badssl.com/"
client = wreq.Client(tls_verify=False, tls_info=True)
resp = await client.get(url)
async with resp:
assert resp.status.is_success()
tls_info = resp.tls_info
assert tls_info is not None
peer_der_cert = tls_info.peer_certificate()
assert peer_der_cert is not None
assert isinstance(peer_der_cert, bytes)
assert len(peer_der_cert) > 0
cert_store = CertStore(der_certs=[peer_der_cert])
assert cert_store is not None
client = wreq.Client(tls_verify=cert_store)
resp = await client.get(url)
async with resp:
assert resp.status.is_success()
@pytest.mark.asyncio
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_alps_new_endpoint():
url = "https://google.com"
client = wreq.Client(emulation=Emulation.Chrome133)
resp = await client.get(url)
async with resp:
text = await resp.text()
assert text is not None