use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent in project cloudbreak by hortonworks.
the class CheckFreeIpaExistsHandlerTest method testFreeIpaExists.
@Test
public void testFreeIpaExists() {
Event<CheckFreeIpaExistsEvent> event = new Event<>(new CheckFreeIpaExistsEvent(1L));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
StackEvent result = (StackEvent) ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.doAccept(new HandlerEvent<>(event)));
assertEquals(KerberosConfigValidationEvent.FREEIPA_EXISTS_EVENT.event(), result.selector());
assertEquals(1L, result.getResourceId());
verify(freeIpaV1Endpoint).describeInternal(ENV_CRN, "1234");
}
use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent in project cloudbreak by hortonworks.
the class CheckFreeIpaExistsHandlerTest method testDefaultFailureEvent.
@Test
public void testDefaultFailureEvent() {
Event<CheckFreeIpaExistsEvent> event = new Event<>(new CheckFreeIpaExistsEvent(1L));
Exception e = new Exception();
StackFailureEvent result = (StackFailureEvent) underTest.defaultFailureEvent(1L, e, event);
assertEquals(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), result.selector());
assertEquals(1L, result.getResourceId());
assertEquals(e, result.getException());
}
use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent in project cloudbreak by hortonworks.
the class CheckFreeIpaExistsHandlerTest method testFreeIpaDontExists.
@Test
public void testFreeIpaDontExists() {
Event<CheckFreeIpaExistsEvent> event = new Event<>(new CheckFreeIpaExistsEvent(1L));
when(freeIpaV1Endpoint.describeInternal(ENV_CRN, "1234")).thenThrow(new NotFoundException());
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ValidateKerberosConfigEvent result = (ValidateKerberosConfigEvent) ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.doAccept(new HandlerEvent<>(event)));
assertEquals(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_EXISTS_EVENT.event(), result.selector());
assertEquals(1L, result.getResourceId());
assertFalse(result.doesFreeipaExistsForEnv());
}
use of com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent in project cloudbreak by hortonworks.
the class KerberosConfigValidationActions method checkFreeIpaExistsAction.
@Bean(name = "CHECK_FREEIPA_EXISTS_STATE")
public Action<?, ?> checkFreeIpaExistsAction() {
return new AbstractStackCreationAction<>(StackEvent.class) {
@Override
protected void doExecute(StackCreationContext context, StackEvent payload, Map<Object, Object> variables) {
CheckFreeIpaExistsEvent event = new CheckFreeIpaExistsEvent(payload.getResourceId());
sendEvent(context, event);
}
@Override
protected Object getFailurePayload(StackEvent payload, Optional<StackCreationContext> flowContext, Exception ex) {
return new StackFailureEvent(KerberosConfigValidationEvent.VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.selector(), payload.getResourceId(), ex);
}
};
}
Aggregations