Search in sources :

Example 6 with BindUserCreateRequest

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

the class BindUserCreateServiceTest method testOperationRejected.

@Test
public void testOperationRejected() {
    BindUserCreateRequest request = createRequest();
    Operation operation = new Operation();
    operation.setOperationId("op");
    operation.setStatus(OperationState.REJECTED);
    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);
    verifyNoInteractions(flowManager);
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest) OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) Operation(com.sequenceiq.freeipa.entity.Operation) Test(org.junit.jupiter.api.Test)

Example 7 with BindUserCreateRequest

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

the class BindUserCreateServiceTest method testFlowRejected.

@Test
public void testFlowRejected() {
    BindUserCreateRequest request = createRequest();
    Operation operation = new Operation();
    operation.setOperationId("op");
    operation.setStatus(OperationState.RUNNING);
    Operation failedOperation = new Operation();
    failedOperation.setOperationId("op");
    failedOperation.setStatus(OperationState.FAILED);
    when(operationService.startOperation(eq(ACCOUNT), eq(OperationType.BIND_USER_CREATE), anyCollection(), anyCollection())).thenReturn(operation);
    when(operationService.failOperation(ACCOUNT, operation.getOperationId(), "Couldn't start create bind user flow: Flow failure")).thenReturn(failedOperation);
    OperationStatus failedOperationStatus = new OperationStatus();
    failedOperationStatus.setStatus(OperationState.FAILED);
    when(operationConverter.convert(failedOperation)).thenReturn(failedOperationStatus);
    when(flowManager.notify(anyString(), any(Acceptable.class))).thenThrow(new RuntimeException("Flow failure"));
    OperationStatus response = underTest.createBindUser(ACCOUNT, request);
    assertEquals(failedOperationStatus, response);
}
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) Operation(com.sequenceiq.freeipa.entity.Operation) Test(org.junit.jupiter.api.Test)

Example 8 with BindUserCreateRequest

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

the class FreeIpaUpgradeTests method createBindUser.

private void createBindUser(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        BindUserCreateRequest bindUserCreateRequest = new BindUserCreateRequest();
        bindUserCreateRequest.setEnvironmentCrn(environmentCrn);
        bindUserCreateRequest.setBindUserNameSuffix("testuser");
        String initiatorUserCrn = "__internal__actor__";
        OperationStatus operationStatus = ipaClient.getFreeIpaV1Endpoint().createE2ETestBindUser(bindUserCreateRequest, initiatorUserCrn);
        waitToCompleted(testContext, operationStatus.getOperationId(), "createBindUserOperation");
    } catch (Exception e) {
        logger.error("CREATE BIND USER test failed during upgrade", e);
        throw new TestFailException("CREATE BIND USER test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : BindUserCreateRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.binduser.BindUserCreateRequest) OperationStatus(com.sequenceiq.freeipa.api.v1.operation.model.OperationStatus) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

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