Search in sources :

Example 1 with BindUserCreateRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest in project cloudbreak by hortonworks.

the class StartBindUserCreationService method createRequest.

private BindUserCreateRequest createRequest(StackView stackView) {
    BindUserCreateRequest request = new BindUserCreateRequest();
    request.setEnvironmentCrn(stackView.getEnvironmentCrn());
    request.setBindUserNameSuffix(stackView.getName());
    return request;
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest)

Example 2 with BindUserCreateRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest in project cloudbreak by hortonworks.

the class StartBindUserCreationService method invokeCreateBindUser.

private OperationStatus invokeCreateBindUser(StackView stackView) {
    BindUserCreateRequest request = createRequest(stackView);
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    return ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> freeIpaV1Endpoint.createBindUser(request, userCrn));
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest)

Example 3 with BindUserCreateRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest in project cloudbreak by hortonworks.

the class BindUserCreateServiceTest method testCreateStartedFLowNotified.

@Test
public void testCreateStartedFLowNotified() {
    BindUserCreateRequest request = createRequest();
    Operation operation = new Operation();
    operation.setOperationId("op");
    operation.setStatus(OperationState.RUNNING);
    when(operationService.startOperation(eq(ACCOUNT), eq(OperationType.BIND_USER_CREATE), anyCollection(), anyCollection())).thenReturn(operation);
    OperationStatus operationStatus = new OperationStatus();
    when(operationConverter.convert(operation)).thenReturn(operationStatus);
    OperationStatus response = underTest.createBindUser(ACCOUNT, request);
    assertEquals(operationStatus, response);
    ArgumentCaptor<Acceptable> captor = ArgumentCaptor.forClass(Acceptable.class);
    verify(flowManager).notify(eq(CREATE_BIND_USER_EVENT.event()), captor.capture());
    Acceptable event = captor.getValue();
    assertTrue(event instanceof CreateBindUserEvent);
    CreateBindUserEvent bindUserEvent = (CreateBindUserEvent) event;
    assertEquals(CREATE_BIND_USER_EVENT.event(), bindUserEvent.selector());
    assertEquals(STACK_ID, bindUserEvent.getResourceId());
    assertEquals(ACCOUNT, bindUserEvent.getAccountId());
    assertEquals(operation.getOperationId(), bindUserEvent.getOperationId());
    assertEquals(request.getEnvironmentCrn(), bindUserEvent.getEnvironmentCrn());
    assertEquals(request.getBindUserNameSuffix(), bindUserEvent.getSuffix());
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest) OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) Acceptable(com.sequenceiq.cloudbreak.common.event.Acceptable) CreateBindUserEvent(com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent) Operation(com.sequenceiq.freeipa.entity.Operation) Test(org.junit.jupiter.api.Test)

Example 4 with BindUserCreateRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest in project cloudbreak by hortonworks.

the class StartBindUserCreationServiceTest method verifyAll.

@AfterEach
public void verifyAll() {
    ArgumentCaptor<BindUserCreateRequest> argumentCaptor = ArgumentCaptor.forClass(BindUserCreateRequest.class);
    verify(freeIpaV1Endpoint).createBindUser(argumentCaptor.capture(), eq(USER_CRN));
    BindUserCreateRequest request = argumentCaptor.getValue();
    assertEquals(ENV_CRN, request.getEnvironmentCrn());
    assertEquals(STACK_NAME, request.getBindUserNameSuffix());
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest) AfterEach(org.junit.jupiter.api.AfterEach)

Example 5 with BindUserCreateRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest in project cloudbreak by hortonworks.

the class BindUserCreateServiceTest method createRequest.

private BindUserCreateRequest createRequest() {
    BindUserCreateRequest request = new BindUserCreateRequest();
    request.setEnvironmentCrn(ENV_CRN);
    request.setBindUserNameSuffix("suffix");
    return request;
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest)

Aggregations

BindUserCreateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest)8 OperationStatus (com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus)4 Operation (com.sequenceiq.freeipa.entity.Operation)3 Test (org.junit.jupiter.api.Test)3 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)2 SyncOperationStatus (com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus)1 CreateBindUserEvent (com.sequenceiq.freeipa.flow.freeipa.binduser.create.event.CreateBindUserEvent)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 AfterEach (org.junit.jupiter.api.AfterEach)1