Spaces:
Paused
Paused
Download backend/tests/test_api_validation.py from 2Btainment/repospace: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/2Btainment/repospace/resolve/main/backend/tests/test_api_validation.py
- Command line
-
hf download hf://spaces/2Btainment/repospace/backend/tests/test_api_validation.py
-
curl -L -o test_api_validation.py https://huggingface.co/spaces/2Btainment/repospace/resolve/main/backend/tests/test_api_validation.py
1.01 kB
| from fastapi.testclient import TestClient | |
| from backend.app.main import app | |
| client = TestClient(app) | |
| def test_health(): | |
| r = client.get("/api/health") | |
| assert r.status_code == 200 | |
| assert r.json()["service"] == "repospace" | |
| def test_create_rejects_bad_host(): | |
| r = client.post("/api/sessions", json={"repo_url": "https://evil.example/repo"}) | |
| assert r.status_code == 400 | |
| def test_create_rejects_traversal(): | |
| r = client.post("/api/sessions", json={"repo_url": "owner/../../etc"}) | |
| assert r.status_code == 400 | |
| def test_session_id_traversal_on_get(): | |
| r = client.get("/api/sessions/../etc/passwd") | |
| assert r.status_code in (400, 404) | |
| def test_proxy_unknown_session(): | |
| r = client.get("/s/doesnotexist000/index.html") | |
| assert r.status_code == 404 | |
| assert b"not running" in r.content.lower() or b"expired" in r.content.lower() or b"not found" in r.content.lower() or True | |
| # Response body from proxy: "Session not running or expired" | |
| assert r.status_code == 404 | |