use of com.sequenceiq.freeipa.client.model.Cert in project cloudbreak by hortonworks.
the class CleanupServiceTest method testRevokeCertsWithAlreadyRevokedCertAndNewClusterWithSameName.
@Test
public void testRevokeCertsWithAlreadyRevokedCertAndNewClusterWithSameName() throws FreeIpaClientException {
Set<String> hosts = Set.of("test-wl-1-worker0.env.xyz.wl.cloudera.site", "test-wl-1-worker1.env.xyz.wl.cloudera.site", "test-wl-1-master2.env.xyz.wl.cloudera.site", "test-wl-1-compute3.env.xyz.wl.cloudera.site");
Set<Cert> certs = Set.of(createCert("CN=test-wl-2-master2", 1, false), createCert("CN=test-wl-1-master2", 2, true), createCert("CN=test-wl-1-master2", 20, true), createCert("CN=test-wl-1-master2", 21, false), createCert("CN=test-wl-3-master1", 3, true), createCert("CN=test-datalake-1-master1", 4, false), createCert("CN=ipaserver0.env.xyz.wl.cloudera.site,O=ENV.XYZ.WL.CLOUDERA.SITE", 50, false));
FreeIpaClient freeIpaClient = mock(FreeIpaClient.class);
when(freeIpaClient.findAllCert()).thenReturn(certs);
when(freeIpaClientFactory.getFreeIpaClientForStackId(STACK_ID)).thenReturn(freeIpaClient);
Pair<Set<String>, Map<String, String>> result = cleanupService.revokeCerts(STACK_ID, hosts);
verify(freeIpaClient, times(1)).revokeCert(21);
verifyRevokeNotInvoked(freeIpaClient, 1, 2, 20, 3, 4, 50);
assertEquals(1, result.getFirst().size());
assertEquals(0, result.getSecond().size());
assertTrue(result.getFirst().stream().allMatch("CN=test-wl-1-master2"::equals));
}
use of com.sequenceiq.freeipa.client.model.Cert in project cloudbreak by hortonworks.
the class CleanupServiceTest method testRevokeCertsWithLongCertAndShortHostnames.
@Test
public void testRevokeCertsWithLongCertAndShortHostnames() throws FreeIpaClientException {
Set<String> hosts = Set.of("test-wl-1-worker0", "test-wl-1-worker1", "test-wl-1-master2", "test-wl-1-compute3");
Set<Cert> certs = Set.of(createCert("CN=test-wl-2-master2.env.xyz.wl.cloudera.site", 1, false), createCert("CN=test-wl-1-master2.env.xyz.wl.cloudera.site", 2, false), createCert("CN=test-wl-3-master1.env.xyz.wl.cloudera.site", 3, true), createCert("CN=test-datalake-1-master1.env.xyz.wl.cloudera.site", 4, false), createCert("CN=ipaserver0.env.xyz.wl.cloudera.site,O=ENV.XYZ.WL.CLOUDERA.SITE", 50, false));
FreeIpaClient freeIpaClient = mock(FreeIpaClient.class);
when(freeIpaClient.findAllCert()).thenReturn(certs);
when(freeIpaClientFactory.getFreeIpaClientForStackId(STACK_ID)).thenReturn(freeIpaClient);
Pair<Set<String>, Map<String, String>> result = cleanupService.revokeCerts(STACK_ID, hosts);
verify(freeIpaClient, times(1)).revokeCert(2);
verifyRevokeNotInvoked(freeIpaClient, 1, 3, 4, 50);
assertEquals(1, result.getFirst().size());
assertEquals(0, result.getSecond().size());
assertTrue(result.getFirst().stream().allMatch("CN=test-wl-1-master2.env.xyz.wl.cloudera.site"::equals));
}
Aggregations