Search in sources :

Example 1 with CreateKerberosBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent in project cloudbreak by hortonworks.

the class CreateBindUserActions method createKerberosBindUserAction.

@Bean("CREATE_KERBEROS_BIND_USER_STATE")
public Action<?, ?> createKerberosBindUserAction() {
    return new AbstractBindUserCreateAction<>(CreateBindUserEvent.class) {

        @Override
        protected void doExecute(CommonContext context, CreateBindUserEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Sending request to create Kerberos bind user for {}", payload.getSuffix());
            sendEvent(context, new CreateKerberosBindUserEvent(payload));
        }
    };
}
Also used : CreateKerberosBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent) CommonContext(com.sequenceiq.flow.core.CommonContext) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with CreateKerberosBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandlerTest method testCreated.

@Test
public void testCreated() throws FreeIpaClientException {
    CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
    CreateKerberosBindUserEvent createKerberosBindUserEvent = new CreateKerberosBindUserEvent(createBindUserEvent);
    HandlerEvent<CreateKerberosBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createKerberosBindUserEvent));
    when(kerberosConfigService.find(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId(), createBindUserEvent.getSuffix())).thenReturn(Optional.empty());
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountId(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId())).thenReturn(stack);
    Selectable selectable = underTest.doAccept(handlerEvent);
    assertTrue(selectable instanceof CreateBindUserEvent);
    CreateBindUserEvent event = (CreateBindUserEvent) selectable;
    assertEquals(CreateBindUserFlowEvent.CREATE_KERBEROS_BIND_USER_FINISHED_EVENT.event(), event.selector());
    assertEquals(createBindUserEvent.getOperationId(), event.getOperationId());
    assertEquals(createBindUserEvent.getSuffix(), event.getSuffix());
    assertEquals(createBindUserEvent.getAccountId(), event.getAccountId());
    assertEquals(createBindUserEvent.getResourceId(), event.getResourceId());
    verify(stackService).getByEnvironmentCrnAndAccountId(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId());
    verify(kerberosConfigV1Service).createNewKerberosConfig(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getSuffix(), stack, true);
}
Also used : CreateKerberosBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with CreateKerberosBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandlerTest method testDefaultFailureEventCreation.

@Test
public void testDefaultFailureEventCreation() {
    CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
    CreateKerberosBindUserEvent createKerberosBindUserEvent = new CreateKerberosBindUserEvent(createBindUserEvent);
    Exception exception = new Exception("test");
    Selectable result = underTest.defaultFailureEvent(1L, exception, new Event<>(createKerberosBindUserEvent));
    assertTrue(result instanceof CreateBindUserFailureEvent);
    CreateBindUserFailureEvent failureEvent = (CreateBindUserFailureEvent) result;
    assertEquals(CreateBindUserFlowEvent.CREATE_BIND_USER_FAILED_EVENT.event(), failureEvent.selector());
    assertEquals("Kerberos bind user creation failed for suffix with test", failureEvent.getFailureMessage());
    assertEquals(exception, failureEvent.getException());
}
Also used : CreateKerberosBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) CreateBindUserFailureEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserFailureEvent) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Test(org.junit.jupiter.api.Test)

Example 4 with CreateKerberosBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandlerTest method testCreateFailed.

@Test
public void testCreateFailed() throws FreeIpaClientException {
    CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
    CreateKerberosBindUserEvent createKerberosBindUserEvent = new CreateKerberosBindUserEvent(createBindUserEvent);
    HandlerEvent<CreateKerberosBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createKerberosBindUserEvent));
    when(kerberosConfigService.find(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId(), createBindUserEvent.getSuffix())).thenReturn(Optional.empty());
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountId(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId())).thenReturn(stack);
    when(kerberosConfigV1Service.createNewKerberosConfig(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getSuffix(), stack, true)).thenThrow(new FreeIpaClientException("test"));
    Selectable selectable = underTest.doAccept(handlerEvent);
    assertTrue(selectable instanceof CreateBindUserEvent);
    CreateBindUserEvent event = (CreateBindUserEvent) selectable;
    assertEquals(CreateBindUserFlowEvent.CREATE_BIND_USER_FAILED_EVENT.event(), event.selector());
    assertEquals(createBindUserEvent.getOperationId(), event.getOperationId());
    assertEquals(createBindUserEvent.getSuffix(), event.getSuffix());
    assertEquals(createBindUserEvent.getAccountId(), event.getAccountId());
    assertEquals(createBindUserEvent.getResourceId(), event.getResourceId());
    verify(stackService).getByEnvironmentCrnAndAccountId(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId());
    verify(kerberosConfigV1Service).createNewKerberosConfig(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getSuffix(), stack, true);
}
Also used : CreateKerberosBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 5 with CreateKerberosBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent in project cloudbreak by hortonworks.

the class KerberosBindUserCreationHandlerTest method testEventSentIfConfigAlreadyExists.

@Test
public void testEventSentIfConfigAlreadyExists() {
    CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
    CreateKerberosBindUserEvent createKerberosBindUserEvent = new CreateKerberosBindUserEvent(createBindUserEvent);
    HandlerEvent<CreateKerberosBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createKerberosBindUserEvent));
    when(kerberosConfigService.find(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId(), createBindUserEvent.getSuffix())).thenReturn(Optional.of(new KerberosConfig()));
    Selectable selectable = underTest.doAccept(handlerEvent);
    assertTrue(selectable instanceof CreateBindUserEvent);
    CreateBindUserEvent event = (CreateBindUserEvent) selectable;
    assertEquals(CreateBindUserFlowEvent.CREATE_KERBEROS_BIND_USER_FINISHED_EVENT.event(), event.selector());
    assertEquals(createBindUserEvent.getOperationId(), event.getOperationId());
    assertEquals(createBindUserEvent.getSuffix(), event.getSuffix());
    assertEquals(createBindUserEvent.getAccountId(), event.getAccountId());
    assertEquals(createBindUserEvent.getResourceId(), event.getResourceId());
    verifyNoInteractions(stackService);
    verifyNoInteractions(kerberosConfigV1Service);
}
Also used : CreateKerberosBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) KerberosConfig(com.sequenceiq.freeipa.kerberos.KerberosConfig) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) Test(org.junit.jupiter.api.Test)

Aggregations

CreateBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)5 CreateKerberosBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent)5 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)4 Test (org.junit.jupiter.api.Test)4 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)3 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)2 Stack (com.sequenceiq.freeipa.entity.Stack)2 CommonContext (com.sequenceiq.flow.core.CommonContext)1 CreateBindUserFailureEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserFailureEvent)1 KerberosConfig (com.sequenceiq.freeipa.kerberos.KerberosConfig)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1