summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Likins <adrian@alikins.usersys.redhat.com>2010-01-12 13:50:42 -0500
committerAdrian Likins <adrian@alikins.usersys.redhat.com>2010-01-12 13:50:42 -0500
commit0b8cbae95b51b744d9779a1ed339277196482260 (patch)
tree49e2a20e0d8674871cd3179debc00f03b0cdbcd1
parentc8c40033cac251baa86b24fba7a663b1aefccea6 (diff)
downloadcandlepin-attr_model.tar.gz
candlepin-attr_model.tar.xz
candlepin-attr_model.zip
Add annotations for Attribute classattr_model
Add a test case for Attribute Make Product and EntitlementPool use the Attribute class
-rw-r--r--proxy/src/main/java/org/fedoraproject/candlepin/model/Attribute.java42
-rw-r--r--proxy/src/main/java/org/fedoraproject/candlepin/model/EntitlementPool.java6
-rw-r--r--proxy/src/main/java/org/fedoraproject/candlepin/model/Product.java5
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java82
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTest.java234
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTypeTest.java28
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/EntitlementPoolTest.java57
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ObjectFactoryTest.java100
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/OwnerTest.java128
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java130
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/UserTest.java45
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CandlepinTestingModule.java17
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CertificateResourceTest.java117
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ConsumerResourceTest.java88
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementMatcherTest.java59
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementResourceTest.java202
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/TestResourceTest.java94
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/UserResourceTest.java77
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/cert/test/CertTest.java284
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/spacewalk-public.cert23
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/test/DatabaseTestFixture.java187
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/test/TestUtil.java126
-rw-r--r--proxy/src/test/resources/certs/certificates.readme22
-rw-r--r--proxy/src/test/resources/certs/rest_api_test.jksbin0 -> 2001 bytes
-rw-r--r--proxy/src/test/resources/certs/rest_client_test.p12bin0 -> 1840 bytes
-rw-r--r--proxy/src/test/resources/certs/server.xml147
-rw-r--r--rel-eng/tito.props3
27 files changed, 2294 insertions, 9 deletions
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/model/Attribute.java b/proxy/src/main/java/org/fedoraproject/candlepin/model/Attribute.java
index 0952206..16df2fb 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/model/Attribute.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/model/Attribute.java
@@ -15,10 +15,46 @@
package org.fedoraproject.candlepin.model;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.SequenceGenerator;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ *
+ *
+ * Attributes can be thought of as a hint on some restriction on the usage of an entitlement.
+ * They will not actually contain the logic on how to enforce the Attribute, but basically just act as a constant the policy rules can look for, and a little metadata that may be required to enforce.
+ * Attributes can be affiliated with a given product in the product database, or they can be affiliated with entitlements granted within a particular customer's order/certificate.
+ * All Attributes must pass for the entitlement to be granted to a consumer. Not sure if this statement will stand the test of time, may be some issues here with "enabling" attributes vs "restricting" attributes and knowing when to grant/not grant based on the outcome of multiple checks. Will see how it goes.
+ * Attributes can be associated with a product, or more commonly with an order of that product contained in the cert. For us, this probably means they'll be associated with entitlement pools in the database.
+ * o If the same Attribute is found on both the product and the entitlement pool, the entitlement pool's version can be assumed as the authoritative one to check.
+ */
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+@Entity
+@Table(name = "cp_attribute")
+@SequenceGenerator(name="seq_attribute", sequenceName="seq_attribute", allocationSize=1)
public class Attribute {
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_attribute")
+ private Long id;
+
+
+ @Column(nullable = false)
private String name;
- private String quantity;
+
+ @Column(nullable = false)
+ private Long quantity;
public String getName() {
return name;
@@ -28,11 +64,11 @@ public class Attribute {
this.name = name;
}
- public String getQuantity() {
+ public Long getQuantity() {
return quantity;
}
- public void setQuantity(String quantity) {
+ public void setQuantity(Long quantity) {
this.quantity = quantity;
}
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/model/EntitlementPool.java b/proxy/src/main/java/org/fedoraproject/candlepin/model/EntitlementPool.java
index a10a620..2edc8a7 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/model/EntitlementPool.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/model/EntitlementPool.java
@@ -24,6 +24,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -72,7 +74,9 @@ public class EntitlementPool implements Persisted {
@Column(nullable = false)
private Date endDate;
- @Transient
+ @OneToMany
+// @ForeignKey(name = "fk_entitlement_pool_attribute")
+ @JoinColumn(name = "attribute_id")
private Set<Attribute> attributes;
public EntitlementPool() {
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/model/Product.java b/proxy/src/main/java/org/fedoraproject/candlepin/model/Product.java
index 183a4b9..be179d3 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/model/Product.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/model/Product.java
@@ -28,7 +28,6 @@ import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
-import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@@ -66,7 +65,9 @@ public class Product implements Persisted {
inverseJoinColumns = @JoinColumn(name = "CHILD_PRODUCT_ID"))
private Set<Product> childProducts;
- @Transient
+
+ @OneToMany
+ @JoinColumn(name = "attribute_id")
private Set<Attribute> attributes;
/**
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java
new file mode 100644
index 0000000..fbcb191
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/CertificateTest.java
@@ -0,0 +1,82 @@
+/**
+ * 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.model.test;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.fedoraproject.candlepin.model.Certificate;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+public class CertificateTest extends DatabaseTestFixture {
+
+ @Before
+ public void setUpTestObjects() {
+
+ String ownerName = "Example Corporation";
+ Owner owner = new Owner(ownerName);
+
+ ownerCurator.create(owner);
+ certificateCurator.create(
+ new Certificate("This is not actually a certificate. No entitlements for you!", owner));
+ }
+
+
+ @Ignore
+ public void testGetCertificate() {
+ Certificate newCertificate = new Certificate();
+ }
+
+ @Test
+ public void testList() throws Exception {
+ List<Certificate> certificates = certificateCurator.findAll();
+ int beforeCount = certificates.size();
+
+ for (int i = 0; i < 10; i++) {
+ Owner owner = new Owner("owner" + i);
+ ownerCurator.create(owner);
+ certificateCurator.create(new Certificate("this is a test", owner));
+ }
+
+ certificates = certificateCurator.findAll();
+ int afterCount = certificates.size();
+ assertEquals(10, afterCount - beforeCount);
+ }
+
+ @Test
+ public void testLookup() throws Exception {
+
+ Owner owner = new Owner("test company");
+ Certificate certificate = new Certificate("not a cert", owner);
+
+ ownerCurator.create(owner);
+ certificateCurator.create(certificate);
+
+ Certificate lookedUp = certificateCurator.find(certificate.getId());
+
+ assertEquals(certificate.getId(), lookedUp.getId());
+ assertEquals(certificate.getCertificate(), lookedUp.getCertificate());
+ }
+}
+
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTest.java
new file mode 100644
index 0000000..da34e5b
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTest.java
@@ -0,0 +1,234 @@
+/**
+ * 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.model.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import javax.persistence.PersistenceException;
+
+import org.fedoraproject.candlepin.model.Consumer;
+import org.fedoraproject.candlepin.model.ConsumerFact;
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.Entitlement;
+import org.fedoraproject.candlepin.model.EntitlementPool;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.fedoraproject.candlepin.test.TestUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+
+
+public class ConsumerTest extends DatabaseTestFixture {
+
+ private Owner owner;
+ private Product rhel;
+ private Product jboss;
+ private Consumer consumer;
+ private ConsumerType consumerType;
+ private static final String CONSUMER_TYPE_NAME = "test-consumer-type";
+ private static final String CONSUMER_NAME = "Test Consumer";
+
+ @Before
+ public void setUpTestObjects() {
+ owner = new Owner("Example Corporation");
+ rhel = new Product("rhel", "Red Hat Enterprise Linux");
+ jboss = new Product("jboss", "JBoss");
+
+ ownerCurator.create(owner);
+ productCurator.create(rhel);
+ productCurator.create(jboss);
+
+ consumerType = new ConsumerType(CONSUMER_TYPE_NAME);
+ consumerTypeCurator.create(consumerType);
+ consumer = new Consumer(CONSUMER_NAME, owner, consumerType);
+ consumer.setMetadataField("foo", "bar");
+ consumer.setMetadataField("foo1", "bar1");
+ consumer.addConsumedProduct(rhel);
+ consumer.addConsumedProduct(jboss);
+ consumerCurator.create(consumer);
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void testConsumerTypeRequired() {
+ Consumer newConsumer = new Consumer();
+ newConsumer.setName("cname");
+ newConsumer.setOwner(owner);
+
+ consumerCurator.create(newConsumer);
+ }
+
+ @Test
+ public void testLookup() throws Exception {
+ Consumer lookedUp = consumerCurator.find(consumer.getId());
+ assertEquals(consumer.getId(), lookedUp.getId());
+ assertEquals(consumer.getName(), lookedUp.getName());
+ assertEquals(consumer.getType().getLabel(), lookedUp.getType().getLabel());
+ assertNotNull(consumer.getUuid());
+ }
+
+ @Test
+ public void testInfo() {
+ Consumer lookedUp = consumerCurator.find(consumer.getId());
+ Map<String, String> metadata = lookedUp.getInfo().getMetadata();
+ assertEquals(2, metadata.keySet().size());
+ assertEquals("bar", metadata.get("foo"));
+ assertEquals("bar", lookedUp.getInfo().getMetadataField("foo"));
+ assertEquals("bar1", metadata.get("foo1"));
+ assertEquals("bar1", lookedUp.getInfo().getMetadataField("foo1"));
+ }
+
+ @Test
+ public void testMetadataInfo() {
+ Consumer consumer2 = new Consumer("consumer2", owner, consumerType);
+ consumer2.setMetadataField("foo", "bar2");
+ consumerCurator.create(consumer2);
+
+ Consumer lookedUp = consumerCurator.find(consumer.getId());
+ Map<String, String> metadata = lookedUp.getInfo().getMetadata();
+ assertEquals(2, metadata.keySet().size());
+ assertEquals("bar", metadata.get("foo"));
+ assertEquals("bar", lookedUp.getInfo().getMetadataField("foo"));
+ assertEquals("bar1", metadata.get("foo1"));
+ assertEquals("bar1", lookedUp.getInfo().getMetadataField("foo1"));
+ assertEquals(consumer.getId(), lookedUp.getInfo().getConsumer().getId());
+
+ Consumer lookedUp2 = consumerCurator.find(consumer2.getId());
+ metadata = lookedUp2.getInfo().getMetadata();
+ assertEquals(1, metadata.keySet().size());
+ assertEquals("bar2", metadata.get("foo"));
+ }
+
+ @Test
+ public void testModifyMetadata() {
+ consumer.setMetadataField("foo", "notbar");
+ consumerCurator.update(consumer);
+
+ Consumer lookedUp = consumerCurator.find(consumer.getId());
+ assertEquals("notbar", lookedUp.getMetadataField("foo"));
+ }
+
+ @Test
+ public void testMetadataDeleteCascading() {
+ Consumer attachedConsumer = consumerCurator.find(consumer.getId());
+ Long consumerInfoId = attachedConsumer.getInfo().getId();
+
+ assertNotNull((ConsumerFact)entityManager().find(ConsumerFact.class, consumerInfoId));
+
+ consumerCurator.delete(attachedConsumer);
+
+ assertNull((ConsumerFact)entityManager().find(ConsumerFact.class, consumerInfoId));
+ }
+
+ @Test
+ public void testConsumedProducts() {
+ entityManager().clear();
+ Consumer lookedUp = (Consumer)entityManager().find(Consumer.class, consumer.getId());
+ assertEquals(2, lookedUp.getConsumedProducts().size());
+ }
+
+ @Test
+ public void testRemoveConsumedProducts() {
+ consumerCurator.delete(consumerCurator.find(consumer.getId()));
+ assertNull(consumerCurator.find(consumer.getId()));
+ }
+
+ @Test
+ public void testConsumerHierarchy() {
+ Consumer child1 = new Consumer("child1", owner, consumerType);
+ child1.setMetadataField("foo", "bar");
+ consumerCurator.create(child1);
+
+ Consumer child2 = new Consumer("child2", owner, consumerType);
+ child2.setMetadataField("foo", "bar");
+ consumerCurator.create(child2);
+
+ consumer.addChildConsumer(child1);
+ consumer.addChildConsumer(child2);
+ consumerCurator.update(consumer);
+
+ Consumer lookedUp = consumerCurator.find(consumer.getId());
+ assertEquals(2, lookedUp.getChildConsumers().size());
+ }
+
+ @Test
+ public void testChildDeleteNoCascade() {
+ Consumer child1 = new Consumer("child1", owner, consumerType);
+ child1.setMetadataField("foo", "bar");
+ consumer.addChildConsumer(child1);
+ consumerCurator.update(consumer);
+
+ child1 = consumerCurator.find(child1.getId());
+ consumerCurator.delete(child1);
+
+ assertNull(consumerCurator.find(child1.getId()));
+
+ Consumer lookedUp = consumerCurator.find(consumer.getId());
+ assertEquals(0, lookedUp.getChildConsumers().size());
+ }
+
+ @Test
+ public void testParentDeleteCascadesToChildren() {
+ Consumer child1 = new Consumer("child1", owner, consumerType);
+ child1.setMetadataField("foo", "bar");
+ consumer.addChildConsumer(child1);
+ consumerCurator.update(consumer);
+
+ consumerCurator.delete(consumer);
+
+ assertNull(consumerCurator.find(consumer.getId()));
+ assertNull(consumerCurator.find(child1.getId()));
+ }
+
+ // This this looks like a stupid test but this was actually failing at one point. :)
+ @Test
+ public void testMultipleConsumersSameConsumedProduct() {
+ beginTransaction();
+
+ // Default consumer already consumes RHEL:
+ Consumer child1 = new Consumer("child1", owner, consumerType);
+ child1.setMetadataField("foo", "bar");
+ child1.addConsumedProduct(rhel);
+ entityManager().persist(child1);
+ commitTransaction();
+ }
+
+ @Test
+ public void testAddEntitlements() {
+ EntitlementPool pool = TestUtil.createEntitlementPool();
+ entityManager().persist(pool.getProduct());
+ entityManager().persist(pool.getOwner());
+ entityManager().persist(pool);
+
+ Entitlement e1 = TestUtil.createEntitlement(pool);
+ Entitlement e2 = TestUtil.createEntitlement(pool);
+ Entitlement e3 = TestUtil.createEntitlement(pool);
+ entityManager().persist(e1);
+ entityManager().persist(e2);
+ entityManager().persist(e3);
+
+ consumer.addEntitlement(e1);
+ consumer.addEntitlement(e2);
+ consumer.addEntitlement(e3);
+ consumerCurator.update(consumer);
+
+ Consumer lookedUp = consumerCurator.find(consumer.getId());
+ assertEquals(3, lookedUp.getEntitlements().size());
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTypeTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTypeTest.java
new file mode 100644
index 0000000..4974c46
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTypeTest.java
@@ -0,0 +1,28 @@
+package org.fedoraproject.candlepin.model.test;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.junit.Test;
+
+public class ConsumerTypeTest extends DatabaseTestFixture {
+
+ @Test
+ public void testSomething() {
+ beginTransaction();
+
+ ConsumerType ct = new ConsumerType("standard-system");
+ entityManager().persist(ct);
+
+ commitTransaction();
+
+ List<EntityManager> results = entityManager().createQuery("select ct from ConsumerType as ct")
+ .getResultList();
+ assertEquals(1, results.size());
+ }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/EntitlementPoolTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/EntitlementPoolTest.java
new file mode 100644
index 0000000..3279216
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/EntitlementPoolTest.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.model.test;
+
+import static org.junit.Assert.*;
+
+import org.fedoraproject.candlepin.model.EntitlementPool;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.fedoraproject.candlepin.test.TestUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class EntitlementPoolTest extends DatabaseTestFixture {
+
+ private EntitlementPool pool;
+ private Product prod;
+ private Owner owner;
+
+ @Before
+ public void createObjects() {
+ beginTransaction();
+
+ pool = TestUtil.createEntitlementPool();
+ owner = pool.getOwner();
+ prod = pool.getProduct();
+ entityManager().persist(owner);
+ entityManager().persist(prod);
+ entityManager().persist(pool);
+
+ commitTransaction();
+ }
+
+ @Test
+ public void testCreate() {
+ EntitlementPool lookedUp = (EntitlementPool)entityManager().find(EntitlementPool.class,
+ pool.getId());
+ assertNotNull(lookedUp);
+ assertEquals(owner.getId(), lookedUp.getOwner().getId());
+ assertEquals(prod.getId(), lookedUp.getProduct().getId());
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ObjectFactoryTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ObjectFactoryTest.java
new file mode 100644
index 0000000..5186fb6
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ObjectFactoryTest.java
@@ -0,0 +1,100 @@
+/**
+ * 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.model.test;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.fedoraproject.candlepin.model.ObjectFactory;
+import org.fedoraproject.candlepin.model.Owner;
+import org.junit.Test;
+
+/**
+ * ObjectFactoryTest
+ */
+public class ObjectFactoryTest {
+
+ @Test
+ public void testGet() {
+ ObjectFactory o1 = ObjectFactory.get();
+ ObjectFactory o2 = ObjectFactory.get();
+
+ assertNotNull(o1);
+ assertNotNull(o2);
+ assertEquals(o1, o2);
+ }
+
+ @Test
+ public void testListObjectsByClass() {
+ List<Object> l = ObjectFactory.get().listObjectsByClass(Object.class);
+ assertNotNull(l);
+ assertTrue(l.isEmpty());
+
+ l = ObjectFactory.get().listObjectsByClass(Owner.class);
+ assertNotNull(l);
+ assertFalse(l.isEmpty());
+ Object o = l.get(0);
+ assertNotNull(o);
+ assertEquals(o.getClass(), Owner.class);
+ }
+
+ @Test
+ public void testStore() {
+ // make sure we don't have one stored already
+ List<Object> list = ObjectFactory.get().listObjectsByClass(Long.class);
+ assertNotNull(list);
+ assertTrue(list.isEmpty());
+
+ Long l = new Long(10);
+ ObjectFactory.get().store(l);
+
+ // verify it got stored
+ list = ObjectFactory.get().listObjectsByClass(Long.class);
+ assertNotNull(list);
+ assertFalse(list.isEmpty());
+ Long l2 = (Long) list.get(0);
+ assertEquals(l, l2);
+ }
+
+// @Test
+// public void testLookupByUUID() {
+// String uuid = BaseModel.generateUUID();
+// assertNull(ObjectFactory.get().lookupByUUID(Owner.class, uuid));
+//
+// Owner owner = new Owner(uuid);
+// owner.setName("unit-test-owner");
+// ObjectFactory.get().store(owner);
+// Object o = ObjectFactory.get().lookupByUUID(Owner.class, uuid);
+// assertNotNull(o);
+// assertEquals(o.getClass(), Owner.class);
+// assertEquals(((Owner)o).getUuid(), owner.getUuid());
+// }
+
+// @Test
+// public void testLookupByFieldName() {
+// String uuid = BaseModel.generateUUID();
+// assertNull(ObjectFactory.get().lookupByUUID(Owner.class, uuid));
+//
+// Owner owner = new Owner(uuid);
+// owner.setName("unit-test-org");
+// ObjectFactory.get().store(owner);
+//
+// Owner o2 = (Owner) ObjectFactory.get().lookupByFieldName(
+// Owner.class, "uuid", uuid);
+// assertNotNull(o2);
+// assertEquals(owner, o2);
+// }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/OwnerTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/OwnerTest.java
new file mode 100644
index 0000000..f331d95
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/OwnerTest.java
@@ -0,0 +1,128 @@
+/**
+ * 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.model.test;
+
+import static org.junit.Assert.*;
+
+import org.fedoraproject.candlepin.model.Consumer;
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.EntitlementPool;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.model.User;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.fedoraproject.candlepin.test.TestUtil;
+import org.junit.Test;
+
+public class OwnerTest extends DatabaseTestFixture {
+
+ @Test
+ public void testCreate() throws Exception {
+ String ownerName = "Example Corporation";
+ Owner o = new Owner(ownerName);
+ ownerCurator.create(o);
+
+ Owner result = (Owner)entityManager().createQuery(
+ "select o from Owner o where o.name = :name")
+ .setParameter("name", ownerName).getSingleResult();
+
+ assertNotNull(result);
+ assertEquals(ownerName, result.getName());
+ assertTrue(result.getId() > 0);
+ assertEquals(o.getId(), result.getId());
+ }
+
+ @Test
+ public void testList() throws Exception {
+ int beforeCount = entityManager().createQuery("select o from Owner as o").getResultList().size();
+
+ for (int i = 0; i < 10; i++) {
+ ownerCurator.create(new Owner("Corp " + i));
+ }
+
+ int afterCount = entityManager().createQuery("select o from Owner as o").getResultList().size();
+ assertEquals(10, afterCount - beforeCount);
+ }
+
+ @Test
+ public void testObjectRelationships() throws Exception {
+ Owner owner = new Owner("test-owner");
+ // Product
+ Product rhel = new Product();
+ rhel.setName("Red Hat Enterprise Linux");
+
+ // User
+ User u = new User();
+ u.setLogin("test-login");
+ u.setPassword("redhat");
+ owner.addUser(u);
+ assertEquals(1, owner.getUsers().size());
+
+ // Consumer
+ Consumer c = new Consumer();
+ c.setOwner(owner);
+ owner.addConsumer(c);
+ c.addConsumedProduct(rhel);
+ assertEquals(1, owner.getConsumers().size());
+ assertEquals(1, c.getConsumedProducts().size());
+
+ // EntitlementPool
+ EntitlementPool pool = new EntitlementPool();
+ owner.addEntitlementPool(pool);
+ pool.setProduct(rhel);
+ assertEquals(1, owner.getEntitlementPools().size());
+ }
+
+ @Test
+ public void bidirectionalConsumers() throws Exception {
+ beginTransaction();
+ Owner o = TestUtil.createOwner();
+ ConsumerType consumerType = TestUtil.createConsumerType();
+ Consumer c1 = TestUtil.createConsumer(consumerType, o);
+ Consumer c2 = TestUtil.createConsumer(consumerType, o);
+ o.addConsumer(c1);
+ o.addConsumer(c2);
+
+ ownerCurator.create(o);
+ consumerTypeCurator.create(consumerType);
+ consumerCurator.create(c1);
+ consumerCurator.create(c2);
+
+ assertEquals(2, o.getConsumers().size());
+
+ Owner lookedUp = ownerCurator.find(o.getId());
+ assertEquals(2, lookedUp.getConsumers().size());
+ }
+
+ @Test
+ public void bidirectionalUsers() throws Exception {
+ Owner o = TestUtil.createOwner();
+
+ User u1 = TestUtil.createUser(o);
+ User u2 = TestUtil.createUser(o);
+
+ o.addUser(u1);
+ o.addUser(u2);
+
+ ownerCurator.create(o);
+
+ assertEquals(2, o.getUsers().size());
+
+ entityManager().clear();
+ Owner lookedUp = ownerCurator.find(o.getId());
+ assertEquals(2, lookedUp.getUsers().size());
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java
new file mode 100644
index 0000000..248d70a
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java
@@ -0,0 +1,130 @@
+package org.fedoraproject.candlepin.model.test;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import javax.persistence.PersistenceException;
+
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.junit.Test;
+
+public class ProductTest extends DatabaseTestFixture {
+
+
+ @Test
+ public void normalCreate() {
+
+ Product prod = new Product("cptest-label", "My Product");
+ persistAndCommit(prod);
+
+ List<Product> results = entityManager().createQuery("select p from Product as p")
+ .getResultList();
+ assertEquals(1, results.size());
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void nameRequired() {
+
+ Product prod = new Product();
+ prod.setLabel("someproductlabel");
+ persistAndCommit(prod);
+
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void labelRequired() {
+
+ Product prod = new Product();
+ prod.setName("My Product Name");
+ persistAndCommit(prod);
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void nameUnique() {
+
+ Product prod = new Product("label1", "name");
+ persistAndCommit(prod);
+
+ Product prod2 = new Product("label2", "name");
+ persistAndCommit(prod2);
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void labelUnique() {
+
+ Product prod = new Product("label1", "name");
+ Product prod2 = new Product("label1", "name2");
+ persistAndCommit(prod);
+
+ persistAndCommit(prod2);
+ }
+
+ @Test
+ public void addChildProducts() {
+ beginTransaction();
+ Product parent = new Product("parent-product", "Parent Product");
+ Product child1 = new Product("child-product1", "Child Product 1");
+ Product child2 = new Product("child-product2", "Child Product 2");
+
+ parent.addChildProduct(child1);
+ parent.addChildProduct(child2);
+ entityManager().persist(parent);
+ commitTransaction();
+
+ //EntityManager em2 = EntityManagerUtil.createEntityManager(); XXX not sure why we need to ask for a new EntityManager here
+ Product result = (Product)entityManager().createQuery(
+ "select p from Product as p where name = :name")
+ .setParameter("name", parent.getName())
+ .getSingleResult();
+ assertEquals(2, result.getChildProducts().size());
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void childHasSingleParentOnly() {
+ beginTransaction();
+
+ Product parent1 = new Product("parent-product1", "Parent Product 1");
+ Product child1 = new Product("child-product1", "Child Product 1");
+ Product parent2 = new Product("parent-product2", "Parent Product 2");
+
+ parent1.addChildProduct(child1);
+ parent2.addChildProduct(child1); // should cause the failure
+
+ entityManager().persist(child1);
+ entityManager().persist(parent1);
+ entityManager().persist(parent2);
+ commitTransaction();
+ }
+
+ @Test
+ public void testCascading() {
+ beginTransaction();
+
+ Product parent1 = new Product("parent-product1", "Parent Product 1");
+ Product child1 = new Product("child-product1", "Child Product 1");
+ parent1.addChildProduct(child1);
+ entityManager().persist(parent1);
+ commitTransaction();
+
+ //EntityManager em2 = EntityManagerUtil.createEntityManager();
+ Product result = (Product)entityManager().createQuery(
+ "select p from Product as p where name = :name")
+ .setParameter("name", child1.getName())
+ .getSingleResult();
+ assertNotNull(result);
+
+ beginTransaction();
+ entityManager().remove(parent1);
+ commitTransaction();
+
+ //em2 = EntityManagerUtil.createEntityManager();
+ List<Product> results = entityManager().createQuery(
+ "select p from Product as p where name = :name")
+ .setParameter("name", child1.getName())
+ .getResultList();
+ assertEquals(0, results.size());
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/UserTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/UserTest.java
new file mode 100644
index 0000000..4e8ea1d
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/UserTest.java
@@ -0,0 +1,45 @@
+/**
+ * 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.model.test;
+
+import static org.junit.Assert.*;
+
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.User;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.junit.Test;
+
+public class UserTest extends DatabaseTestFixture {
+
+ @Test
+ public void testCreate() throws Exception {
+ String ownerName = "Example Corporation";
+ Owner o = new Owner(ownerName);
+
+ String username = "TESTUSER";
+ String password = "sekretpassword";
+ User user = new User(o, username, password);
+
+ beginTransaction();
+ entityManager().persist(o);
+ entityManager().persist(user);
+ commitTransaction();
+
+ User lookedUp = (User)entityManager().find(User.class, user.getId());
+ assertEquals(username, lookedUp.getLogin());
+ assertEquals(password, lookedUp.getPassword());
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CandlepinTestingModule.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CandlepinTestingModule.java
new file mode 100644
index 0000000..96e9f2f
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CandlepinTestingModule.java
@@ -0,0 +1,17 @@
+package org.fedoraproject.candlepin.resource.test;
+
+import org.fedoraproject.candlepin.guice.JPAInitializer;
+
+import com.google.inject.AbstractModule;
+import com.wideplay.warp.persist.jpa.JpaUnit;
+
+public class CandlepinTestingModule extends AbstractModule {
+
+ @Override
+ public void configure() {
+
+ bind(JPAInitializer.class).asEagerSingleton();
+ bindConstant().annotatedWith(JpaUnit.class).to("test");
+
+ }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CertificateResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CertificateResourceTest.java
new file mode 100644
index 0000000..f835046
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/CertificateResourceTest.java
@@ -0,0 +1,117 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import org.fedoraproject.candlepin.model.CertificateCurator;
+import org.fedoraproject.candlepin.model.ConsumerCurator;
+import org.fedoraproject.candlepin.model.EntitlementPool;
+import org.fedoraproject.candlepin.model.EntitlementPoolCurator;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.OwnerCurator;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.model.ProductCurator;
+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 com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.wideplay.warp.persist.PersistenceService;
+import com.wideplay.warp.persist.UnitOfWork;
+
+public class CertificateResourceTest extends DatabaseTestFixture {
+
+ private CertificateResource certResource;
+ private CertificateCurator certificateCurator;
+ private ConsumerCurator consumerRepository;
+ private EntitlementPoolCurator epCurator;
+ private ProductCurator productCurator;
+ private OwnerCurator ownerCurator;
+ private String sampleCertXml;
+
+ @Before
+ public void createObjects() throws Exception {
+
+ Injector injector = Guice.createInjector(
+ new CandlepinTestingModule(),
+ PersistenceService.usingJpa()
+ .across(UnitOfWork.TRANSACTION)
+ .buildModule()
+ );
+
+ consumerRepository = injector.getInstance(ConsumerCurator.class);
+ epCurator = injector.getInstance(EntitlementPoolCurator.class);
+ productCurator = injector.getInstance(ProductCurator.class);
+ ownerCurator = injector.getInstance(OwnerCurator.class);
+ certificateCurator = injector.getInstance(CertificateCurator.class);
+
+ certResource = new CertificateResource(ownerCurator, productCurator, epCurator, certificateCurator);
+
+ 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 ownerCreated() {
+ certResource.upload(TestUtil.xmlToBase64String(sampleCertXml));
+ Owner owner = ownerCurator.lookupByName("Spacewalk Public Cert");
+// certResource.upload(TestUtil.xmlToBase64String(sampleCertXml));
+ assertNotNull(owner);
+ }
+
+ @Test
+ public void simpleUploadCertProductsCreated() {
+ certResource.upload(TestUtil.xmlToBase64String(sampleCertXml));
+ List<Product> products = productCurator.listAll();
+ assertEquals(5, products.size());
+ }
+
+ @Test
+ public void entitlementPoolCreation() {
+ String encoded = TestUtil.xmlToBase64String(sampleCertXml);
+ certResource.upload(encoded);
+ Owner owner = ownerCurator.lookupByName("Spacewalk Public Cert");
+ List<EntitlementPool> entPools = epCurator.listByOwner(owner);
+ assertEquals(5, entPools.size());
+ }
+
+ @Test
+ public void channelFamilyCreation() {
+ // TODO!!!!!! Current test cert has no channel families.
+ }
+
+ @Test
+ public void uploadCertWithPreExistingProducts() {
+ // TODO
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ConsumerResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ConsumerResourceTest.java
new file mode 100644
index 0000000..c67a225
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ConsumerResourceTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.fedoraproject.candlepin.model.Consumer;
+import org.fedoraproject.candlepin.model.ConsumerFact;
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.resource.ConsumerResource;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.fedoraproject.candlepin.test.TestUtil;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * ConsumerResourceTest
+ */
+public class ConsumerResourceTest extends DatabaseTestFixture {
+
+ private static final String METADATA_VALUE = "jsontestname";
+ private static final String METADATA_NAME = "name";
+ private static final String CONSUMER_NAME = "consumer name";
+
+ private ConsumerType standardSystemType;
+ private ConsumerResource consumerResource;
+ private Owner owner;
+
+ @Before
+ public void setUp() {
+ super.setUp();
+
+ consumerResource = new ConsumerResource(ownerCurator, consumerCurator, consumerTypeCurator);
+ standardSystemType = consumerTypeCurator.create(new ConsumerType("standard-system"));
+ owner = ownerCurator.create(new Owner("test-owner"));
+ }
+
+ // TODO: Test no such consumer type.
+
+// @Test
+// public void testDelete() {
+// Consumer c = TestUtil.createConsumer();
+// String uuid = c.getUuid();
+// ConsumerResource capi = new ConsumerResource();
+// assertNotNull(ObjectFactory.get().lookupByUUID(c.getClass(), uuid));
+// capi.delete(uuid);
+// assertNull(ObjectFactory.get().lookupByUUID(c.getClass(), uuid));
+// }
+
+ @Test
+ public void testCreateConsumer() {
+ Consumer toSubmit = new Consumer(CONSUMER_NAME, null, standardSystemType);
+ toSubmit.setInfo(new ConsumerFact() {{ setMetadataField(METADATA_NAME, METADATA_VALUE); }});
+
+ Consumer created = consumerResource.create(toSubmit);
+
+ assertNotNull(created);
+ assertNotNull(created.getUuid());
+ assertNotNull(consumerCurator.find(created.getId()));
+ assertEquals(standardSystemType.getLabel(), created.getType().getLabel());
+ assertEquals(METADATA_VALUE, created.getMetadataField(METADATA_NAME));
+ }
+
+ @Ignore // TODO: implement 'delete' functionality
+ public void testDeleteResource() {
+ Consumer created = consumerCurator.create(new Consumer(CONSUMER_NAME, owner, standardSystemType));
+ consumerResource.delete(created.getUuid());
+
+ assertNull(consumerCurator.find(created.getId()));
+ }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementMatcherTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementMatcherTest.java
new file mode 100644
index 0000000..4bb31b6
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementMatcherTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.fedoraproject.candlepin.model.Consumer;
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.ObjectFactory;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.model.ProductFactory;
+import org.fedoraproject.candlepin.resource.EntitlementMatcher;
+import org.fedoraproject.candlepin.test.TestUtil;
+import org.junit.Test;
+
+/**
+ * EntitlementMatcherTest
+ * @version $Rev$
+ */
+public class EntitlementMatcherTest {
+
+ @Test
+ public void testIsCompatable() throws Exception {
+ Consumer consumer = TestUtil.createConsumer();
+ ConsumerType typeSystem = ProductFactory.get().lookupConsumerTypeByLabel("system");
+ consumer.setType(typeSystem);
+
+ List f = ObjectFactory.get().listObjectsByClass(Product.class);
+ Product rhel = (Product) ObjectFactory.get().lookupByFieldName(
+ Product.class, "label", "rhel");
+ Product rhelvirt = (Product) ObjectFactory.get().lookupByFieldName(
+ Product.class, "label", "rhel-virt");
+
+ EntitlementMatcher m = new EntitlementMatcher();
+
+ assertTrue(m.isCompatible(consumer, rhel));
+
+ ConsumerType vmwarehost =
+ ProductFactory.get().lookupConsumerTypeByLabel("vmwarehost");
+ consumer.setType(vmwarehost);
+
+ // Check that you can't use rhelvirt on a vmware host
+ assertFalse(m.isCompatible(consumer, rhelvirt));
+ }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementResourceTest.java
new file mode 100644
index 0000000..b9dfaa4
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementResourceTest.java
@@ -0,0 +1,202 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import java.sql.Date;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.fedoraproject.candlepin.model.Consumer;
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.EntitlementPool;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.resource.EntitlementResource;
+import org.fedoraproject.candlepin.test.DatabaseTestFixture;
+import org.fedoraproject.candlepin.test.TestUtil;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+
+
+/**
+ * ConsumerResourceTest
+ */
+public class EntitlementResourceTest extends DatabaseTestFixture {
+
+ private Consumer consumer;
+ private Product product;
+ private EntitlementPool ep;
+ private Owner owner;
+ private EntitlementResource eapi;
+
+ @Before
+ public void createTestObjects() {
+ owner = TestUtil.createOwner();
+ ownerCurator.create(owner);
+
+ ConsumerType type = new ConsumerType("some-consumer-type");
+ consumerTypeCurator.create(type);
+
+ consumer = TestUtil.createConsumer(type, owner);
+ consumerCurator.create(consumer);
+
+ product = TestUtil.createProduct();
+ productCurator.create(product);
+
+ Date pastDate = new Date(System.currentTimeMillis() - 10000000);
+ Date futuredate = new Date(System.currentTimeMillis() + 1000000000);
+ ep = new EntitlementPool(owner, product, new Long(10), pastDate, futuredate);
+ entitlementPoolCurator.create(ep);
+
+ eapi = new EntitlementResource(entitlementPoolCurator, ownerCurator, consumerCurator,
+ productCurator);
+
+ }
+
+ @Ignore
+ public void testEntitle() throws Exception {
+
+// Form f = new Form();
+// f.add("consumer_id", consumer.getId());
+// f.add("product_id", product.getId());
+ String cert = (String) eapi.entitle(consumer.getUuid(), product.getLabel());
+
+ assertNotNull(cert);
+
+ consumer = consumerCurator.lookupByUuid(consumer.getUuid());
+ assertEquals(1, consumer.getConsumedProducts().size());
+ assertEquals(product.getId(), consumer.getConsumedProducts().iterator()
+ .next().getId());
+ assertEquals(1, consumer.getEntitlements().size());
+
+ ep = entitlementPoolCurator.find(ep.getId());
+ assertEquals(new Long(1), ep.getCurrentMembers());
+ }
+
+ @Test
+ public void testMaxMembership() {
+
+ // 10 entitlements available, lets try to entitle 11 consumers.
+ for (int i = 0; i < ep.getMaxMembers(); i++) {
+ Consumer c = TestUtil.createConsumer(consumer.getType(), owner);
+ consumerCurator.create(c);
+ eapi.entitle(c.getUuid(), product.getLabel());
+ }
+
+ // Now for the 11th:
+ try {
+ Consumer c = TestUtil.createConsumer(consumer.getType(), owner);
+ eapi.entitle(c.getUuid(), product.getLabel());
+ fail();
+ }
+ catch (RuntimeException e) {
+ // expected
+ }
+
+ }
+
+ @Test
+ public void testEntitlementsHaveExpired() {
+ Product myProduct = TestUtil.createProduct();
+ productCurator.create(myProduct);
+ Date pastDate = new Date(System.currentTimeMillis() - 10000000);
+ Date notSoPastDate = new Date(System.currentTimeMillis() - 100000);
+ EntitlementPool anotherPool = new EntitlementPool(owner, myProduct, new Long(10),
+ pastDate, notSoPastDate);
+ entitlementPoolCurator.create(anotherPool);
+
+ try {
+ eapi.entitle(consumer.getUuid(), myProduct.getLabel());
+ fail();
+ }
+ catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testEntitleOwnerHasNoEntitlements() {
+ // TODO
+ }
+
+ @Test
+ public void testEntitleOwnerHasNoAviailableEntitlements() {
+ // TODO
+ }
+
+ @Test
+ public void testEntitleConsumerAlreadyEntitledForProduct() {
+ // TODO
+ }
+
+ @Ignore
+ public void testHasEntitlement() {
+
+ eapi.entitle(consumer.getUuid(), product.getLabel());
+
+ // TODO: Disabling this test, boils into ObjectFactory things that need
+ // to be fixed before we can do this check! Sorry! :) - dgoodwin
+// assertTrue(eapi.hasEntitlement(consumer.getUuid(), product.getUuid()));
+ }
+
+ // TODO: Re-enable once ObjectFactory is Hibernatized or removed.
+// @Test
+// public void testListAvailableEntitlements() {
+// EntitlementResource eapi = new EntitlementResource();
+//// consumer.setType(new ConsumerType("standard-system"));
+// Form f = new Form();
+// f.add("consumer_id", consumer.getId());
+//
+// List<EntitlementPool> avail = eapi.listAvailableEntitlements(consumer.getId());
+// assertNotNull(avail);
+// assertTrue(avail.size() > 0);
+// }
+
+ @Test
+ @Ignore
+ public void testJson() {
+ ClientConfig cc = new DefaultClientConfig();
+ Client c = Client.create(cc);
+
+ // WebResource getresource = c.resource("http://localhost:8080/candlepin/entitle/");
+
+
+ Object[] params = new Object[2];
+ params[0] = consumer;
+ params[1] = product;
+ List aparams = new ArrayList();
+ aparams.add(consumer);
+ aparams.add(product);
+
+ WebResource postresource =
+ c.resource("http://localhost:8080/candlepin/entitlement/foo/");
+ postresource.accept("application/json").type("application/json").post(consumer);
+
+ // System.out.println(jto.getName());
+ // jto = getresource.accept("application/json").get(JsonTestObject.class);
+ // assertEquals("testname", jto.getName());
+ // assertEquals("AEF", jto.getUuid());
+ }
+
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/TestResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/TestResourceTest.java
new file mode 100644
index 0000000..6454df4
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/TestResourceTest.java
@@ -0,0 +1,94 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.JsonTestObject;
+import org.fedoraproject.candlepin.resource.TestResource;
+import org.junit.Ignore;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+
+
+/**
+ * TestResourceTest
+ * @version $Rev$
+ */
+@Ignore
+public class TestResourceTest {
+
+ private JsonTestObject createTestObject() {
+ JsonTestObject jto = new JsonTestObject();
+ jto.setName("testname");
+ List<String> l = new ArrayList<String>();
+ l.add("hey there");
+ l.add("how are you?");
+ jto.setStringList(l);
+ return jto;
+ }
+
+// @Test
+ @Ignore
+ public void testJson() {
+ ClientConfig cc = new DefaultClientConfig();
+ Client c = Client.create(cc);
+
+
+ JsonTestObject jto = createTestObject();
+
+ WebResource postresource = c.resource("http://localhost:8080/candlepin/test/");
+ postresource.accept("application/json").type("application/json").post(jto);
+
+ WebResource getresource = c.resource("http://localhost:8080/candlepin/test/");
+ System.out.println(jto.getName());
+ jto = getresource.accept("application/json").get(JsonTestObject.class);
+ assertEquals("testname", jto.getName());
+ assertNotNull(jto.getStringList());
+ assertEquals(2, jto.getStringList().size());
+ assertNull(jto.getParent());
+ System.out.println(jto.getStringList());
+ }
+
+ // @Test
+ @Ignore
+ public void testGet() {
+ TestResource tr = new TestResource();
+ assertNull(tr.get());
+
+ JsonTestObject jto = createTestObject();
+ tr.create(jto);
+ assertEquals(jto, tr.get());
+ }
+
+ // @Test
+ public void testConsumerType() {
+ ClientConfig cc = new DefaultClientConfig();
+ Client c = Client.create(cc);
+
+ WebResource getresource =
+ c.resource("http://localhost:8080/candlepin/test/consumertype");
+ ConsumerType ct = getresource.accept("application/json").get(ConsumerType.class);
+ assertNotNull(ct);
+ assertEquals("testtype", ct.getLabel());
+ }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/UserResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/UserResourceTest.java
new file mode 100644
index 0000000..94cf31d
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/UserResourceTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.fedoraproject.candlepin.model.User;
+import org.fedoraproject.candlepin.resource.UserResource;
+import org.junit.Test;
+
+
+/**
+ * UserResourceTest
+ * @version $Rev$
+ */
+public class UserResourceTest {
+
+ private UserResource api = new UserResource();
+
+ @Test
+ public void testNewUser() {
+ User user = api.create("candlepin", "cp_p@$sw0rd");
+ assertNotNull(user);
+ assertEquals("candlepin", user.getLogin());
+ assertEquals("cp_p@$sw0rd", user.getPassword());
+
+ user = api.create(null, null);
+ assertNotNull(user);
+ assertEquals(null, user.getLogin());
+ assertEquals(null, user.getPassword());
+
+ user = api.create("", "");
+ assertNotNull(user);
+ assertEquals("", user.getLogin());
+ assertEquals("", user.getPassword());
+ }
+
+ @Test
+ public void testList() {
+ List<User> users = api.list();
+ int origSize = users.size();
+ // create 1
+ api.create("candlepin", "cp_p@$sw0rd");
+
+ // create 2
+ api.create("jesusr", "n0P@$sw0rD");
+
+ // get the list back
+ users = api.list();
+ System.out.println("Users: " + users.toString());
+ assertNotNull(users);
+ assertEquals(origSize + 2, users.size());
+ assertEquals(User.class, users.get(0).getClass());
+ }
+
+ @Test
+ public void testGet() {
+ User user = api.get("test-login");
+ assertNotNull(user);
+ assertEquals("test-login", user.getLogin());
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/cert/test/CertTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/cert/test/CertTest.java
new file mode 100644
index 0000000..fd72bf9
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/cert/test/CertTest.java
@@ -0,0 +1,284 @@
+/**
+ * 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.cert.test;
+
+import java.math.BigInteger;
+import java.security.KeyFactory;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.Security;
+import java.security.cert.X509Certificate;
+import java.security.spec.RSAPrivateCrtKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.util.Date;
+
+import org.bouncycastle.asn1.ASN1EncodableVector;
+import org.bouncycastle.asn1.DERSequence;
+import org.bouncycastle.asn1.x509.GeneralName;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.x509.AttributeCertificateHolder;
+import org.bouncycastle.x509.AttributeCertificateIssuer;
+import org.bouncycastle.x509.X509Attribute;
+import org.bouncycastle.x509.X509V2AttributeCertificate;
+import org.bouncycastle.x509.X509V2AttributeCertificateGenerator;
+import org.bouncycastle.x509.examples.AttrCertExample;
+import org.fedoraproject.candlepin.resource.cert.CertGenerator;
+import org.junit.Test;
+
+/**
+ * CertTest
+ * @version $Rev$
+ */
+public class CertTest {
+
+ @Test
+ public void testCertGenerator() {
+ String cert = CertGenerator.getCertString();
+// System.out.println("Cert: " + cert);
+ }
+
+ @Test
+ public void testCertExample() throws Exception {
+
+ Security.addProvider(new BouncyCastleProvider());
+
+ //
+ // personal keys
+ //
+ RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(
+ new BigInteger("b4a7e46170574f16a97082b22be58b6a2a629798419" +
+ "be12872a4bdba626cfae9900f76abfb12139dce5de5" +
+ "6564fab2b6543165a040c606887420e33d91ed7ed7", 16),
+ new BigInteger("11", 16));
+
+ RSAPrivateCrtKeySpec privKeySpec = new RSAPrivateCrtKeySpec(
+ new BigInteger("b4a7e46170574f16a97082b22be58b6a2a629798419" +
+ "be12872a4bdba626cfae9900f76abfb12139dce5de5" +
+ "6564fab2b6543165a040c606887420e33d91ed7ed7", 16),
+ new BigInteger("11", 16),
+ new BigInteger("9f66f6b05410cd503b2709e88115d55daced94d1a34" +
+ "d4e32bf824d0dde6028ae79c5f07b580f5dce240d71" +
+ "11f7ddb130a7945cd7d957d1920994da389f490c89", 16),
+ new BigInteger("c0a0758cdf14256f78d4708c86becdead1b50ad4ad6" +
+ "c5c703e2168fbf37884cb", 16),
+ new BigInteger("f01734d7960ea60070f1b06f2bb81bfac48ff192ae1" +
+ "8451d5e56c734a5aab8a5", 16),
+ new BigInteger("b54bb9edff22051d9ee60f9351a48591b6500a31942" +
+ "9c069a3e335a1d6171391", 16),
+ new BigInteger("d3d83daf2a0cecd3367ae6f8ae1aeb82e9ac2f816c6" +
+ "fc483533d8297dd7884cd", 16),
+ new BigInteger("b8f52fc6f38593dabb661d3f50f8897f8106eee68b1" +
+ "bce78a95b132b4e5b5d19", 16));
+
+ //
+ // ca keys
+ //
+ RSAPublicKeySpec caPubKeySpec = new RSAPublicKeySpec(
+ new BigInteger("b259d2d6e627a768c94be36164c2d9fc79d97aab925" +
+ "3140e5bf17751197731d6f7540d2509e7b9ffee0a70" +
+ "a6e26d56e92d2edd7f85aba85600b69089f35f6bdbf" +
+ "3c298e05842535d9f064e6b0391cb7d306e0a2d20c4" +
+ "dfb4e7b49a9640bdea26c10ad69c3f05007ce2513ce" +
+ "e44cfe01998e62b6c3637d3fc0391079b26ee36d5", 16),
+ new BigInteger("11", 16));
+
+ RSAPrivateCrtKeySpec caPrivKeySpec = new RSAPrivateCrtKeySpec(
+ new BigInteger("b259d2d6e627a768c94be36164c2d9fc79d97aab925" +
+ "3140e5bf17751197731d6f7540d2509e7b9ffee0a70" +
+ "a6e26d56e92d2edd7f85aba85600b69089f35f6bdbf" +
+ "3c298e05842535d9f064e6b0391cb7d306e0a2d20c4" +
+ "dfb4e7b49a9640bdea26c10ad69c3f05007ce2513ce" +
+ "e44cfe01998e62b6c3637d3fc0391079b26ee36d5", 16),
+ new BigInteger("11", 16),
+ new BigInteger("92e08f83cc9920746989ca5034dcb384a094fb9c5a6" +
+ "288fcc4304424ab8f56388f72652d8fafc65a4b9020" +
+ "896f2cde297080f2a540e7b7ce5af0b3446e1258d1d" +
+ "d7f245cf54124b4c6e17da21b90a0ebd22605e6f45c" +
+ "9f136d7a13eaac1c0f7487de8bd6d924972408ebb58" +
+ "af71e76fd7b012a8d0e165f3ae2e5077a8648e619", 16),
+ new BigInteger("f75e80839b9b9379f1cf1128f321639757dba514642" +
+ "c206bbbd99f9a4846208b3e93fbbe5e0527cc59b1d4" +
+ "b929d9555853004c7c8b30ee6a213c3d1bb7415d03", 16),
+ new BigInteger("b892d9ebdbfc37e397256dd8a5d3123534d1f037262" +
+ "84743ddc6be3a709edb696fc40c7d902ed804c6eee7" +
+ "30eee3d5b20bf6bd8d87a296813c87d3b3cc9d7947", 16),
+ new BigInteger("1d1a2d3ca8e52068b3094d501c9a842fec37f54db16" +
+ "e9a67070a8b3f53cc03d4257ad252a1a640eadd6037" +
+ "24d7bf3737914b544ae332eedf4f34436cac25ceb5", 16),
+ new BigInteger("6c929e4e81672fef49d9c825163fec97c4b7ba7acb2" +
+ "6c0824638ac22605d7201c94625770984f78a56e6e2" +
+ "5904fe7db407099cad9b14588841b94f5ab498dded", 16),
+ new BigInteger("dae7651ee69ad1d081ec5e7188ae126f6004ff39556" +
+ "bde90e0b870962fa7b926d070686d8244fe5a9aa709" +
+ "a95686a104614834b0ada4b10f53197a5cb4c97339", 16));
+
+ //
+ // set up the keys
+ //
+ KeyFactory fact = KeyFactory.getInstance("RSA", "BC");
+ PrivateKey caPrivKey = fact.generatePrivate(caPrivKeySpec);
+ PublicKey caPubKey = fact.generatePublic(caPubKeySpec);
+ PrivateKey privKey = fact.generatePrivate(privKeySpec);
+ PublicKey pubKey = fact.generatePublic(pubKeySpec);
+
+ //
+ // note in this case we are using the CA certificate for both the client
+ // cetificate
+ // and the attribute certificate. This is to make the vcode simpler to
+ // read, in practice
+ // the CA for the attribute certificate should be different to that of
+ // the client certificate
+ //
+ X509Certificate caCert = AttrCertExample.createAcIssuerCert(caPubKey,
+ caPrivKey);
+ X509Certificate clientCert = AttrCertExample.createClientCert(pubKey,
+ caPrivKey, caPubKey);
+// System.out.println("CaCert: " + caCert);
+// System.out.println("clientCert: " + clientCert);
+ // Instantiate a new AC generator
+ X509V2AttributeCertificateGenerator acGen =
+ new X509V2AttributeCertificateGenerator();
+
+ acGen.reset();
+
+ //
+ // Holder: here we use the IssuerSerial form
+ //
+ acGen.setHolder(new AttributeCertificateHolder(clientCert));
+
+ // set the Issuer
+ acGen.setIssuer(new AttributeCertificateIssuer(caCert
+ .getSubjectX500Principal()));
+
+ //
+ // serial number (as it's an example we don't have to keep track of the
+ // serials anyway
+ //
+ acGen.setSerialNumber(new BigInteger("1"));
+
+ // not Before
+ acGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
+
+ // not After
+ acGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
+
+ // signature Algorithmus
+ acGen.setSignatureAlgorithm("SHA1WithRSAEncryption");
+
+ // the actual attributes
+ GeneralName roleName = new GeneralName(GeneralName.rfc822Name,
+ "DAU123456789");
+ ASN1EncodableVector roleSyntax = new ASN1EncodableVector();
+ roleSyntax.add(roleName);
+
+ // roleSyntax OID: 2.5.24.72
+ X509Attribute attributes = new X509Attribute("2.5.24.72",
+ new DERSequence(roleSyntax));
+
+ acGen.addAttribute(attributes);
+
+ // finally create the AC
+ X509V2AttributeCertificate att = (X509V2AttributeCertificate) acGen
+ .generate(caPrivKey, "BC");
+
+
+
+ String encoded = new String(att.getEncoded());
+ //System.out.println("CERT CERT: " + encoded);
+ KeyStore store = KeyStore.getInstance("PKCS12");
+ String pass = "redhat";
+
+
+ /*FileOutputStream fout = new FileOutputStream("/tmp/foo.file");
+ store.load(null, null);
+ store.store(fout, pass.toCharArray());
+ X509CertificateObject ccert = new
+ X509CertificateObject(new X509CertificateStructure(new DERSequence(att)));*/
+ //
+ // starting here, we parse the newly generated AC
+ //
+
+ // Holder
+
+ AttributeCertificateHolder h = att.getHolder();
+ if (h.match(clientCert)) {
+ if (h.getEntityNames() != null) {
+// System.out.println(h.getEntityNames().length +
+// " entity names found");
+ }
+ if (h.getIssuer() != null) {
+// System.out.println(h.getIssuer().length +
+// " issuer names found, serial number " +
+// h.getSerialNumber());
+ }
+// System.out.println("Matches original client x509 cert");
+ }
+
+ // Issuer
+
+ AttributeCertificateIssuer issuer = att.getIssuer();
+ if (issuer.match(caCert)) {
+ if (issuer.getPrincipals() != null) {
+// System.out.println(issuer.getPrincipals().length +
+// " entity names found");
+ }
+// System.out.println("Matches original ca x509 cert");
+ }
+
+ // Dates
+// System.out.println("valid not before: " + att.getNotBefore());
+// System.out.println("valid not before: " + att.getNotAfter());
+
+ // check the dates, an exception is thrown in checkValidity()...
+
+ try {
+ att.checkValidity();
+ att.checkValidity(new Date());
+ }
+ catch (Exception e) {
+ System.out.println(e);
+ }
+
+ // verify
+
+ try {
+ att.verify(caPubKey, "BC");
+ }
+ catch (Exception e) {
+ System.out.println(e);
+ }
+
+ // Attribute
+ X509Attribute[] attribs = att.getAttributes();
+// System.out.println("cert has " + attribs.length + " attributes:");
+ for (int i = 0; i < attribs.length; i++) {
+ X509Attribute a = attribs[i];
+// System.out.println("OID: " + a.getOID());
+
+ // currently we only check for the presence of a 'RoleSyntax'
+ // attribute
+
+ if (a.getOID().equals("2.5.24.72")) {
+// System.out.println("rolesyntax read from cert!");
+ }
+ }
+
+
+
+
+ // CertificateFactory.getInstance
+ }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/spacewalk-public.cert b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/spacewalk-public.cert
new file mode 100644
index 0000000..4d63ab3
--- /dev/null
+++ b/proxy/src/test/java/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>
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/test/DatabaseTestFixture.java b/proxy/src/test/java/org/fedoraproject/candlepin/test/DatabaseTestFixture.java
new file mode 100644
index 0000000..a373489
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/test/DatabaseTestFixture.java
@@ -0,0 +1,187 @@
+package org.fedoraproject.candlepin.test;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+
+import org.fedoraproject.candlepin.model.Certificate;
+import org.fedoraproject.candlepin.model.CertificateCurator;
+import org.fedoraproject.candlepin.model.Consumer;
+import org.fedoraproject.candlepin.model.ConsumerCurator;
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.ConsumerTypeCurator;
+import org.fedoraproject.candlepin.model.Entitlement;
+import org.fedoraproject.candlepin.model.EntitlementPool;
+import org.fedoraproject.candlepin.model.EntitlementPoolCurator;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.OwnerCurator;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.model.ProductCurator;
+import org.fedoraproject.candlepin.model.User;
+import org.fedoraproject.candlepin.resource.test.CandlepinTestingModule;
+import org.junit.Before;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.wideplay.warp.persist.PersistenceService;
+import com.wideplay.warp.persist.UnitOfWork;
+
+/**
+ * Test fixture for test classes requiring access to the database.
+ */
+public class DatabaseTestFixture {
+
+ protected EntityManagerFactory emf;
+ protected Injector injector;
+
+ protected OwnerCurator ownerCurator;
+ protected ProductCurator productCurator;
+ protected ConsumerCurator consumerCurator;
+ protected ConsumerTypeCurator consumerTypeCurator;
+ protected CertificateCurator certificateCurator;
+ protected EntitlementPoolCurator entitlementPoolCurator;
+
+
+ @Before
+ public void setUp() {
+ injector = Guice.createInjector(
+ new CandlepinTestingModule(),
+ PersistenceService.usingJpa()
+ .across(UnitOfWork.TRANSACTION)
+ .buildModule()
+ );
+
+ injector.getInstance(EntityManagerFactory.class);
+ emf = injector.getProvider(EntityManagerFactory.class).get();
+
+ ownerCurator = injector.getInstance(OwnerCurator.class);
+ productCurator = injector.getInstance(ProductCurator.class);
+ consumerCurator = injector.getInstance(ConsumerCurator.class);
+ consumerTypeCurator = injector.getInstance(ConsumerTypeCurator.class);
+ certificateCurator = injector.getInstance(CertificateCurator.class);
+ entitlementPoolCurator = injector.getInstance(EntitlementPoolCurator.class);
+ }
+
+ /*
+ * As long as we are using in-memory db we don't need to clean it out;
+ * a new instance will be created for each test. cleanDb() is *not* being currently invoked.
+ *
+ * Cleans out everything in the database. Currently we test against an
+ * in-memory hsqldb, so this should be ok.
+ *
+ * WARNING: Don't flip the persistence unit to point to an actual live
+ * DB or you'll lose everything.
+ *
+ * WARNING: If you're creating objects in tables that have static
+ * pre-populated content, we may not want to wipe those tables here.
+ * This situation hasn't arisen yet.
+ */
+ @SuppressWarnings("unchecked")
+ public void cleanDb() {
+ EntityManager em = entityManager();
+ if (!em.getTransaction().isActive()) {
+ beginTransaction();
+ }
+
+ List<User> users = em.createQuery("from User u").getResultList();
+ for (User u : users) {
+ em.remove(u);
+ }
+
+ List<Entitlement> ents = em.createQuery("from Entitlement e").
+ getResultList();
+ for (Entitlement e : ents) {
+ em.remove(e);
+ }
+
+ List<EntitlementPool> pools = em.createQuery("from EntitlementPool p").getResultList();
+ for (EntitlementPool p : pools) {
+ em.remove(p);
+ }
+
+ // TODO: Would rather be doing this, but such a bulk delete does not seem to respect
+ // the cascade to child products and thus fails.
+ // em.createQuery("delete from Product").executeUpdate();
+ List<Product> products = em.createQuery("from Product p").getResultList();
+ for (Product p : products) {
+ em.remove(p);
+ }
+
+ List<Consumer> consumers = em.createQuery("from Consumer c").getResultList();
+ for (Consumer c : consumers) {
+ em.remove(c);
+ }
+
+ List<Certificate> certificates = em.createQuery("from Certificate c").getResultList();
+ for (Certificate c : certificates){
+ em.remove(c);
+ }
+
+ List<Owner> owners = em.createQuery("from Owner o").getResultList();
+ for (Owner o : owners) {
+ em.remove(o);
+ }
+
+// List<ConsumerInfo> consumerInfos = em.createQuery("from ConsumerInfo c").getResultList();
+// for (ConsumerInfo c : consumerInfos) {
+// em.remove(c);
+// }
+
+ // TODO: Is this right? Or should we pre-populate default defined types, and always
+ // reference these in the tests instead of creating them everywhere?
+ List<ConsumerType> consumerTypes = em.createQuery("from ConsumerType c").
+ getResultList();
+ for (ConsumerType c : consumerTypes) {
+ em.remove(c);
+ }
+
+
+
+ commitTransaction();
+ em.close();
+ }
+
+ protected EntityManager entityManager() {
+ return injector.getProvider(EntityManager.class).get();
+ }
+
+ /**
+ * Begin a transaction, persist the given entity, and commit.
+ *
+ * @param storeMe Entity to persist.
+ */
+ protected void persistAndCommit(Object storeMe) {
+ EntityTransaction tx = null;
+
+ try {
+ tx = entityManager().getTransaction();
+ tx.begin();
+ entityManager().persist(storeMe);
+ tx.commit();
+ }
+ catch (RuntimeException e) {
+ if (tx != null && tx.isActive()) {
+ tx.rollback();
+ }
+ throw e; // or display error message
+ }
+ }
+
+ /**
+ * Helper to open a new db transaction. Pretty simple for now, but may
+ * require additional logic and error handling down the road.
+ */
+ protected void beginTransaction() {
+ entityManager().getTransaction().begin();
+ }
+
+ /**
+ * Helper to commit the current db transaction. Pretty simple for now, but may
+ * require additional logic and error handling down the road.
+ */
+ protected void commitTransaction() {
+ entityManager().getTransaction().commit();
+ }
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/test/TestUtil.java b/proxy/src/test/java/org/fedoraproject/candlepin/test/TestUtil.java
new file mode 100644
index 0000000..21b005e
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/test/TestUtil.java
@@ -0,0 +1,126 @@
+/**
+ * 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.test;
+
+import java.sql.Date;
+import java.util.Calendar;
+import java.util.Random;
+
+import org.apache.commons.codec.binary.Base64;
+import org.fedoraproject.candlepin.model.Consumer;
+import org.fedoraproject.candlepin.model.ConsumerType;
+import org.fedoraproject.candlepin.model.Entitlement;
+import org.fedoraproject.candlepin.model.EntitlementPool;
+import org.fedoraproject.candlepin.model.ObjectFactory;
+import org.fedoraproject.candlepin.model.Owner;
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.model.User;
+
+/**
+ * TestUtil for creating various testing objects.
+ *
+ * Objects backed by the database are not persisted, the caller is expected to persist
+ * the entities returned and any dependent objects.
+ */
+public class TestUtil {
+
+ private TestUtil() {
+ }
+
+ public static Owner createOwner() {
+ Owner o = new Owner("Test Owner " + randomInt());
+// o.setUuid(lookedUp);
+ ObjectFactory.get().store(o);
+ return o;
+ }
+
+ public static Consumer createConsumer(ConsumerType type, Owner owner) {
+ Consumer c = new Consumer("Test Consumer " + randomInt(), owner, type);
+ ObjectFactory.get().store(c);
+ return c;
+ }
+
+ /**
+ * Create a consumer with a new owner
+ * @return Consumer
+ */
+ public static Consumer createConsumer() {
+ return createConsumer(createConsumerType(), createOwner());
+ }
+
+ public static ConsumerType createConsumerType() {
+ return new ConsumerType("test-consumer-type-" + randomInt());
+ }
+
+ public static int randomInt() {
+ return new Random().nextInt(10000);
+ }
+
+ public static Product createProduct() {
+ int random = randomInt();
+ Product rhel = new Product("test-product-" + random,
+ "Test Product " + random);
+ ObjectFactory.get().store(rhel);
+ return rhel;
+ }
+
+ public static EntitlementPool createEntitlementPool() {
+ EntitlementPool pool = new EntitlementPool(createOwner(), createProduct(),
+ new Long(1000),
+ TestUtil.createDate(2009, 11, 30), TestUtil.createDate(2015, 11, 30));
+ return pool;
+ }
+
+ public static Entitlement createEntitlement(EntitlementPool pool) {
+ Entitlement e = new Entitlement(pool, pool.getOwner(), pool.getStartDate());
+ return e;
+ }
+
+ public static User createUser(Owner owner) {
+ User u = new User(owner, "testuser" + randomInt(), "sekret");
+ return u;
+ }
+
+ public static Date createDate(int year, int month, int day) {
+ Calendar cal = Calendar.getInstance();
+
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.MONTH, month);
+ cal.set(Calendar.DATE, day);
+
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ Date jsqlD = new Date(cal.getTime().getTime());
+ return jsqlD;
+ }
+
+ public static String xmlToBase64String(String xml) {
+
+// byte[] bytes = Base64.encode(xml);
+ Base64 encoder = new Base64();
+ byte [] bytes = encoder.encode(xml.getBytes());
+
+ StringBuffer buf = new StringBuffer();
+ for (byte b : bytes) {
+ buf.append((char) Integer.parseInt(Integer.toHexString(b), 16));
+ }
+
+ return buf.toString();
+ }
+
+}
diff --git a/proxy/src/test/resources/certs/certificates.readme b/proxy/src/test/resources/certs/certificates.readme
new file mode 100644
index 0000000..0039145
--- /dev/null
+++ b/proxy/src/test/resources/certs/certificates.readme
@@ -0,0 +1,22 @@
+to generate certificates:
+
+keytool -genkeypair -alias servercert -keyalg RSA -dname "CN=Web Server,OU=Unit,O=Organization,L=City,S=State,C=US" -keypass password -keystore server.jks -storepass password
+keytool -genkeypair -alias clientcert -keystore clientcert.p12 -storetype pkcs12 -keyalg RSA -dname "CN=Client,OU=Unit,O=Organization,L=City,S=State,C=US" -keypass password -storepass password
+keytool -exportcert -alias %1 -file clientcert.cer -keystore clientcert.p12 -storetype pkcs12 -storepass password
+keytool -importcert -keystore server.jks -alias clientcert -file clientcert.cer -v -trustcacerts -noprompt -storepass password
+
+tomcat connector configuration:
+
+<Connector
+ clientAuth="true" port="8443" minSpareThreads="5" maxSpareThreads="75"
+ enableLookups="true" disableUploadTimeout="true"
+ acceptCount="100" maxThreads="200"
+ scheme="https" secure="true" SSLEnabled="true"
+ keystoreFile="${catalina.home}/conf/server.jks"
+ keystoreType="JKS" keystorePass="password"
+ truststoreFile="${catalina.home}/conf/server.jks"
+ truststoreType="JKS" truststorePass="password"
+ SSLVerifyClient="require" SSLEngine="on" SSLVerifyDepth="2" sslProtocol="TLS"
+/>
+
+install client certificate into your browser of choice, and you should be good to go! \ No newline at end of file
diff --git a/proxy/src/test/resources/certs/rest_api_test.jks b/proxy/src/test/resources/certs/rest_api_test.jks
new file mode 100644
index 0000000..b055808
--- /dev/null
+++ b/proxy/src/test/resources/certs/rest_api_test.jks
Binary files differ
diff --git a/proxy/src/test/resources/certs/rest_client_test.p12 b/proxy/src/test/resources/certs/rest_client_test.p12
new file mode 100644
index 0000000..f2d100e
--- /dev/null
+++ b/proxy/src/test/resources/certs/rest_client_test.p12
Binary files differ
diff --git a/proxy/src/test/resources/certs/server.xml b/proxy/src/test/resources/certs/server.xml
new file mode 100644
index 0000000..85ab0e1
--- /dev/null
+++ b/proxy/src/test/resources/certs/server.xml
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+--><!-- Note: A "Server" is not itself a "Container", so you may not
+ define subcomponents such as "Valves" at this level.
+ Documentation at /docs/config/server.html
+ --><Server port="8005" shutdown="SHUTDOWN">
+
+ <!--APR library loader. Documentation at /docs/apr.html -->
+ <!-- Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/ -->
+ <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
+ <Listener className="org.apache.catalina.core.JasperListener"/>
+ <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
+ <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
+ <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
+
+ <!-- Global JNDI resources
+ Documentation at /docs/jndi-resources-howto.html
+ -->
+ <GlobalNamingResources>
+ <!-- Editable user database that can also be used by
+ UserDatabaseRealm to authenticate users
+ -->
+ <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
+ </GlobalNamingResources>
+
+ <!-- A "Service" is a collection of one or more "Connectors" that share
+ a single "Container" Note: A "Service" is not itself a "Container",
+ so you may not define subcomponents such as "Valves" at this level.
+ Documentation at /docs/config/service.html
+ -->
+ <Service name="Catalina">
+
+ <!--The connectors can use a shared executor, you can define one or more named thread pools-->
+ <!--
+ <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
+ maxThreads="150" minSpareThreads="4"/>
+ -->
+
+
+ <!-- A "Connector" represents an endpoint by which requests are received
+ and responses are returned. Documentation at :
+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+ Java AJP Connector: /docs/config/ajp.html
+ APR (HTTP/AJP) Connector: /docs/apr.html
+ Define a non-SSL HTTP/1.1 Connector on port 8080
+ -->
+ <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
+ <!-- A "Connector" using the shared thread pool-->
+ <!--
+ <Connector executor="tomcatThreadPool"
+ port="8080" protocol="HTTP/1.1"
+ connectionTimeout="20000"
+ redirectPort="8443" />
+ -->
+ <!-- Define a SSL HTTP/1.1 Connector on port 8443
+ This connector uses the JSSE configuration, when using APR, the
+ connector should be using the OpenSSL style configuration
+ described in the APR documentation -->
+ <!--
+ <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
+ maxThreads="150" scheme="https" secure="true"
+ clientAuth="false" sslProtocol="TLS" />
+ -->
+ <Connector port="8443" maxHttpHeaderSize="8192"
+ maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
+ enableLookups="true" disableUploadTimeout="true"
+ acceptCount="100" scheme="https" secure="true" SSLEnabled="true"
+ clientAuth="true"
+ keystoreFile="${catalina.home}/conf/certs/rest_api_test.jks"
+ keystoreType="JKS"
+ keystorePass="password"
+ truststoreFile="${catalina.home}/conf/certs/rest_api_test.jks"
+ truststoreType="JKS"
+ truststorePass="password"
+ SSLVerifyClient="require" SSLVerifyDepth="2" SSLEngine="on" sslProtocol="TLS" />
+
+ <!-- Define an AJP 1.3 Connector on port 8009 -->
+ <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
+
+
+ <!-- An Engine represents the entry point (within Catalina) that processes
+ every request. The Engine implementation for Tomcat stand alone
+ analyzes the HTTP headers included with the request, and passes them
+ on to the appropriate Host (virtual host).
+ Documentation at /docs/config/engine.html -->
+
+ <!-- You should set jvmRoute to support load-balancing via AJP ie :
+ <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
+ -->
+ <Engine defaultHost="localhost" name="Catalina">
+
+ <!--For clustering, please take a look at documentation at:
+ /docs/cluster-howto.html (simple how to)
+ /docs/config/cluster.html (reference documentation) -->
+ <!--
+ <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
+ -->
+
+ <!-- The request dumper valve dumps useful debugging information about
+ the request and response data received and sent by Tomcat.
+ Documentation at: /docs/config/valve.html -->
+ <!--
+ <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
+ -->
+
+ <!-- This Realm uses the UserDatabase configured in the global JNDI
+ resources under the key "UserDatabase". Any edits
+ that are performed against this UserDatabase are immediately
+ available for use by the Realm. -->
+ <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
+
+ <!-- Define the default virtual host
+ Note: XML Schema validation will not work with Xerces 2.2.
+ -->
+ <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
+
+ <!-- SingleSignOn valve, share authentication between web applications
+ Documentation at: /docs/config/valve.html -->
+ <!--
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+ -->
+
+ <!-- Access log processes all example.
+ Documentation at: /docs/config/valve.html -->
+ <!--
+ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
+ prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
+ -->
+
+ <Context docBase="/Users/wb/sandbox/candlepin/proxy/code/webapp" path="" reloadable="true"/></Host>
+ </Engine>
+ </Service>
+</Server> \ No newline at end of file
diff --git a/rel-eng/tito.props b/rel-eng/tito.props
deleted file mode 100644
index 9137b21..0000000
--- a/rel-eng/tito.props
+++ /dev/null
@@ -1,3 +0,0 @@
-[globalconfig]
-default_builder = spacewalk.releng.builder.Builder
-default_tagger = spacewalk.releng.tagger.VersionTagger