Search in sources :

Example 11 with Cert

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));
}
Also used : Set(java.util.Set) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Cert(com.sequenceiq.freeipa.client.model.Cert) Map(java.util.Map) Test(org.junit.Test)

Example 12 with Cert

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));
}
Also used : Set(java.util.Set) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Cert(com.sequenceiq.freeipa.client.model.Cert) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Cert (com.sequenceiq.freeipa.client.model.Cert)12 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)10 Map (java.util.Map)10 Set (java.util.Set)10 Test (org.junit.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)2 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)1 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)1 PollingService (com.sequenceiq.cloudbreak.polling.PollingService)1 CleanupRequest (com.sequenceiq.freeipa.api.v1.freeipa.cleanup.CleanupRequest)1 HostRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostRequest)1 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)1 OperationType (com.sequenceiq.freeipa.api.v1.operation.model.OperationType)1 FreeIpaClientExceptionUtil (com.sequenceiq.freeipa.client.FreeIpaClientExceptionUtil)1 RetryableFreeIpaClientException (com.sequenceiq.freeipa.client.RetryableFreeIpaClientException)1 DnsRecord (com.sequenceiq.freeipa.client.model.DnsRecord)1 DnsZone (com.sequenceiq.freeipa.client.model.DnsZone)1 Role (com.sequenceiq.freeipa.client.model.Role)1 User (com.sequenceiq.freeipa.client.model.User)1