ticket #70 attempt 1

This commit is contained in:
Typosaurus
2026-07-19 18:46:25 +00:00
parent 818568c609
commit 4026e3e1a8
977 changed files with 234309 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
# retoor <retoor@molodetz.nl>
import httpx
import pytest
from devplacepy.main import app
from devplacepy.config import DATABASE_URL
from tests.conftest import run_async
@pytest.fixture
def client():
from devplacepy.database import init_db
init_db()
with httpx.Client(app=app) as c:
yield c
def test_localhost_ipv4_allowed_through(client):
gateway_url = "http://127.0.0.1/openai/v1/chat/completions"
response = client.get(gateway_url, headers={"accept": "application/json"})
assert response.status_code != 403
def test_localhost_ipv6_allowed_through(client):
gateway_url = "http://[::1]/openai/v1/models"
response = client.get(gateway_url, headers={"accept": "application/json"})
assert response.status_code != 403
def test_non_openai_path_not_affected(client):
response = client.get("http://127.0.0.1/feed", headers={"accept": "application/json"})
assert response.status_code != 403
def test_external_ip_rejected(client):
response = client.get(
"http://10.0.0.1/openai/v1/chat/completions",
headers={"accept": "application/json"},
)
assert response.status_code == 403
assert response.json() == {"detail": "Forbidden"}