"""Tests for HTTP bidirectional server — TDD: tests before implementation.""" import pytest from i2p_apps.i2ptunnel.config import TunnelDefinition, TunnelType from i2p_apps.i2ptunnel.http_bidir import HTTPBidirServerTask class MockBidirSession: def __init__(self): self.destination = "BIDI" * 129 async def accept(self): raise NotImplementedError async def lookup(self, name): return None async def connect(self, dest): raise NotImplementedError async def close(self): pass def _make_bidir_def(**kw): defaults = dict( name="bidir", type=TunnelType.HTTPBIDIRSERVER, target_host="127.0.0.1", target_port=7658, spoofed_host="mysite.i2p", ) defaults.update(kw) return TunnelDefinition(**defaults) class TestHTTPBidirServerTask: def test_creation(self): task = HTTPBidirServerTask(_make_bidir_def(), MockBidirSession()) assert task.tunnel_type == TunnelType.HTTPBIDIRSERVER def test_is_server_type(self): task = HTTPBidirServerTask(_make_bidir_def(), MockBidirSession()) assert task._config.type == TunnelType.HTTPBIDIRSERVER def test_has_spoofed_host(self): task = HTTPBidirServerTask( _make_bidir_def(spoofed_host="site.i2p"), MockBidirSession() ) assert task._spoofed_host == "site.i2p"