Search in sources :

Example 21 with CertificateSerial

use of org.candlepin.model.CertificateSerial in project candlepin by candlepin.

the class CertificateSerialTranslatorTest method initSourceObject.

@Override
protected CertificateSerial initSourceObject() {
    CertificateSerial source = new CertificateSerial();
    // ID is automatically generated for this object
    // ID is also used as the serial here
    source.setExpiration(new Date());
    source.setCollected(true);
    source.setRevoked(true);
    return source;
}
Also used : CertificateSerial(org.candlepin.model.CertificateSerial) Date(java.util.Date)

Example 22 with CertificateSerial

use of org.candlepin.model.CertificateSerial in project candlepin by candlepin.

the class CdnManagerTest method cdnCertSerialIsRevokedOnCdnDeletion.

@Test
public void cdnCertSerialIsRevokedOnCdnDeletion() throws Exception {
    Cdn cdn = createCdn("test_cdn");
    CertificateSerial serial = cdn.getCertificate().getSerial();
    assertNotNull(serial);
    assertFalse(serial.isRevoked());
    manager.deleteCdn(cdn);
    CertificateSerial fetched = certSerialCurator.find(serial.getId());
    assertNotNull(fetched);
    assertTrue(fetched.isRevoked());
}
Also used : CertificateSerial(org.candlepin.model.CertificateSerial) Cdn(org.candlepin.model.Cdn) Test(org.junit.Test)

Example 23 with CertificateSerial

use of org.candlepin.model.CertificateSerial in project candlepin by candlepin.

the class PoolManagerFunctionalTest method testRevocationRevokesEntitlementCertSerial.

@Test
public void testRevocationRevokesEntitlementCertSerial() throws Exception {
    AutobindData data = AutobindData.create(parentSystem, o).on(new Date()).forProducts(new String[] { monitoring.getId() });
    Entitlement e = poolManager.entitleByProducts(data).get(0);
    CertificateSerial serial = e.getCertificates().iterator().next().getSerial();
    poolManager.revokeEntitlement(e);
    List<Entitlement> entitlements = entitlementCurator.listByConsumer(parentSystem);
    assertTrue(entitlements.isEmpty());
    CertificateSerial revoked = certSerialCurator.find(serial.getId());
    assertTrue("Entitlement cert serial should have been marked as revoked once deleted!", revoked.isRevoked());
}
Also used : CertificateSerial(org.candlepin.model.CertificateSerial) AutobindData(org.candlepin.resource.dto.AutobindData) Entitlement(org.candlepin.model.Entitlement) Date(java.util.Date) Test(org.junit.Test)

Example 24 with CertificateSerial

use of org.candlepin.model.CertificateSerial in project candlepin by candlepin.

the class ConsumerResourceTest method createEntitlementCertificate.

protected EntitlementCertificate createEntitlementCertificate(String key, String cert) {
    EntitlementCertificate toReturn = new EntitlementCertificate();
    CertificateSerial certSerial = new CertificateSerial(1L, new Date());
    toReturn.setKeyAsBytes(key.getBytes());
    toReturn.setCertAsBytes(cert.getBytes());
    toReturn.setSerial(certSerial);
    return toReturn;
}
Also used : EntitlementCertificate(org.candlepin.model.EntitlementCertificate) CertificateSerial(org.candlepin.model.CertificateSerial) Date(java.util.Date)

Example 25 with CertificateSerial

use of org.candlepin.model.CertificateSerial in project candlepin by candlepin.

the class CertificateSerialResourceTest method getSerial.

@Test
public void getSerial() {
    CertificateSerialCurator csc = mock(CertificateSerialCurator.class);
    CertificateSerialResource csr = new CertificateSerialResource(csc, this.modelTranslator);
    CertificateSerial cs = new CertificateSerial(10L);
    when(csc.find(cs.getId())).thenReturn(cs);
    CertificateSerialDTO output = csr.getCertificateSerial(10L);
    assertNotNull(output);
    CertificateSerialDTO dto = this.modelTranslator.translate(cs, CertificateSerialDTO.class);
    assertEquals(dto, output);
}
Also used : CertificateSerialDTO(org.candlepin.dto.api.v1.CertificateSerialDTO) CertificateSerial(org.candlepin.model.CertificateSerial) CertificateSerialCurator(org.candlepin.model.CertificateSerialCurator) Test(org.junit.Test)

Aggregations

CertificateSerial (org.candlepin.model.CertificateSerial)46 Date (java.util.Date)23 Test (org.junit.Test)21 Consumer (org.candlepin.model.Consumer)16 IdentityCertificate (org.candlepin.model.IdentityCertificate)16 Entitlement (org.candlepin.model.Entitlement)11 EntitlementCertificate (org.candlepin.model.EntitlementCertificate)11 HashSet (java.util.HashSet)9 CandlepinQuery (org.candlepin.model.CandlepinQuery)9 Owner (org.candlepin.model.Owner)9 File (java.io.File)8 FileInputStream (java.io.FileInputStream)7 InputStream (java.io.InputStream)7 KeyPair (java.security.KeyPair)7 X509Certificate (java.security.cert.X509Certificate)7 ZipInputStream (java.util.zip.ZipInputStream)7 Principal (org.candlepin.auth.Principal)7 ConsumerType (org.candlepin.model.ConsumerType)7 HashMap (java.util.HashMap)6 KeyPair (org.candlepin.model.KeyPair)6