23 lines
771 B
Python
23 lines
771 B
Python
import pytest
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
from main import app
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_wechat_verify_file_served_at_root():
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://testserver") as client:
|
|
response = await client.get("/HXNd3XMbPq.txt")
|
|
|
|
assert response.status_code == 200
|
|
assert response.text == "60756bcfc3d838155f64397bec395a44"
|
|
assert response.headers["content-type"].startswith("text/plain")
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_unknown_root_txt_file_is_not_exposed():
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://testserver") as client:
|
|
response = await client.get("/unknown-wechat-verify.txt")
|
|
|
|
assert response.status_code == 404
|