From d1db0051e3440f5ef4a7c9751eb8008f0ac7045a Mon Sep 17 00:00:00 2001 From: "jesus m. rodriguez" Date: Wed, 18 Nov 2009 23:06:03 -0500 Subject: uploading and get of sat cert --- proxy/code/scripts/test-certificateapi.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'proxy/code/scripts') diff --git a/proxy/code/scripts/test-certificateapi.py b/proxy/code/scripts/test-certificateapi.py index 94b33de..bae8dc5 100755 --- a/proxy/code/scripts/test-certificateapi.py +++ b/proxy/code/scripts/test-certificateapi.py @@ -5,27 +5,35 @@ import sys import simplejson as json import base64 +# read and encode the cert cert = open('spacewalk-public.cert', 'rb').read() encoded_cert = base64.b64encode(cert) -print(encoded_cert) -# GET candlepin user +# GET see if there's a certificate response = urllib.urlopen('http://localhost:8080/candlepin/certificate') rsp = response.read() print("get: %s" % rsp) +#""" +# POST upload a certificate +print("upload certificate") + params = {"base64cert":encoded_cert} headers = {"Content-type":"application/json", "Accept": "application/json"} -# POST new user -print("create consumer") conn = httplib.HTTPConnection("localhost", 8080) -#conn.request("POST", '/candlepin/certificate/', json.dumps(params), headers) +print("encoded cert: %s" % encoded_cert) conn.request("POST", '/candlepin/certificate/', json.dumps(encoded_cert), headers) response = conn.getresponse() print("Status: %d Response: %s" % (response.status, response.reason)) rsp = response.read() -print("created consumer: %s" % rsp) +print("uploaded certificate: %s" % rsp) conn.close() - +#""" +# GET see if there's a certificate +response = urllib.urlopen('http://localhost:8080/candlepin/certificate') +rsp = response.read() +print("------------") +#print(rsp) +print(base64.standard_b64decode(rsp)) -- cgit