summaryrefslogtreecommitdiffstats
path: root/proxy/code/scripts/test-userapi.py
diff options
context:
space:
mode:
authorjesus m. rodriguez <jesusr@redhat.com>2009-07-31 13:33:56 -0400
committerjesus m. rodriguez <jesusr@redhat.com>2009-08-27 15:42:08 -0400
commitbf9e1bdf9bb0d3498259b8ac183b3365f935eabe (patch)
treee06da23d0628a8aa55634e4be75faeab452aea01 /proxy/code/scripts/test-userapi.py
parentc814a67b6c67a43e920975fdd6e66b42fe3fbab5 (diff)
downloadcandlepin-bf9e1bdf9bb0d3498259b8ac183b3365f935eabe.tar.gz
candlepin-bf9e1bdf9bb0d3498259b8ac183b3365f935eabe.tar.xz
candlepin-bf9e1bdf9bb0d3498259b8ac183b3365f935eabe.zip
use json instead of a string
Diffstat (limited to 'proxy/code/scripts/test-userapi.py')
-rwxr-xr-xproxy/code/scripts/test-userapi.py16
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)