Search in sources :

Example 16 with CreateBindUserEvent

use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent 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)

Example 17 with CreateBindUserEvent

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

the class LdapBindUserCreationHandlerTest method testEventSentIfConfigAlreadyExists.

@Test
public void testEventSentIfConfigAlreadyExists() {
    CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
    CreateLdapBindUserEvent createLdapBindUserEvent = new CreateLdapBindUserEvent(createBindUserEvent);
    HandlerEvent<CreateLdapBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createLdapBindUserEvent));
    when(ldapConfigService.find(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId(), createBindUserEvent.getSuffix())).thenReturn(Optional.of(new LdapConfig()));
    Selectable selectable = underTest.doAccept(handlerEvent);
    assertTrue(selectable instanceof CreateBindUserEvent);
    CreateBindUserEvent event = (CreateBindUserEvent) selectable;
    assertEquals(CreateBindUserFlowEvent.CREATE_LDAP_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(ldapConfigV1Service);
}
Also used : LdapConfig(com.sequenceiq.freeipa.ldap.LdapConfig) 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) CreateLdapBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent) Test(org.junit.jupiter.api.Test)

Example 18 with CreateBindUserEvent

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

the class LdapBindUserCreationHandlerTest method testCreated.

@Test
public void testCreated() throws FreeIpaClientException {
    CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
    CreateLdapBindUserEvent createLdapBindUserEvent = new CreateLdapBindUserEvent(createBindUserEvent);
    HandlerEvent<CreateLdapBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createLdapBindUserEvent));
    when(ldapConfigService.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_LDAP_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(ldapConfigV1Service).createNewLdapConfig(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getSuffix(), stack, true);
}
Also used : 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) CreateLdapBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 19 with CreateBindUserEvent

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

the class LdapBindUserCreationHandlerTest method testCreateFailed.

@Test
public void testCreateFailed() throws FreeIpaClientException {
    CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
    CreateLdapBindUserEvent createLdapBindUserEvent = new CreateLdapBindUserEvent(createBindUserEvent);
    HandlerEvent<CreateLdapBindUserEvent> handlerEvent = new HandlerEvent<>(new Event<>(createLdapBindUserEvent));
    when(ldapConfigService.find(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId(), createBindUserEvent.getSuffix())).thenReturn(Optional.empty());
    Stack stack = new Stack();
    when(stackService.getByEnvironmentCrnAndAccountId(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getAccountId())).thenReturn(stack);
    when(ldapConfigV1Service.createNewLdapConfig(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(ldapConfigV1Service).createNewLdapConfig(createBindUserEvent.getEnvironmentCrn(), createBindUserEvent.getSuffix(), stack, true);
}
Also used : 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) CreateLdapBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

CreateBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)19 Test (org.junit.jupiter.api.Test)9 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)8 HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)6 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)6 Stack (com.sequenceiq.freeipa.entity.Stack)6 CreateKerberosBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateKerberosBindUserEvent)5 CreateLdapBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent)5 CreateBindUserFailureEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserFailureEvent)4 CommonContext (com.sequenceiq.flow.core.CommonContext)3 Map (java.util.Map)3 Bean (org.springframework.context.annotation.Bean)3 KerberosConfig (com.sequenceiq.freeipa.kerberos.KerberosConfig)2 LdapConfig (com.sequenceiq.freeipa.ldap.LdapConfig)2 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)1 BindUserCreateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest)1 SuccessDetails (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails)1 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)1 Operation (com.sequenceiq.freeipa.entity.Operation)1 OperationService (com.sequenceiq.freeipa.service.operation.OperationService)1