feat: 导入 MemRelay 初始源码
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from collections.abc import Iterator
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from memrelay.app import create_app
|
||||
from memrelay.config import Settings
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(tmp_path) -> Iterator[TestClient]:
|
||||
settings = Settings(
|
||||
data_dir=tmp_path / "data",
|
||||
public_url="http://testserver",
|
||||
initial_admin_username=None,
|
||||
initial_admin_password=None,
|
||||
)
|
||||
app = create_app(settings)
|
||||
with TestClient(app) as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def initialized_client(client: TestClient) -> TestClient:
|
||||
response = client.post(
|
||||
"/api/v1/auth/initialize",
|
||||
json={"username": "admin", "password": "strong-test-password"},
|
||||
)
|
||||
assert response.status_code == 201
|
||||
return client
|
||||
|
||||
|
||||
def csrf_headers(client: TestClient) -> dict[str, str]:
|
||||
return {"X-CSRF-Token": client.cookies["memrelay_csrf"]}
|
||||
Reference in New Issue
Block a user