Search in sources :

Example 1 with CheckFreeIpaExistsEvent

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");
}
Also used : CheckFreeIpaExistsEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) CheckFreeIpaExistsEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent) Event(reactor.bus.Event) KerberosConfigValidationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.config.KerberosConfigValidationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent) Test(org.junit.jupiter.api.Test)

Example 2 with CheckFreeIpaExistsEvent

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());
}
Also used : CheckFreeIpaExistsEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) CheckFreeIpaExistsEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent) Event(reactor.bus.Event) KerberosConfigValidationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.config.KerberosConfigValidationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 3 with CheckFreeIpaExistsEvent

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());
}
Also used : CheckFreeIpaExistsEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) CheckFreeIpaExistsEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent) Event(reactor.bus.Event) KerberosConfigValidationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.config.KerberosConfigValidationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent) NotFoundException(javax.ws.rs.NotFoundException) ValidateKerberosConfigEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent) Test(org.junit.jupiter.api.Test)

Example 4 with CheckFreeIpaExistsEvent

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);
        }
    };
}
Also used : CheckFreeIpaExistsEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent) StackCreationContext(com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext) AbstractStackCreationAction(com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Optional(java.util.Optional) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

CheckFreeIpaExistsEvent (com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.CheckFreeIpaExistsEvent)4 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)4 StackFailureEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent)4 KerberosConfigValidationEvent (com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.config.KerberosConfigValidationEvent)3 ValidateKerberosConfigEvent (com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.ValidateKerberosConfigEvent)3 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)3 Test (org.junit.jupiter.api.Test)3 Event (reactor.bus.Event)3 NotFoundException (javax.ws.rs.NotFoundException)2 AbstractStackCreationAction (com.sequenceiq.cloudbreak.core.flow2.stack.provision.action.AbstractStackCreationAction)1 StackCreationContext (com.sequenceiq.cloudbreak.core.flow2.stack.start.StackCreationContext)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1