Browse Source

Test for multiple requests

Fabrizio Furnari 8 months ago
parent
commit
c36118b3fd
1 changed files with 27 additions and 0 deletions
  1. 27 0
      example_tests/09-basic-logic.py

+ 27 - 0
example_tests/09-basic-logic.py

@@ -0,0 +1,27 @@
+from pathlib import Path
+from httphound.main import BaseProxyTest, BackendConfig, ProxyConfig
+
+class ExampleLogicTest(BaseProxyTest):
+    """Test to demonstrate how to use internal variable to perform some
+    actions.
+    """
+
+    def __init__(self):
+        super().__init__()
+        self.description = "Example logic test"
+        self.proxy_config = ProxyConfig(
+            binary_path=Path.home() / "bin/haproxy"
+        )
+
+    async def run_test(self):
+        # Perform 2 requests with different headers
+        self.headers = {"X-Test": "1234"}
+        res1 = await self.make_request()
+        print(f"Response 1 {res1}")
+        # Check headers received by the backend
+        print(self.backend.received_headers)
+        self.headers = {"X-Another": "abcd"}
+        res2 = await self.make_request()
+        print(f"Response 2 {res2}")
+        print(self.backend.received_headers)
+        return True