PrivateFormat,
load_pem_private_key,
)
-from typing_extensions import Literal
from uvicorn.config import Config
from uvicorn.main import Server
await send({"type": "http.response.body"})
-SERVER_SCOPE: Literal["session"] = "session"
-
-
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def cert_authority():
return trustme.CA()
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def ca_cert_pem_file(cert_authority):
with cert_authority.cert_pem.tempfile() as tmp:
yield tmp
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def localhost_cert(cert_authority):
return cert_authority.issue_cert("localhost")
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def cert_pem_file(localhost_cert):
with localhost_cert.cert_chain_pems[0].tempfile() as tmp:
yield tmp
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def cert_private_key_file(localhost_cert):
with localhost_cert.private_key_pem.tempfile() as tmp:
yield tmp
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def cert_encrypted_private_key_file(localhost_cert):
# Deserialize the private key and then reserialize with a password
private_key = load_pem_private_key(
thread.join()
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def server():
config = Config(app=app, lifespan="off", loop="asyncio")
server = TestServer(config=config)
yield from serve_in_thread(server)
-@pytest.fixture(scope=SERVER_SCOPE)
+@pytest.fixture(scope="session")
def https_server(cert_pem_file, cert_private_key_file):
config = Config(
app=app,