summaryrefslogtreecommitdiffstats
path: root/proxy/code
diff options
context:
space:
mode:
authorjesus m. rodriguez <jesusr@redhat.com>2009-11-18 21:58:14 -0500
committerjesus m. rodriguez <jesusr@redhat.com>2009-11-18 21:58:14 -0500
commitb78b3ce2451ca6d12ed65677ea63e7ee5e60041a (patch)
tree50d8f3d6b70a043a60d44a0773c41a457b89ff55 /proxy/code
parent0b6e5469af00e30a11370d6a9402d59d9e74c2df (diff)
downloadcandlepin-b78b3ce2451ca6d12ed65677ea63e7ee5e60041a.tar.gz
candlepin-b78b3ce2451ca6d12ed65677ea63e7ee5e60041a.tar.xz
candlepin-b78b3ce2451ca6d12ed65677ea63e7ee5e60041a.zip
remove unused test-connection, fix userapi
Diffstat (limited to 'proxy/code')
-rwxr-xr-xproxy/code/scripts/test-connection.py42
-rwxr-xr-xproxy/code/scripts/test-userapi.py11
-rw-r--r--proxy/code/src/org/fedoraproject/candlepin/resource/UserResource.java7
3 files changed, 13 insertions, 47 deletions
diff --git a/proxy/code/scripts/test-connection.py b/proxy/code/scripts/test-connection.py
deleted file mode 100755
index 0aaca74..0000000
--- a/proxy/code/scripts/test-connection.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/python
-
-import httplib, urllib
-import sys
-
-if len(sys.argv) < 1:
- print("please supply a message")
- sys.exit(1)
-
-param = sys.argv[1]
-
-params = urllib.urlencode({'message':sys.argv[1]})
-headers = {"Content-type":"application/x-www-form-urlencoded",
- "Accept": "application/json"}
-conn = httplib.HTTPConnection("localhost", 8080)
-conn.request("POST", '/candlepin/helloworld', params, headers)
-#response = conn.getresponse()
-#print response.status, response.reason
-#rsp = response.read()
-conn.close()
-#print rsp
-
-# test creating org
-params = urllib.urlencode({'name':'test-org-client-created-' + param})
-conn.request("POST", '/candlepin/org', params, headers)
-response = conn.getresponse()
-print response.status, response.reason
-rsp = response.read()
-print(rsp)
-
-# test creating consumer
-params = urllib.urlencode({'name':'test-consumer-client-created-' + param})
-conn.request("POST", '/candlepin/consumer', params, headers)
-response = conn.getresponse()
-print response.status, response.reason
-rsp = response.read()
-print(rsp)
-
-response = urllib.urlopen('http://localhost:8080/candlepin/consumer/list')
-rsp = response.read()
-print(rsp)
-
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)
diff --git a/proxy/code/src/org/fedoraproject/candlepin/resource/UserResource.java b/proxy/code/src/org/fedoraproject/candlepin/resource/UserResource.java
index e41744f..040cc98 100644
--- a/proxy/code/src/org/fedoraproject/candlepin/resource/UserResource.java
+++ b/proxy/code/src/org/fedoraproject/candlepin/resource/UserResource.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -76,9 +77,11 @@ public class UserResource extends BaseResource {
* @return User
*/
@POST
- @Consumes(MediaType.APPLICATION_JSON)
+ @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
- public User create(String login, String password) {
+ public User create(@FormParam("login") String login, @FormParam("password") String password) {
+ System.out.println("login: " + login);
+ System.out.println("password: " + password);
String newuuid = BaseModel.generateUUID();
User u = new User(newuuid);
u.setLogin(login);