hack-house/tests/conftest.py
mirai 5cbe355660 feat: add SRP authentication, improve security
- Replace RSA key exchange with SRP (Secure Remote Password)
- Password never transmitted over network
- Add unit tests for endpoints
- Fix datetime.UTC compatibility for Python < 3.11
- Fix logger.exception usage
- Update README with new auth flow diagram
2026-01-02 23:09:00 +03:00

41 lines
1000 B
Python

import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
import uuid
import pytest
from sanic_testing import TestManager
from sanic import Sanic
from sanic_ext import Extend
from cryptography.fernet import Fernet
from cmd_chat.server.managers import ConnectionManager
from cmd_chat.server.stores import MessageStore, UserSessionStore
from cmd_chat.server.srp_auth import SRPAuthManager
from cmd_chat.server.routes import register_routes
@pytest.fixture
def app():
name = f"test-{uuid.uuid4().hex[:8]}"
app = Sanic(name)
Extend(app)
app.ctx.message_store = MessageStore()
app.ctx.session_store = UserSessionStore()
app.ctx.connection_manager = ConnectionManager()
app.ctx.srp_manager = SRPAuthManager("testpassword")
app.ctx.fernet_key = Fernet.generate_key()
app.ctx.cleanup_task = None
register_routes(app)
TestManager(app)
return app
@pytest.fixture
def test_client(app):
return app.test_client