use of com.sequenceiq.freeipa.service.freeipa.host.HostDeletionService in project cloudbreak by hortonworks.
the class KeytabCleanupServiceTest method testDeleteHost.
@Test
public void testDeleteHost() throws Exception {
Set<Service> services = new HashSet<>();
services.add(service);
FreeIpaClient mockIpaClient = Mockito.mock(FreeIpaClient.class);
HostRequest request = new HostRequest();
request.setEnvironmentCrn(ENVIRONMENT_ID);
request.setServerHostName(HOST);
request.setClusterCrn(CLUSTER_ID);
request.setRoleName(ROLE);
when(freeIpaClientFactory.getFreeIpaClientByAccountAndEnvironment(anyString(), anyString())).thenReturn(mockIpaClient);
when(mockIpaClient.findAllService()).thenReturn(services);
underTest.deleteHost(request, ACCOUNT_ID);
verify(mockIpaClient).deleteService(SERVICE_PRINCIPAL);
verify(hostDeletionService).deleteHostsWithDeleteException(mockIpaClient, Set.of(HOST));
verify(vaultComponent).recursivelyCleanupVault("accountId/ServiceKeytab/serviceprincipal/12345-6789/54321-9876/host1/");
verify(vaultComponent).recursivelyCleanupVault("accountId/ServiceKeytab/keytab/12345-6789/54321-9876/host1/");
verify(vaultComponent).recursivelyCleanupVault("accountId/HostKeytab/serviceprincipal/12345-6789/54321-9876/host1");
verify(vaultComponent).recursivelyCleanupVault("accountId/HostKeytab/keytab/12345-6789/54321-9876/host1");
verify(roleComponent).deleteRoleIfItIsNoLongerUsed(ROLE, mockIpaClient);
verify(keytabCacheService).deleteByEnvironmentCrnAndPrincipal(ENVIRONMENT_ID, SERVICE_PRINCIPAL);
}
Aggregations