use of org.candlepin.service.IdentityCertServiceAdapter in project candlepin by candlepin.
the class ConsumerResourceTest method testIdCertGetsRegenerated.
@Test
public void testIdCertGetsRegenerated() throws Exception {
// using lconsumer simply to avoid hiding consumer. This should
// get renamed once we refactor this test suite.
IdentityCertServiceAdapter mockIdSvc = Mockito.mock(IdentityCertServiceAdapter.class);
EventSink sink = Mockito.mock(EventSinkImpl.class);
SubscriptionServiceAdapter ssa = Mockito.mock(SubscriptionServiceAdapter.class);
ComplianceRules rules = Mockito.mock(ComplianceRules.class);
Consumer consumer = createConsumer(createOwner());
ComplianceStatus status = new ComplianceStatus();
when(rules.getStatus(any(Consumer.class), any(Date.class), anyBoolean())).thenReturn(status);
// cert expires today which will trigger regen
consumer.setIdCert(createIdCert());
BigInteger origserial = consumer.getIdCert().getSerial().getSerial();
when(mockIdSvc.regenerateIdentityCert(consumer)).thenReturn(createIdCert());
ConsumerResource cr = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, ssa, this.mockOwnerServiceAdapter, null, mockIdSvc, null, null, sink, eventFactory, null, null, null, null, null, mockOwnerCurator, null, null, rules, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
ConsumerDTO c = cr.getConsumer(consumer.getUuid());
assertFalse(origserial.equals(c.getIdCert().getSerial().getSerial()));
}
use of org.candlepin.service.IdentityCertServiceAdapter in project candlepin by candlepin.
the class ConsumerResourceTest method testRegenerateIdCerts.
@Test
public void testRegenerateIdCerts() throws GeneralSecurityException, IOException {
// using lconsumer simply to avoid hiding consumer. This should
// get renamed once we refactor this test suite.
IdentityCertServiceAdapter mockIdSvc = Mockito.mock(IdentityCertServiceAdapter.class);
EventSink sink = Mockito.mock(EventSinkImpl.class);
Consumer consumer = createConsumer(createOwner());
consumer.setIdCert(createIdCert());
IdentityCertificate ic = consumer.getIdCert();
assertNotNull(ic);
when(mockIdSvc.regenerateIdentityCert(consumer)).thenReturn(createIdCert());
ConsumerResource cr = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, null, mockIdSvc, null, null, sink, eventFactory, null, null, null, null, null, mockOwnerCurator, null, null, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
ConsumerDTO fooc = cr.regenerateIdentityCertificates(consumer.getUuid());
assertNotNull(fooc);
CertificateDTO ic1 = fooc.getIdCert();
assertNotNull(ic1);
assertFalse(ic.getId().equals(ic1.getId()));
}
Aggregations