Search in sources :

Example 1 with HostDeletionService

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);
}
Also used : FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) KeytabCacheService(com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCacheService) Service(com.sequenceiq.freeipa.client.model.Service) KeytabCleanupService(com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCleanupService) KeytabCommonService(com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCommonService) HostDeletionService(com.sequenceiq.freeipa.service.freeipa.host.HostDeletionService) HashSet(java.util.HashSet) HostRequest(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostRequest) Test(org.junit.jupiter.api.Test)

Aggregations

HostRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostRequest)1 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)1 Service (com.sequenceiq.freeipa.client.model.Service)1 KeytabCacheService (com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCacheService)1 KeytabCleanupService (com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCleanupService)1 KeytabCommonService (com.sequenceiq.freeipa.kerberosmgmt.v1.KeytabCommonService)1 HostDeletionService (com.sequenceiq.freeipa.service.freeipa.host.HostDeletionService)1 HashSet (java.util.HashSet)1 Test (org.junit.jupiter.api.Test)1