|
|
9 months ago | |
|---|---|---|
| example_tests | 9 months ago | |
| .gitignore | 9 months ago | |
| COPYING | 9 months ago | |
| Makefile | 9 months ago | |
| README.md | 9 months ago |
A simple Python tool to test reverse proxy configuration
pip install .
httphound --test-dir example_tests/
Each test is defined as Python class inheriting from BaseProxyTest
from httphound.main import BaseProxyTest, BackendConfig, ProxyConfig
class BasicGetTest(BaseProxyTest):
def __init__(self):
super().__init__()
self.description = "Basic GET request"
self.url = "http://localhost:4242/"
self.method = "GET"
self.expected_status = 200
self.proxy_config = ProxyConfig(
binary_path="/home/fixed/bin/haproxy-bookworm"
)
self.backend_config = BackendConfig(
host="127.0.0.1",
port=4243,
response_body="Hello",
response_headers={"X-Test":"test-backend"},
)
async def run_test(self):
await self.make_request()
return True
When writing tests it can be useful to immediately check some common patterns, eg. if headers are received or not by the client or the backend.
For this, the BaseProxyTest and it's children accepts some parameters that are used when response is received. See the BaseProxyTest class docstring for more information on how to use them.
pip install -e . and start adding features/fix bugs!