04-backend_headers.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from pathlib import Path
  2. from proxytester.main import BaseProxyTest, ProxyConfig
  3. class FailHeaderBackendTest(BaseProxyTest):
  4. """A test to check the headers received by the backend.
  5. This test should fail
  6. """
  7. def __init__(self):
  8. super().__init__()
  9. self.description = "Backend headers check (Fail)"
  10. # We send an header but expect another one on the backend
  11. self.headers = {
  12. "X-Test-1": "1234",
  13. }
  14. self.expected_backend_headers = {
  15. "x-test-2": "abcd",
  16. }
  17. self.proxy_config = ProxyConfig(
  18. binary_path=Path.home() / "bin/haproxy"
  19. )
  20. async def run_test(self):
  21. await self.make_request()
  22. return True
  23. class PassHeaderBackendTest(BaseProxyTest):
  24. """A test to check the headers received by the backend.
  25. """
  26. def __init__(self):
  27. super().__init__()
  28. self.description = "Backend headers check (Pass)"
  29. self.headers = {
  30. "X-Test-1": "abcd",
  31. }
  32. self.expected_backend_headers = {
  33. "x-test-1": "abcd",
  34. }
  35. self.proxy_config = ProxyConfig(
  36. binary_path=Path.home() / "bin/haproxy"
  37. )
  38. async def run_test(self):
  39. await self.make_request()
  40. return True