@Test public void testRotateHostCertificates() throws Exception { initTestInput("user"); when(clouderaManagerApiClientProvider.getClouderaManagerClient(clientConfig, GATEWAY_PORT, stack.getCluster().getCloudbreakAmbariUser(), stack.getCluster().getCloudbreakAmbariPassword(), ClouderaManagerApiClientProvider.API_V_31)).thenReturn(apiClient); HostsResourceApi hostsResourceApi = mock(HostsResourceApi.class); BatchResourceApi batchResourceApi = mock(BatchResourceApi.class); when(clouderaManagerApiFactory.getHostsResourceApi(apiClient)).thenReturn(hostsResourceApi); when(clouderaManagerApiFactory.getBatchResourceApi(apiClient)).thenReturn(batchResourceApi); ApiHostList hostList = createApiHostList(); when(hostsResourceApi.readHosts(null, null, "SUMMARY")).thenReturn(hostList); ArgumentCaptor<ApiBatchRequest> batchRequestArgumentCaptor = ArgumentCaptor.forClass(ApiBatchRequest.class); when(batchResourceApi.execute(batchRequestArgumentCaptor.capture())).thenReturn(createApiBatchResponse(hostList, true)); underTest.rotateHostCertificates(); Assert.assertEquals(2, batchRequestArgumentCaptor.getValue().getItems().size()); }
@Override public void rotateHostCertificates() throws CloudbreakException { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig); HostsResourceApi hostsResourceApi = clouderaManagerApiFactory.getHostsResourceApi(client); BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(client); ApiHostList hostList = hostsResourceApi.readHosts(null, null, "SUMMARY"); ApiBatchRequest batchRequest = createHostCertsBatchRequest(hostList); ApiBatchResponse apiBatchResponse = batchResourceApi.execute(batchRequest); processHostCertsBatchResponse(client, apiBatchResponse); } catch (ApiException | ClouderaManagerClientInitException e) { LOGGER.warn("Can't rotate the host certificates", e); throw new CloudbreakException("Can't rotate the host certificates due to: " + e.getMessage()); } }
ClouderaManagerSecurityService implements ClusterSecurityService { @Override public void rotateHostCertificates() throws CloudbreakException { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig); HostsResourceApi hostsResourceApi = clouderaManagerApiFactory.getHostsResourceApi(client); BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(client); ApiHostList hostList = hostsResourceApi.readHosts(null, null, "SUMMARY"); ApiBatchRequest batchRequest = createHostCertsBatchRequest(hostList); ApiBatchResponse apiBatchResponse = batchResourceApi.execute(batchRequest); processHostCertsBatchResponse(client, apiBatchResponse); } catch (ApiException | ClouderaManagerClientInitException e) { LOGGER.warn("Can't rotate the host certificates", e); throw new CloudbreakException("Can't rotate the host certificates due to: " + e.getMessage()); } } }
ClouderaManagerSecurityService implements ClusterSecurityService { @Override public void rotateHostCertificates() throws CloudbreakException { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig); HostsResourceApi hostsResourceApi = clouderaManagerApiFactory.getHostsResourceApi(client); BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(client); ApiHostList hostList = hostsResourceApi.readHosts(null, null, "SUMMARY"); ApiBatchRequest batchRequest = createHostCertsBatchRequest(hostList); ApiBatchResponse apiBatchResponse = batchResourceApi.execute(batchRequest); processHostCertsBatchResponse(client, apiBatchResponse); } catch (ApiException | ClouderaManagerClientInitException e) { LOGGER.warn("Can't rotate the host certificates", e); throw new CloudbreakException("Can't rotate the host certificates due to: " + e.getMessage()); } } ClouderaManagerSecurityService(Stack stack, HttpClientConfig clientConfig); }
ClouderaManagerSecurityService implements ClusterSecurityService { @Override public void rotateHostCertificates() throws CloudbreakException { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig); HostsResourceApi hostsResourceApi = clouderaManagerApiFactory.getHostsResourceApi(client); BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(client); ApiHostList hostList = hostsResourceApi.readHosts(null, null, "SUMMARY"); ApiBatchRequest batchRequest = createHostCertsBatchRequest(hostList); ApiBatchResponse apiBatchResponse = batchResourceApi.execute(batchRequest); processHostCertsBatchResponse(client, apiBatchResponse); } catch (ApiException | ClouderaManagerClientInitException e) { LOGGER.warn("Can't rotate the host certificates", e); throw new CloudbreakException("Can't rotate the host certificates due to: " + e.getMessage()); } } ClouderaManagerSecurityService(Stack stack, HttpClientConfig clientConfig); @Override void replaceUserNamePassword(String newUserName, String newPassword); @Override void updateUserNamePassword(String newPassword); @Override void setupMonitoringUser(); @Override void prepareSecurity(); @Override void disableSecurity(); @Override void deregisterServices(String clusterName); @Override void changeOriginalCredentialsAndCreateCloudbreakUser(boolean ldapConfigured); @Override void setupLdapAndSSO(String primaryGatewayPublicAddress, LdapView ldapConfig, VirtualGroupRequest virtualGroupRequest); @Override String getCloudbreakClusterUserName(); @Override String getCloudbreakClusterPassword(); @Override String getDataplaneClusterUserName(); @Override String getDataplaneClusterPassword(); @Override String getClusterUserProvidedPassword(); @Override String getCertPath(); @Override String getKeystorePath(); @Override String getKeystorePassword(); @Override String getMasterKey(); @Override void rotateHostCertificates(); ApiClient getClient(Integer gatewayPort, String user, String password, HttpClientConfig clientConfig); }
ClouderaManagerSecurityService implements ClusterSecurityService { @Override public void rotateHostCertificates() throws CloudbreakException { Cluster cluster = stack.getCluster(); String user = cluster.getCloudbreakAmbariUser(); String password = cluster.getCloudbreakAmbariPassword(); try { ApiClient client = getClient(stack.getGatewayPort(), user, password, clientConfig); HostsResourceApi hostsResourceApi = clouderaManagerApiFactory.getHostsResourceApi(client); BatchResourceApi batchResourceApi = clouderaManagerApiFactory.getBatchResourceApi(client); ApiHostList hostList = hostsResourceApi.readHosts(null, null, "SUMMARY"); ApiBatchRequest batchRequest = createHostCertsBatchRequest(hostList); ApiBatchResponse apiBatchResponse = batchResourceApi.execute(batchRequest); processHostCertsBatchResponse(client, apiBatchResponse); } catch (ApiException | ClouderaManagerClientInitException e) { LOGGER.warn("Can't rotate the host certificates", e); throw new CloudbreakException("Can't rotate the host certificates due to: " + e.getMessage()); } } ClouderaManagerSecurityService(Stack stack, HttpClientConfig clientConfig); @Override void replaceUserNamePassword(String newUserName, String newPassword); @Override void updateUserNamePassword(String newPassword); @Override void setupMonitoringUser(); @Override void prepareSecurity(); @Override void disableSecurity(); @Override void deregisterServices(String clusterName); @Override void changeOriginalCredentialsAndCreateCloudbreakUser(boolean ldapConfigured); @Override void setupLdapAndSSO(String primaryGatewayPublicAddress, LdapView ldapConfig, VirtualGroupRequest virtualGroupRequest); @Override String getCloudbreakClusterUserName(); @Override String getCloudbreakClusterPassword(); @Override String getDataplaneClusterUserName(); @Override String getDataplaneClusterPassword(); @Override String getClusterUserProvidedPassword(); @Override String getCertPath(); @Override String getKeystorePath(); @Override String getKeystorePassword(); @Override String getMasterKey(); @Override void rotateHostCertificates(); ApiClient getClient(Integer gatewayPort, String user, String password, HttpClientConfig clientConfig);  }