use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request in project cloudbreak by hortonworks.
the class SdxAutotlsCertRotationAction method action.
@Override
public SdxTestDto action(TestContext testContext, SdxTestDto testDto, SdxClient client) throws Exception {
CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
Log.when(LOGGER, " SDX endpoint: %s" + client.getDefaultClient().sdxEndpoint() + ", SDX's environment: " + testDto.getRequest().getEnvironment());
Log.whenJson(LOGGER, " SDX autotls cert rotation request: ", certificatesRotationV4Request);
FlowIdentifier flowIdentifier = client.getDefaultClient().sdxEndpoint().rotateAutoTlsCertificatesByName(testDto.getName(), new CertificatesRotationV4Request());
testDto.setFlow("SDX autotls cert rotation", flowIdentifier);
SdxClusterDetailResponse detailedResponse = client.getDefaultClient().sdxEndpoint().getDetail(testDto.getName(), Collections.emptySet());
testDto.setResponse(detailedResponse);
Log.whenJson(LOGGER, " SDX response after autotls cert rotation: ", detailedResponse);
return testDto;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request in project cloudbreak by hortonworks.
the class ClusterCommonServiceTest method testRotateAutoTlsCertificatesWithNodeFailure.
@Test
public void testRotateAutoTlsCertificatesWithNodeFailure() {
NameOrCrn cluster = NameOrCrn.ofName("cluster");
Stack stack = new Stack();
stack.setName("cluster");
stack.setStackStatus(new StackStatus(stack, NODE_FAILURE));
when(stackService.getByNameOrCrnInWorkspace(cluster, 1L)).thenReturn(stack);
CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.rotateAutoTlsCertificates(cluster, 1L, certificatesRotationV4Request));
assertEquals("Stack 'cluster' is currently in 'NODE_FAILURE' state. Certificates rotation can only be made when the underlying stack is 'AVAILABLE'.", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request in project cloudbreak by hortonworks.
the class CertRotationServiceTest method testStartCertRotationWebAppEx.
@Test
public void testStartCertRotationWebAppEx() {
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);
when(stackV4Endpoint.rotateAutoTlsCertificates(0L, sdxCluster.getClusterName(), TEST_USER_CRN, request)).thenThrow(new WebApplicationException("asdf"));
assertThrows(RuntimeException.class, () -> ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.startCertRotation(1L, request)));
verifyNoInteractions(cloudbreakFlowService);
verifyNoInteractions(sdxStatusService);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request 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.request.CertificatesRotationV4Request in project cloudbreak by hortonworks.
the class ClusterCommonServiceTest method testRotateAutoTls.
@Test
public void testRotateAutoTls() {
NameOrCrn cluster = NameOrCrn.ofName("cluster");
Stack stack = new Stack();
stack.setName("cluster");
stack.setStackStatus(new StackStatus(stack, AVAILABLE));
CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
when(clusterOperationService.rotateAutoTlsCertificates(stack, certificatesRotationV4Request)).thenReturn(new FlowIdentifier(FlowType.FLOW, "1"));
when(stackService.getByNameOrCrnInWorkspace(cluster, 1L)).thenReturn(stack);
underTest.rotateAutoTlsCertificates(cluster, 1L, certificatesRotationV4Request);
verify(clusterOperationService, times(1)).rotateAutoTlsCertificates(stack, certificatesRotationV4Request);
}
Aggregations