Task 14 - E2E Integration Test

Status

Completed 2026-03-29

What was added

  • locomotive/tests/integration_test.rs — end-to-end HTTP proxy pipeline test

Test wiring

  1. Upstream TcpListener binds to a random port (simulates real backend)
  2. TcpSource binds as proxy listener
  3. Client sends HTTP request with User-Agent: curl/7.0
  4. Proxy: TcpSource::accept HttpParser::parse stream HttpPipeline::process TcpDestination::write
  5. On first routing frame (is_routing_frame() == true), calls dest.provide_with_addr(&upstream_addr) to establish upstream TCP connection
  6. Upstream receives the rewritten request with User-Agent: railscale/1.0

Key patterns

  • pin!() macro used to pin the frames stream for StreamExt::next
  • ParsedData::Passthrough vs ParsedData::Parsed arms handled separately
  • HttpPipeline::new(matchers) with Finder::new(b”User-Agent”) matcher replaces header value in-place
  • provide_with_addr called exactly once, guarded by routed flag

Assertions verified

  • GET / HTTP/1.1 present
  • Host: example.com present
  • User-Agent: railscale/1.0 present
  • curl/7.0 absent

Result

Test passes: 1 passed, 0 failed