Browse Source

Initial commit. README

Fabrizio Furnari 9 months ago
commit
73849b04ef
1 changed files with 77 additions and 0 deletions
  1. 77 0
      README.md

+ 77 - 0
README.md

@@ -0,0 +1,77 @@
+# ProxyTester
+
+A simple Python tool to test reverse proxy configuration
+
+## Features
+
+- **Tests defined as Python code**
+- **Automatic backend spawning** (if required)
+- **Reverse proxy config generation from template** (very simple)
+- **Reverse proxy spawning/management**
+- **Validate status code/headers/boxy received by the client**
+- **Validate status code/headers/boxy received by the backend**
+- **Report about passed/failed tests**
+
+## TODO
+
+- Additional variables in template generation
+- Better https errors management
+- Addidional checks (regex) for haproxy stdout logs (eg. variables)
+- Tests!
+
+## Installation
+
+```bash
+pip install .
+```
+
+## Usage
+
+1. Write basic tests as Python subclasses (see examples below)
+2. HAProxy binary must be present somewhere on the filesystem
+3. An HAProxy template must be present somewhere, or use the very basic one **haproxy.cfg.tpl**
+
+```bash
+proxytester --test-dir example_tests/
+```
+
+## Test Configuration Format
+
+Each test is defined as Python class inheriting from ``BaseProxyTest``
+
+```python
+from proxytester.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
+```
+
+## Useful parameters
+
+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.
+
+# Development
+
+- Install it as editable python package with `pip install -e .` and start adding features/fix bugs!