diff options
| author | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-18 23:06:03 -0500 |
|---|---|---|
| committer | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-18 23:06:03 -0500 |
| commit | d1db0051e3440f5ef4a7c9751eb8008f0ac7045a (patch) | |
| tree | b0e77cc7b2574dfc3836560b015ff5eb13583c85 /proxy/code/scripts | |
| parent | b78b3ce2451ca6d12ed65677ea63e7ee5e60041a (diff) | |
| download | candlepin-d1db0051e3440f5ef4a7c9751eb8008f0ac7045a.tar.gz candlepin-d1db0051e3440f5ef4a7c9751eb8008f0ac7045a.tar.xz candlepin-d1db0051e3440f5ef4a7c9751eb8008f0ac7045a.zip | |
uploading and get of sat cert
Diffstat (limited to 'proxy/code/scripts')
| -rwxr-xr-x | proxy/code/scripts/test-certificateapi.py | 22 |
1 files changed, 15 insertions, 7 deletions
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)) |
