use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent in project cloudbreak by hortonworks.
the class CreateBindUserActions method createLdapBindUserAction.
@Bean("CREATE_LDAP_BIND_USER_STATE")
public Action<?, ?> createLdapBindUserAction() {
return new AbstractBindUserCreateAction<>(CreateBindUserEvent.class) {
@Override
protected void doExecute(CommonContext context, CreateBindUserEvent payload, Map<Object, Object> variables) {
LOGGER.info("Sending request to create LDAP bind user for {}", payload.getSuffix());
sendEvent(context, new CreateLdapBindUserEvent(payload));
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent in project cloudbreak by hortonworks.
the class LdapBindUserCreationHandlerTest method testDefaultFailureEventCreation.
@Test
public void testDefaultFailureEventCreation() {
CreateBindUserEvent createBindUserEvent = new CreateBindUserEvent("selector", 1L, "acc", "opid", "suffix", "envcrn");
CreateLdapBindUserEvent createLdapBindUserEvent = new CreateLdapBindUserEvent(createBindUserEvent);
Exception exception = new Exception("test");
Selectable result = underTest.defaultFailureEvent(1L, exception, new Event<>(createLdapBindUserEvent));
assertTrue(result instanceof CreateBindUserFailureEvent);
CreateBindUserFailureEvent failureEvent = (CreateBindUserFailureEvent) result;
assertEquals(CreateBindUserFlowEvent.CREATE_BIND_USER_FAILED_EVENT.event(), failureEvent.selector());
assertEquals("LDAP bind user creation failed for suffix with test", failureEvent.getFailureMessage());
assertEquals(exception, failureEvent.getException());
}
use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent 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);
}
use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent 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);
}
use of com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateLdapBindUserEvent 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);
}
Aggregations