"""Tests for chatbot endpoints."""
import pytest
from unittest.mock import MagicMock, patch
class TestChatbotProtection:
def test_list_chatbots_requires_auth(self, client):
resp = client.get("/api/v1/chatbots")
assert resp.status_code == 401
def test_create_chatbot_requires_auth(self, client):
resp = client.post("/api/v1/chatbots", json={"name": "Test"})
assert resp.status_code == 401
def test_delete_chatbot_requires_auth(self, client):
resp = client.delete("/api/v1/chatbots/some-id")
assert resp.status_code == 401
class TestInputValidation:
def test_create_chatbot_rejects_long_name(self, client):
"""ChatbotCreate should reject names > 100 chars."""
from app.models import ChatbotCreate
import pytest
with pytest.raises(Exception):
ChatbotCreate(name="x" * 101)
def test_create_chatbot_strips_script_tags(self):
"""System prompt with script tags should be sanitized."""
from app.models import ChatbotCreate
data = ChatbotCreate(
name="Test",
system_prompt="Hello world",
)
assert "