From 1443410095d3b4a2a560997e8a0662a1deed1d57 Mon Sep 17 00:00:00 2001 From: Paul Bonaud Date: Mon, 12 Oct 2020 17:31:15 +0200 Subject: tests: allow fake Kong server to receive PUT requests --- tests/kong.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/kong.py') diff --git a/tests/kong.py b/tests/kong.py index a1f9cec..c39542f 100755 --- a/tests/kong.py +++ b/tests/kong.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from http.server import HTTPServer, CGIHTTPRequestHandler +import random class SimpleHTTPRequestHandler(CGIHTTPRequestHandler): def do_GET(self): @@ -17,6 +18,14 @@ class SimpleHTTPRequestHandler(CGIHTTPRequestHandler): self.end_headers() self.wfile.write(b'Hello, world!') + def do_PUT(self): + if bool(random.getrandbits(1)): + self.send_response(200) + else: + self.send_response(201) + self.end_headers() + self.wfile.write(b'Hello, world!') + httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler) httpd.serve_forever() -- cgit v1.2.3