diff options
author | paulrbr-fl <43074087+paulrbr-fl@users.noreply.github.com> | 2020-10-14 10:27:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-14 10:27:09 +0200 |
commit | 9c9fe5d8071afd657e57a6c11f60e275c2261246 (patch) | |
tree | 83eb5c10f9a792a1b5fc8e88a4a1ed675eb13490 /tests/kong.py | |
parent | 2e423637ee780bd273094ad52e49906100724d08 (diff) | |
parent | 1443410095d3b4a2a560997e8a0662a1deed1d57 (diff) | |
download | ansible-kong-app-9c9fe5d8071afd657e57a6c11f60e275c2261246.tar.gz ansible-kong-app-9c9fe5d8071afd657e57a6c11f60e275c2261246.tar.zst ansible-kong-app-9c9fe5d8071afd657e57a6c11f60e275c2261246.zip |
Merge pull request #23 from paulrbr-fl/use-put-for-idempotency
Use PUT methods instead of manually detecting if new or update
Diffstat (limited to 'tests/kong.py')
-rwxr-xr-x | tests/kong.py | 9 |
1 files changed, 9 insertions, 0 deletions
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 @@ | |||
1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
2 | 2 | ||
3 | from http.server import HTTPServer, CGIHTTPRequestHandler | 3 | from http.server import HTTPServer, CGIHTTPRequestHandler |
4 | import random | ||
4 | 5 | ||
5 | class SimpleHTTPRequestHandler(CGIHTTPRequestHandler): | 6 | class SimpleHTTPRequestHandler(CGIHTTPRequestHandler): |
6 | def do_GET(self): | 7 | def do_GET(self): |
@@ -17,6 +18,14 @@ class SimpleHTTPRequestHandler(CGIHTTPRequestHandler): | |||
17 | self.end_headers() | 18 | self.end_headers() |
18 | self.wfile.write(b'Hello, world!') | 19 | self.wfile.write(b'Hello, world!') |
19 | 20 | ||
21 | def do_PUT(self): | ||
22 | if bool(random.getrandbits(1)): | ||
23 | self.send_response(200) | ||
24 | else: | ||
25 | self.send_response(201) | ||
26 | self.end_headers() | ||
27 | self.wfile.write(b'Hello, world!') | ||
28 | |||
20 | 29 | ||
21 | httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler) | 30 | httpd = HTTPServer(('127.0.0.1', 8000), SimpleHTTPRequestHandler) |
22 | httpd.serve_forever() | 31 | httpd.serve_forever() |