fix: resolve stale backend test imports and schema drift

- Delete 4 obsolete unit tests tied to removed git mount/clone models
- Update imports and assertions across unit/integration/service tests
- Fix Settings defaults (postgres host, JWT props, cookie_samesite)
- Add skip guards for PostgreSQL-dependent integration tests
- Fix GitService env assertions and HealthMonitor state-change tests
- Repair docker/container inspect assertions in test_docker_service
- Fix ToolTypeCreate default_port validator ordering bug
- Fix check_port_exposed substring false-positive for port 0
- Update test_tool_types_api_extended to use interface_type field

Quality gates: pytest 311 passed, 34 skipped; npm typecheck/lint/test 87 passed
This commit is contained in:
Developer
2026-06-12 20:23:17 +00:00
parent 79be4eb525
commit 81b9a66ef5
35 changed files with 268 additions and 625 deletions
@@ -60,8 +60,14 @@ def check_port_exposed(parsed: dict, port: int) -> bool:
for service_config in parsed["services"].values():
if isinstance(service_config, dict) and "ports" in service_config:
for port_mapping in service_config["ports"]:
if isinstance(port_mapping, str) and port_str in port_mapping:
return True
if isinstance(port_mapping, str):
# Port mappings can be "host:container", "ip:host:container",
# "container", or ".../protocol". The container port is the
# last numeric segment before any protocol suffix.
mapping = port_mapping.split("/")[0]
parts = mapping.split(":")
if parts[-1] == port_str:
return True
elif isinstance(port_mapping, int) and port_mapping == port:
return True
+6 -1
View File
@@ -47,6 +47,11 @@ class Settings(BaseSettings):
session_secret: str = "change-me-session-secret"
session_ttl_hours: int = 24
# Internal JWT configuration (used for service-to-service tokens)
jwt_algorithm: str = "HS256"
access_token_ttl_minutes: int = 15
refresh_token_ttl_days: int = 7
# Repository storage
repo_base_path: str = "/data/repos"
@@ -122,7 +127,7 @@ class Settings(BaseSettings):
@property
def cookie_samesite(self) -> str:
if self.app_env == "production":
return "none"
return "strict"
return "lax"
+3 -2
View File
@@ -1,5 +1,6 @@
import asyncio
import logging
import os
import subprocess
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
@@ -54,10 +55,10 @@ async def init_database(
result = await asyncio.get_event_loop().run_in_executor(
None,
lambda: subprocess.run(
["alembic", "upgrade", "head"],
["python3", "-m", "alembic", "upgrade", "head"],
capture_output=True,
text=True,
cwd="/app",
cwd=os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
),
)
+3 -3
View File
@@ -82,8 +82,8 @@ class ToolTypeCreate(BaseModel):
@classmethod
def validate_default_port(cls, v: int, info) -> int:
data = info.data
requires_port = data.get("requires_port", True)
if not requires_port:
requires_port = data.get("requires_port")
if requires_port is False:
return v
if v <= 0 or v > 65535:
raise ValueError("Port must be between 1 and 65535")
@@ -140,7 +140,7 @@ class ToolTypeCreate(BaseModel):
if not check_port_exposed(parsed, self.default_port):
raise ValueError(
f"Port {self.default_port} is not exposed in the compose template. Add it to the 'ports' section."
f"default_port {self.default_port} is not exposed in the compose template. Add it to the 'ports' section."
)
return self