07-multiple_fail.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from pathlib import Path
  2. from httphound.main import BaseProxyTest, BackendConfig, ProxyConfig
  3. class FailExampleMultipleFailTest(BaseProxyTest):
  4. """A simple test to demonstrate multiple failures
  5. """
  6. def __init__(self):
  7. super().__init__()
  8. self.description = "Example multiple failures (Fail)"
  9. self.backend_config = BackendConfig(
  10. # Response headers, body and status are sent to the reverse proxy
  11. # at each request
  12. response_headers={
  13. "X-Test-1": "1234",
  14. "X-Test-2": "5678",
  15. },
  16. response_body="This is just a test body",
  17. response_status=301,
  18. )
  19. # This should fail
  20. self.expected_headers = {
  21. "x-test-2": "42",
  22. }
  23. # This should fail
  24. self.expected_status = 200
  25. # This should pass
  26. self.forbidden_client_headers = {
  27. "x-test-3": "abcd",
  28. }
  29. self.proxy_config = ProxyConfig(
  30. binary_path=Path.home() / "bin/haproxy"
  31. )
  32. async def run_test(self):
  33. await self.make_request()
  34. return True