forked from 0x676e67/rnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth_test.py
40 lines (33 loc) · 1.01 KB
/
auth_test.py
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
import pytest
import rnet
client = rnet.Client(tls_info=True)
@pytest.mark.asyncio
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_auth():
resp = await client.get(
"https://httpbin.org/anything",
auth="token",
)
json = await resp.json()
authorization = json["headers"]["Authorization"]
assert authorization == "token"
@pytest.mark.asyncio
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_bearer_auth():
resp = await client.get(
"https://httpbin.org/anything",
bearer_auth="token",
)
json = await resp.json()
authorization = json["headers"]["Authorization"]
assert authorization == "Bearer token"
@pytest.mark.asyncio
@pytest.mark.flaky(reruns=3, reruns_delay=2)
async def test_basic_auth():
resp = await client.get(
"https://httpbin.org/anything",
basic_auth=("user", "pass"),
)
json = await resp.json()
authorization = json["headers"]["Authorization"]
assert authorization == "Basic dXNlcjpwYXNz"