mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-27 21:05:34 +00:00
- BoundaryGuard degrades gracefully when Rust scanners unavailable - BoundaryGuard tests use lightweight mock scanners (no Rust needed) - Server-dependent tests use pytest.importorskip for starlette/fastapi - Fix import ordering in test files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Tests for webhook fail-closed validation (Section 3)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
|
|
class TestTwilioValidationFailClosed:
|
|
"""Twilio validation must reject when SDK is unavailable."""
|
|
|
|
def test_missing_sdk_returns_false(self) -> None:
|
|
pytest.importorskip("fastapi")
|
|
from openjarvis.server.webhook_routes import _validate_twilio_signature
|
|
|
|
with patch.dict(
|
|
"sys.modules", {"twilio": None, "twilio.request_validator": None}
|
|
):
|
|
result = _validate_twilio_signature(
|
|
auth_token="test_token",
|
|
url="https://example.com/webhooks/twilio",
|
|
params={"Body": "hello"},
|
|
signature="invalid",
|
|
)
|
|
assert result is False
|
|
|
|
def test_empty_auth_token_returns_false(self) -> None:
|
|
pytest.importorskip("fastapi")
|
|
from openjarvis.server.webhook_routes import _validate_twilio_signature
|
|
|
|
result = _validate_twilio_signature(
|
|
auth_token="",
|
|
url="https://example.com/webhooks/twilio",
|
|
params={},
|
|
signature="",
|
|
)
|
|
assert result is False
|