use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CertificatesRotationV4Response in project cloudbreak by hortonworks.
the class CertRotationServiceTest method testStartCertRotation.
@Test
public void testStartCertRotation() {
CertificatesRotationV4Request request = new CertificatesRotationV4Request();
SdxCluster sdxCluster = new SdxCluster();
sdxCluster.setClusterName("testclustername");
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(sdxService.getById(1L)).thenReturn(sdxCluster);
CertificatesRotationV4Response response = new CertificatesRotationV4Response();
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW, "pollid");
response.setFlowIdentifier(flowIdentifier);
when(stackV4Endpoint.rotateAutoTlsCertificates(0L, sdxCluster.getClusterName(), TEST_USER_CRN, request)).thenReturn(response);
ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.startCertRotation(1L, request));
verify(cloudbreakFlowService).saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier);
verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.CERT_ROTATION_IN_PROGRESS, "Datalake cert rotation in progress", sdxCluster);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CertificatesRotationV4Response in project cloudbreak by hortonworks.
the class CertRotationService method startCertRotation.
public void startCertRotation(Long id, CertificatesRotationV4Request request) {
SdxCluster sdxCluster = sdxService.getById(id);
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
try {
CertificatesRotationV4Response response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.rotateAutoTlsCertificates(0L, sdxCluster.getClusterName(), initiatorUserCrn, request));
cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, response.getFlowIdentifier());
updateCertExpirationState(sdxCluster);
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.CERT_ROTATION_IN_PROGRESS, "Datalake cert rotation in progress", sdxCluster);
} catch (WebApplicationException e) {
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
LOGGER.error("Couldn't start certiificate rotation in CB: {}", errorMessage, e);
throw new RuntimeException(errorMessage, e);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CertificatesRotationV4Response in project cloudbreak by hortonworks.
the class ClusterCommonService method rotateAutoTlsCertificates.
public CertificatesRotationV4Response rotateAutoTlsCertificates(NameOrCrn nameOrCrn, Long workspaceId, CertificatesRotationV4Request certificatesRotationV4Request) {
Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
MDCBuilder.buildMdcContext(stack);
validateOperationOnStack(stack, "Certificates rotation");
return new CertificatesRotationV4Response(clusterOperationService.rotateAutoTlsCertificates(stack, certificatesRotationV4Request));
}
Aggregations