summaryrefslogtreecommitdiff
path: root/tests/endpoints.py
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2020-05-30 19:49:56 -0400
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2020-05-30 19:49:56 -0400
commitc2f1e1096f602b1cbd4531352f3e1ea6d656a186 (patch)
treeae102982878bb0c31bdfe07209e60bfc14030490 /tests/endpoints.py
parent095c2640aa2070ed4e2765875238d5e6e6673856 (diff)
parent5a0b639dfbd7db9d16c6995f72ba17152a1f362d (diff)
Merge branch 'upstream' into dfsg_clean20200209+dfsgdfsg_clean
Diffstat (limited to 'tests/endpoints.py')
-rwxr-xr-xtests/endpoints.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/endpoints.py b/tests/endpoints.py
new file mode 100755
index 00000000..8dc5abef
--- /dev/null
+++ b/tests/endpoints.py
@@ -0,0 +1,30 @@
+#!/usr/bin/python3
+
+import sys
+import json
+import time
+import subprocess
+import urllib.request
+import urllib.parse
+import os
+
+def main():
+ prefix = 'http://localhost:8080/'
+
+ with open('/tmp/endpoints.json') as json_data:
+ data = json.load(json_data)
+ endpoints = data['endpoints']
+ for ep in endpoints:
+ path = ep['url']
+ src = urllib.parse.urljoin(prefix, path)
+ if ep['method'] == 'GET':
+ contents = urllib.request.urlopen(src).read()
+ # it's okay that we can retrieve it, enough for us right now
+ else:
+ # TODO: add support for parameters?
+ post_fields = {'Nam': 'X', 'Msg': 'message', 'Sameday': 'on'} # Set POST fields here
+ request = urllib.request.Request(src, urllib.parse.urlencode(post_fields).encode())
+ contents = urllib.request.urlopen(request).read().decode()
+
+if __name__ == '__main__':
+ main()