"""Tests for LocalHTTPServer — TDD: tests before implementation.""" import pytest from i2p_apps.i2ptunnel.local_http_server import LocalHTTPHandler class TestLocalHTTPHandler: def test_creation(self): h = LocalHTTPHandler() assert h is not None def test_health_page(self): h = LocalHTTPHandler() status, body = h.handle_get("/") assert status == 200 assert "i2p" in body.lower() or "proxy" in body.lower() def test_add_form_get(self): h = LocalHTTPHandler() status, body = h.handle_get("/add?host=example.i2p&dest=AAAA") assert status == 200 assert "example.i2p" in body assert "form" in body.lower() def test_unknown_path(self): h = LocalHTTPHandler() status, body = h.handle_get("/nonexistent") assert status == 404 def test_nonce_generation(self): h = LocalHTTPHandler() n1 = h._generate_nonce() n2 = h._generate_nonce() assert n1 != n2 assert len(n1) >= 16