use of org.candlepin.model.CertificateSerialDto in project candlepin by candlepin.
the class ConsumerResourceTest method testcheckForGuestsMigrationSerialList.
@Test
public void testcheckForGuestsMigrationSerialList() {
Consumer consumer = createConsumer(createOwner());
List<EntitlementCertificate> certificates = createEntitlementCertificates();
when(mockEntitlementCertServiceAdapter.listForConsumer(consumer)).thenReturn(certificates);
when(mockConsumerCurator.verifyAndLookupConsumer(consumer.getUuid())).thenReturn(consumer);
when(mockEntitlementCurator.listByConsumer(consumer)).thenReturn(new ArrayList<>());
ConsumerResource consumerResource = Mockito.spy(new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, mockEntitlementCurator, null, mockEntitlementCertServiceAdapter, null, null, null, null, null, null, mockPoolManager, null, null, null, null, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, mockContentAccessCertService, this.factValidator, null, consumerEnricher, migrationProvider, translator));
List<CertificateSerialDto> serials = consumerResource.getEntitlementCertificateSerials(consumer.getUuid());
verify(consumerResource).revokeOnGuestMigration(consumer);
}
use of org.candlepin.model.CertificateSerialDto in project candlepin by candlepin.
the class ConsumerResourceTest method testGetCertSerials.
@Test
public void testGetCertSerials() {
Consumer consumer = createConsumer(createOwner());
List<EntitlementCertificate> certificates = createEntitlementCertificates();
List<Long> serialIds = new ArrayList<>();
for (EntitlementCertificate ec : certificates) {
serialIds.add(ec.getSerial().getId());
}
when(mockEntitlementCertServiceAdapter.listEntitlementSerialIds(consumer)).thenReturn(serialIds);
when(mockEntitlementCurator.listByConsumer(consumer)).thenReturn(new ArrayList<>());
ConsumerResource consumerResource = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, mockEntitlementCurator, null, mockEntitlementCertServiceAdapter, null, null, null, null, null, null, mockPoolManager, null, null, null, null, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, mockContentAccessCertService, this.factValidator, null, consumerEnricher, migrationProvider, translator);
List<CertificateSerialDto> serials = consumerResource.getEntitlementCertificateSerials(consumer.getUuid());
verifyCertificateSerialNumbers(serials);
}
use of org.candlepin.model.CertificateSerialDto in project candlepin by candlepin.
the class ConsumerResource method getEntitlementCertificateSerials.
@ApiOperation(notes = "Retrieves a list of Certiticate Serials Return the " + "client certificate metadata a for the given consumer. This is a small" + " subset of data clients can use to determine which certificates they" + " need to update/fetch.", value = "getEntitlementCertificateSerials")
@ApiResponses({ @ApiResponse(code = 404, message = "") })
@GET
@Path("{consumer_uuid}/certificates/serials")
@Produces(MediaType.APPLICATION_JSON)
@Wrapped(element = "serials")
@UpdateConsumerCheckIn
public List<CertificateSerialDto> getEntitlementCertificateSerials(@PathParam("consumer_uuid") @Verify(Consumer.class) String consumerUuid) {
log.debug("Getting client certificate serials for consumer: {}", consumerUuid);
Consumer consumer = consumerCurator.verifyAndLookupConsumer(consumerUuid);
ConsumerType ctype = this.consumerTypeCurator.getConsumerType(consumer);
if (ctype.isType(ConsumerTypeEnum.SHARE)) {
logShareConsumerRequestWarning("cert serial fetch", consumer);
return new ArrayList<>();
}
revokeOnGuestMigration(consumer);
poolManager.regenerateDirtyEntitlements(consumer);
List<CertificateSerialDto> allCerts = new LinkedList<>();
for (Long id : entCertService.listEntitlementSerialIds(consumer)) {
allCerts.add(new CertificateSerialDto(id));
}
// add content access cert if needed
try {
ContentAccessCertificate cac = contentAccessCertService.getCertificate(consumer);
if (cac != null) {
allCerts.add(new CertificateSerialDto(cac.getSerial().getId()));
}
} catch (IOException ioe) {
throw new BadRequestException(i18n.tr("Cannot retrieve content access certificate"), ioe);
} catch (GeneralSecurityException gse) {
throw new BadRequestException(i18n.tr("Cannot retrieve content access certificate", gse));
}
return allCerts;
}
Aggregations