| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- from pathlib import Path
- from httphound.main import BaseProxyTest, BackendConfig, ProxyConfig
- class FailHeaderCheck(BaseProxyTest):
- """Minimal test to demonstrate the basic header checks functionality
- This test should fail as the backend or the reverse proxy aren't configured
- to answer this header.
- """
- def __init__(self):
- super().__init__()
- self.description = "Client custom header (Fail)"
- self.url = "http://localhost:4242/"
- # expected_headers must match with the headers received by
- # the client or will fail
- self.expected_headers = {
- "x-test": "1234",
- }
- self.proxy_config = ProxyConfig(
- binary_path=Path.home() / "bin/haproxy"
- )
- # def run_test(self):
- # self.make_request()
- # return True
- class PassHeaderCheck(BaseProxyTest):
- """Minimal test to demonstrate the basic header checks functionality
- This test should succeed.
- """
- def __init__(self):
- super().__init__()
- self.description = "Client custom header (Pass)"
- self.url = "http://localhost:4242/"
- # expected_headers must match with the headers received by
- # the client or will fail
- self.expected_headers = {
- "x-test": "1234",
- }
- self.proxy_config = ProxyConfig(
- binary_path=Path.home() / "bin/haproxy"
- )
- # Defining a backend configuration with headers
- # to answer to the client
- self.backend_config = BackendConfig(
- response_headers={"X-Test": "1234"},
- )
- # def run_test(self):
- # """The run_test() method is always the same as all logic
- # is defined entirely in the classes configuration.
- # """
- # self.make_request()
- # return True
|