use of org.candlepin.pki.impl.BouncyCastlePKIUtility in project candlepin by candlepin.
the class ImporterTest method importConsumer.
@Test
public void importConsumer() throws Exception {
PKIUtility pki = new BouncyCastlePKIUtility(null, null, null);
OwnerCurator oc = mock(OwnerCurator.class);
ConsumerType type = new ConsumerType(ConsumerTypeEnum.CANDLEPIN);
type.setId("test-ctype");
when(consumerTypeCurator.lookupByLabel(eq("candlepin"))).thenReturn(type);
when(consumerTypeCurator.find(eq(type.getId()))).thenReturn(type);
Importer i = new Importer(consumerTypeCurator, null, null, oc, mock(IdentityCertificateCurator.class), null, null, pki, null, null, mock(CertificateSerialCurator.class), null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
File[] upstream = createUpstreamFiles();
Owner owner = new Owner("admin", "Admin Owner");
ConsumerDTO consumerDTO = new ConsumerDTO();
consumerDTO.setUuid("eb5e04bf-be27-44cf-abe3-0c0b1edd523e");
consumerDTO.setName("mymachine");
ConsumerTypeDTO typeDTO = new ConsumerTypeDTO();
typeDTO.setLabel("candlepin");
typeDTO.setManifest(true);
consumerDTO.setType(typeDTO);
consumerDTO.setUrlWeb("foo.example.com/subscription");
consumerDTO.setUrlApi("/candlepin");
consumerDTO.setContentAccessMode("access_mode");
OwnerDTO ownerDTO = new OwnerDTO();
ownerDTO.setKey("admin");
ownerDTO.setDisplayName("Admin Owner");
consumerDTO.setOwner(ownerDTO);
File consumerfile = new File(folder.getRoot(), "consumer.json");
mapper.writeValue(consumerfile, consumerDTO);
ConflictOverrides forcedConflicts = mock(ConflictOverrides.class);
when(forcedConflicts.isForced(any(Importer.Conflict.class))).thenReturn(false);
Meta meta = new Meta("1.0", new Date(), "admin", "/candlepin/owners", null);
i.importConsumer(owner, consumerfile, upstream, forcedConflicts, meta);
verify(oc).merge(eq(owner));
}
use of org.candlepin.pki.impl.BouncyCastlePKIUtility in project candlepin by candlepin.
the class DefaultEntitlementCertServiceAdapterTest method testDetachedEntitlementDataNotAddedToCertV1.
@Test
public void testDetachedEntitlementDataNotAddedToCertV1() throws Exception {
KeyPair keyPair = new BouncyCastlePKIUtility(null, null, null).generateNewKeyPair();
when(keyPairCurator.getConsumerKeyPair(any(Consumer.class))).thenReturn(keyPair);
when(mockedPKI.getPemEncoded(any(X509Certificate.class))).thenReturn("".getBytes());
when(mockedPKI.getPemEncoded(any(Key.class))).thenReturn("".getBytes());
final CertificateSerial serial = mock(CertificateSerial.class);
when(serial.getId()).thenReturn(1L);
pool.setId("poolId");
doAnswer(new Answer<Map<String, CertificateSerial>>() {
@Override
public Map<String, CertificateSerial> answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
Map<String, CertificateSerial> map = (Map<String, CertificateSerial>) args[0];
map.put("poolId", serial);
return null;
}
}).when(serialCurator).saveOrUpdateAll(anyMap());
EntitlementCertificate cert = certServiceAdapter.generateEntitlementCert(entitlement, product);
assertTrue(!cert.getCert().contains("ENTITLEMENT DATA"));
}
Aggregations