diff options
| author | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-11 17:30:03 -0500 |
|---|---|---|
| committer | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-11 17:30:03 -0500 |
| commit | e48a7b6b049e398fb6439372bd2510b592e2ab05 (patch) | |
| tree | ad2b318fabae9f93bbc56eea34bcdcbaf1ad00ec /proxy/code/scripts | |
| parent | e372d8ad99ea9b2bbfb20e711c3faf906c2b0ef8 (diff) | |
| download | candlepin-e48a7b6b049e398fb6439372bd2510b592e2ab05.tar.gz candlepin-e48a7b6b049e398fb6439372bd2510b592e2ab05.tar.xz candlepin-e48a7b6b049e398fb6439372bd2510b592e2ab05.zip | |
allow upload of a certificate
Diffstat (limited to 'proxy/code/scripts')
| -rw-r--r-- | proxy/code/scripts/spacewalk-public.cert | 23 | ||||
| -rwxr-xr-x | proxy/code/scripts/test-certificateapi.py | 31 |
2 files changed, 54 insertions, 0 deletions
diff --git a/proxy/code/scripts/spacewalk-public.cert b/proxy/code/scripts/spacewalk-public.cert new file mode 100644 index 0000000..4d63ab3 --- /dev/null +++ b/proxy/code/scripts/spacewalk-public.cert @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rhn-cert version="0.1"> + <rhn-cert-field name="product">SPACEWALK-001</rhn-cert-field> + <rhn-cert-field name="owner">Spacewalk Public Cert</rhn-cert-field> + <rhn-cert-field name="issued">2007-07-13 00:00:00</rhn-cert-field> + <rhn-cert-field name="expires">2010-07-13 00:00:00</rhn-cert-field> + <rhn-cert-field name="slots">20000</rhn-cert-field> + <rhn-cert-field name="monitoring-slots">20000</rhn-cert-field> + <rhn-cert-field name="provisioning-slots">20000</rhn-cert-field> + <rhn-cert-field name="virtualization_host">20000</rhn-cert-field> + <rhn-cert-field name="virtualization_host_platform">20000</rhn-cert-field> + <rhn-cert-field name="satellite-version">spacewalk</rhn-cert-field> + <rhn-cert-field name="generation">2</rhn-cert-field> + <rhn-cert-signature> +-----BEGIN PGP SIGNATURE----- +Version: Crypt::OpenPGP 1.03 + +iQBGBAARAwAGBQJIUsb7AAoJEJ5yna8GlHkyi50Anjh4/GHHPoOUKO6LdDaE2ZcJ +X69tAJ41s97D66gXGvk244vkmSMajJT2hg== +=oOTl +-----END PGP SIGNATURE----- +</rhn-cert-signature> +</rhn-cert> diff --git a/proxy/code/scripts/test-certificateapi.py b/proxy/code/scripts/test-certificateapi.py new file mode 100755 index 0000000..94b33de --- /dev/null +++ b/proxy/code/scripts/test-certificateapi.py @@ -0,0 +1,31 @@ +#!/usr/bin/python + +import httplib, urllib +import sys +import simplejson as json +import base64 + +cert = open('spacewalk-public.cert', 'rb').read() +encoded_cert = base64.b64encode(cert) +print(encoded_cert) + +# GET candlepin user +response = urllib.urlopen('http://localhost:8080/candlepin/certificate') +rsp = response.read() +print("get: %s" % rsp) + +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) +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) +conn.close() + |
