|
| 1 | +import pytest |
| 2 | + |
1 | 3 | import aiohttp |
2 | 4 | from aiohttp import web |
3 | 5 | from aiohttp.pytest_plugin import AiohttpClient |
4 | 6 | from aiohttp_remotes import BasicAuth, setup as _setup |
5 | 7 |
|
6 | 8 |
|
7 | | -async def test_basic_auth_ok(aiohttp_client: AiohttpClient) -> None: |
| 9 | +@pytest.mark.parametrize("password", ["pass", "pass:pass:"]) |
| 10 | +async def test_basic_auth_ok(aiohttp_client: AiohttpClient, password: str) -> None: |
8 | 11 | async def handler(request: web.Request) -> web.Response: |
9 | 12 | return web.Response() |
10 | 13 |
|
11 | 14 | app = web.Application() |
12 | 15 | app.router.add_get("/", handler) |
13 | | - await _setup(app, BasicAuth("user", "pass", "realm")) |
| 16 | + await _setup(app, BasicAuth("user", password, "realm")) |
14 | 17 | cl = await aiohttp_client(app) |
15 | | - resp = await cl.get("/", auth=aiohttp.BasicAuth("user", "pass")) |
| 18 | + resp = await cl.get("/", auth=aiohttp.BasicAuth("user", password)) |
16 | 19 | assert resp.status == 200 |
17 | 20 |
|
18 | 21 |
|
@@ -55,19 +58,6 @@ async def handler(request: web.Request) -> web.Response: |
55 | 58 | assert resp.headers["WWW-Authenticate"] == "Basic realm=realm" |
56 | 59 |
|
57 | 60 |
|
58 | | -async def test_basic_auth_malformed_req2(aiohttp_client: AiohttpClient) -> None: |
59 | | - async def handler(request: web.Request) -> web.Response: |
60 | | - return web.Response() |
61 | | - |
62 | | - app = web.Application() |
63 | | - app.router.add_get("/", handler) |
64 | | - await _setup(app, BasicAuth("user", "pass", "realm")) |
65 | | - cl = await aiohttp_client(app) |
66 | | - resp = await cl.get("/", headers={"Authorization": "Basic nonbase64"}) |
67 | | - assert resp.status == 401 |
68 | | - assert resp.headers["WWW-Authenticate"] == "Basic realm=realm" |
69 | | - |
70 | | - |
71 | 61 | async def test_basic_auth_white_path(aiohttp_client: AiohttpClient) -> None: |
72 | 62 | async def handler(request: web.Request) -> web.Response: |
73 | 63 | return web.Response() |
|
0 commit comments