diff options
Diffstat (limited to 'proxy/code/scripts/test-userapi.py')
-rwxr-xr-x | proxy/code/scripts/test-userapi.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/proxy/code/scripts/test-userapi.py b/proxy/code/scripts/test-userapi.py index 89c1a1f..fc4c8f7 100755 --- a/proxy/code/scripts/test-userapi.py +++ b/proxy/code/scripts/test-userapi.py @@ -5,16 +5,18 @@ import sys import simplejson as json # POST new user -params = {"login":"testapi","password":"sw3etnothings"} +params = urllib.urlencode({"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) +print("params: %s" % json.dumps(params)) +conn.request("POST", '/candlepin/user/', 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() @@ -23,4 +25,7 @@ print("get: %s" % rsp) # GET list of users response = urllib.urlopen('http://localhost:8080/candlepin/user/') rsp = response.read() -print("list of users: %s" % rsp) +users = json.loads(rsp) +print("list of users ----------------") +for user in users['user']: + print(user) |