diff options
Diffstat (limited to 'proxy/code/scripts/test-userapi.py')
-rwxr-xr-x | proxy/code/scripts/test-userapi.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/proxy/code/scripts/test-userapi.py b/proxy/code/scripts/test-userapi.py index 0851a6e..89c1a1f 100755 --- a/proxy/code/scripts/test-userapi.py +++ b/proxy/code/scripts/test-userapi.py @@ -2,9 +2,21 @@ import httplib, urllib import sys +import simplejson as json -# GET candlepin user -response = urllib.urlopen('http://localhost:8080/candlepin/user/candlepin') +# POST new user +params = {"login":"testapi","password":"sw3etnothings"} +headers = {"Content-type":"application/json", + "Accept": "application/json"} +conn = httplib.HTTPConnection("localhost", 8080) +conn.request("POST", '/candlepin/user/', json.dumps(params), headers) +response = conn.getresponse() +print("Status: %d Response: %s" % (response.status, response.reason)) +rsp = response.read() +conn.close() + +# GET testapi user +response = urllib.urlopen('http://localhost:8080/candlepin/user/testapi') rsp = response.read() print("get: %s" % rsp) |