diff options
author | Devan Goodwin <dgoodwin@redhat.com> | 2009-12-05 13:36:00 -0400 |
---|---|---|
committer | Devan Goodwin <dgoodwin@redhat.com> | 2009-12-05 13:36:00 -0400 |
commit | 1bee200575dda5cf1b41bf879f79471e47311740 (patch) | |
tree | f09a2c6debbe8293286ca317b7bb70eda67a054f /proxy/code/src/org/fedoraproject/candlepin/resource | |
parent | 0a1e68069524f42adc7539f8c94d5fbc7423c00a (diff) | |
download | candlepin-1bee200575dda5cf1b41bf879f79471e47311740.tar.gz candlepin-1bee200575dda5cf1b41bf879f79471e47311740.tar.xz candlepin-1bee200575dda5cf1b41bf879f79471e47311740.zip |
Start testing the CertificateResource.
Diffstat (limited to 'proxy/code/src/org/fedoraproject/candlepin/resource')
3 files changed, 81 insertions, 9 deletions
diff --git a/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java b/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java index e4e5138..fdfcc45 100644 --- a/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java +++ b/proxy/code/src/org/fedoraproject/candlepin/resource/CertificateResource.java @@ -91,15 +91,7 @@ public class CertificateResource extends BaseResource { return "uuid"; } - private String createString(byte[] bytes) { - StringBuffer buf = new StringBuffer(); - for (byte b : bytes) { - buf.append((char) Integer.parseInt(Integer.toHexString(b), 16)); - } - - return buf.toString(); - } - + @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public String get() { diff --git a/proxy/code/src/org/fedoraproject/candlepin/resource/test/CertificateResourceTest.java b/proxy/code/src/org/fedoraproject/candlepin/resource/test/CertificateResourceTest.java new file mode 100644 index 0000000..99751eb --- /dev/null +++ b/proxy/code/src/org/fedoraproject/candlepin/resource/test/CertificateResourceTest.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2009 Red Hat, Inc. + * + * This software is licensed to you under the GNU General Public License, + * version 2 (GPLv2). There is NO WARRANTY for this software, express or + * implied, including the implied warranties of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 + * along with this software; if not, see + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + * + * Red Hat trademarks are not licensed under GPLv2. No permission is + * granted to use or replicate Red Hat trademarks that are incorporated + * in this software or its documentation. + */ + +package org.fedoraproject.candlepin.resource.test; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.fedoraproject.candlepin.model.Product; +import org.fedoraproject.candlepin.resource.CertificateResource; +import org.fedoraproject.candlepin.test.DatabaseTestFixture; +import org.fedoraproject.candlepin.test.TestUtil; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +public class CertificateResourceTest extends DatabaseTestFixture { + + private CertificateResource certResource; + private String sampleCertXml; + + @Before + public void createObjects() throws Exception { + certResource = new CertificateResource(); + + InputStream is = this.getClass().getResourceAsStream( + "/org/fedoraproject/candlepin/resource/test/spacewalk-public.cert"); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder builder = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + builder.append(line + "\n"); + } + sampleCertXml = builder.toString(); + } + + @Test + public void simpleUploadCertProductsCreated() { + certResource.upload(TestUtil.xmlToBase64String(sampleCertXml)); + // TODO: check that products got created! + } + + +} diff --git a/proxy/code/src/org/fedoraproject/candlepin/resource/test/spacewalk-public.cert b/proxy/code/src/org/fedoraproject/candlepin/resource/test/spacewalk-public.cert new file mode 100644 index 0000000..4d63ab3 --- /dev/null +++ b/proxy/code/src/org/fedoraproject/candlepin/resource/test/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> |