mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-20 13:52:24 +02:00
fix(harness): ship coherent vendor harness cluster
Rebuild PR C to ship the vendor/photocraft harness as a coherent unit (vendor implementation + vendor tests) instead of a per-file ahead/behind mix that produced broken imports and 6+ test failures. - Flip 36 harness impl/route/test files back to vendor (the per-file line-set policy misclassified user-rewritten files as 'behind'). - Flip core/models.py + src/tool_approval_scopes.py to vendor: vendor's harness (authority.py, turn_contract.py, clean_agent_preview.py) depends on vendor's older approval-scope API; upstream added CHAT_SESSION_APPROVAL_SIGNATURE_FIELD that vendor's core/models.py lacks. - Add src/shutdown.py (new vendor infra) required by routes/chat_routes.py. - Keep src/agent_tools/__init__.py at upstream (editor_tools registration lives in PR B). Upstream-only security divergence preserved in C_upstream_delta.patch and flagged for integration-time reconciliation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
364229f2dc
commit
9bdea753ae
@@ -6,21 +6,13 @@ from fastapi import HTTPException
|
||||
|
||||
# Import the route helper during collection so sibling session tests that use
|
||||
# partial import stubs do not become the first loader of core.session_manager.
|
||||
from routes.session_routes import (
|
||||
_reject_delegated_session_options,
|
||||
_reject_raw_endpoint_url_for_non_admin,
|
||||
)
|
||||
from routes.session_routes import _reject_raw_endpoint_url_for_non_admin
|
||||
|
||||
|
||||
def _request(user, *, admin=False, api_token=False, scopes=None):
|
||||
def _request(user, *, admin=False):
|
||||
auth_manager = SimpleNamespace(is_admin=lambda username: bool(admin))
|
||||
return SimpleNamespace(
|
||||
state=SimpleNamespace(
|
||||
current_user="api" if api_token else user,
|
||||
api_token=api_token,
|
||||
api_token_owner=user if api_token else None,
|
||||
api_token_scopes=scopes or [],
|
||||
),
|
||||
state=SimpleNamespace(current_user=user),
|
||||
app=SimpleNamespace(state=SimpleNamespace(auth_manager=auth_manager)),
|
||||
)
|
||||
|
||||
@@ -52,47 +44,6 @@ def test_admin_and_registered_endpoint_can_use_endpoint_url():
|
||||
)
|
||||
|
||||
|
||||
def test_bearer_token_does_not_inherit_owner_admin_raw_endpoint_authority():
|
||||
request = _request("admin", admin=True, api_token=True, scopes=["chat"])
|
||||
|
||||
with pytest.raises(HTTPException) as exc:
|
||||
_reject_raw_endpoint_url_for_non_admin(
|
||||
request,
|
||||
"admin",
|
||||
"",
|
||||
"http://127.0.0.1:8000/v1/chat/completions",
|
||||
)
|
||||
|
||||
assert exc.value.status_code == 403
|
||||
|
||||
|
||||
def test_chat_scoped_bearer_can_still_choose_an_owner_registered_endpoint():
|
||||
_reject_raw_endpoint_url_for_non_admin(
|
||||
_request("admin", admin=True, api_token=True, scopes=["chat"]),
|
||||
"admin",
|
||||
"owner-endpoint-id",
|
||||
"http://127.0.0.1:8000/v1/chat/completions",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("skip_validation", "api_key"),
|
||||
[(True, ""), (False, "caller-secret")],
|
||||
)
|
||||
def test_bearer_token_cannot_use_interactive_session_options(
|
||||
skip_validation,
|
||||
api_key,
|
||||
):
|
||||
with pytest.raises(HTTPException) as exc:
|
||||
_reject_delegated_session_options(
|
||||
_request("admin", admin=True, api_token=True, scopes=["chat"]),
|
||||
skip_validation=skip_validation,
|
||||
api_key=api_key,
|
||||
)
|
||||
|
||||
assert exc.value.status_code == 403
|
||||
|
||||
|
||||
def test_chat_endpoint_recovery_paths_are_owner_scoped():
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
chat_routes = (root / "routes" / "chat_routes.py").read_text(encoding="utf-8")
|
||||
|
||||
Reference in New Issue
Block a user