use of com.sequenceiq.datalake.flow.cert.renew.event.SdxStartCertRenewalEvent in project cloudbreak by hortonworks.
the class CertRenewalServiceTest method testCertRenewalTriggering.
@Test
public void testCertRenewalTriggering() {
when(sdxCluster.getId()).thenReturn(1L);
when(sdxCluster.getClusterName()).thenReturn("cluster");
underTest.triggerRenewCertificate(sdxCluster, "userCrn");
verify(sdxReactorFlowManager).triggerCertRenewal(captor.capture(), anyString());
SdxStartCertRenewalEvent renewalEvent = captor.getValue();
assertEquals("userCrn", renewalEvent.getUserId());
assertEquals(1L, renewalEvent.getResourceId());
}
use of com.sequenceiq.datalake.flow.cert.renew.event.SdxStartCertRenewalEvent in project cloudbreak by hortonworks.
the class CertRenewalActions method startCertRenewAction.
@Bean(name = "START_CERT_RENEWAL_STATE")
public Action<?, ?> startCertRenewAction() {
return new AbstractSdxAction<>(SdxStartCertRenewalEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxStartCertRenewalEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxStartCertRenewalEvent payload, Map<Object, Object> variables) throws Exception {
LOGGER.info("Start cert renewal.");
SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
if (payload.isInternal()) {
certRenewalService.renewInternalCertificate(sdxCluster);
} else {
certRenewalService.renewCertificate(sdxCluster, payload.getUserId());
}
SdxEvent sdxEvent = new SdxEvent(SdxCertRenewalEvent.CERT_RENEWAL_STARTED_EVENT.event(), payload.getResourceId(), payload.getUserId());
sendEvent(context, sdxEvent);
}
@Override
protected Object getFailurePayload(SdxStartCertRenewalEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return new SdxCertRenewalFailedEvent(payload, ex.getMessage());
}
};
}
use of com.sequenceiq.datalake.flow.cert.renew.event.SdxStartCertRenewalEvent in project cloudbreak by hortonworks.
the class CertRenewalServiceTest method testInternalCertRenewalTriggering.
@Test
public void testInternalCertRenewalTriggering() {
when(sdxCluster.getId()).thenReturn(1L);
when(sdxCluster.getClusterName()).thenReturn("cluster");
when(sdxCluster.getInitiatorUserCrn()).thenReturn("userCrn");
underTest.triggerInternalRenewCertificate(sdxCluster);
verify(sdxReactorFlowManager).triggerCertRenewal(captor.capture(), anyString());
SdxStartCertRenewalEvent renewalEvent = captor.getValue();
assertEquals("userCrn", renewalEvent.getUserId());
assertEquals(1L, renewalEvent.getResourceId());
}
Aggregations