feat: rebuild as multi-user web agent
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import jwt
|
||||
import pytest
|
||||
|
||||
from agent_platform.config import Settings
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def settings(tmp_path: Path) -> Settings:
|
||||
return Settings(
|
||||
model_api_base_url="https://model.example.test",
|
||||
model_api_key="model-secret",
|
||||
openwebui_forward_jwt_secret="identity-secret-with-at-least-32-bytes", # noqa: S106
|
||||
internal_provider_key="provider-secret-with-at-least-32-bytes",
|
||||
internal_gateway_key="gateway-secret-with-at-least-32-bytes",
|
||||
database_url=f"sqlite+aiosqlite:///{tmp_path / 'agent.sqlite3'}",
|
||||
redis_url="redis://unused",
|
||||
gateway_url="http://gateway.test",
|
||||
execution_provider="local-docker",
|
||||
workspace_image="k1412-agent-workspace:test",
|
||||
workspace_network_enabled=False,
|
||||
workspace_memory_limit="512m",
|
||||
workspace_cpu_limit=1.0,
|
||||
workspace_pids_limit=128,
|
||||
workspace_ssh_host="",
|
||||
model_timeout_seconds=30,
|
||||
tool_timeout_seconds=30,
|
||||
max_tool_output_chars=24_000,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def identity_jwt(settings: Settings) -> str:
|
||||
import time
|
||||
|
||||
now = int(time.time())
|
||||
return jwt.encode(
|
||||
{
|
||||
"sub": "user-123",
|
||||
"email": "user@example.test",
|
||||
"name": "Test User",
|
||||
"role": "user",
|
||||
"iss": "open-webui",
|
||||
"iat": now,
|
||||
"exp": now + 300,
|
||||
},
|
||||
settings.openwebui_forward_jwt_secret,
|
||||
algorithm="HS256",
|
||||
)
|
||||
Reference in New Issue
Block a user