""" Input Validation Security Tests. This module tests input validation across the application to ensure all user inputs are properly sanitized and validated. """ import pytest from httpx import AsyncClient from src.server.fastapi_app import app @pytest.mark.security class TestInputValidation: """Security tests for input validation.""" @pytest.fixture async def client(self): """Create async HTTP client for testing.""" from httpx import ASGITransport async with AsyncClient( transport=ASGITransport(app=app), base_url="http://test" ) as ac: yield ac @pytest.mark.asyncio async def test_xss_in_anime_title(self, client): """Test XSS protection in anime title input.""" xss_payloads = [ "", "", "javascript:alert('XSS')", "", ] for payload in xss_payloads: response = await client.post( "/api/anime", json={"title": payload, "description": "Test"}, ) # Should either reject or sanitize if response.status_code == 200: # If accepted, should be sanitized data = response.json() title = data.get("data", {}).get("title", "") assert "