Search in sources :

Example 6 with AcceptResult

use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.

the class BindUserCreateOperationAcceptorTest method testMissingEnv.

@Test
public void testMissingEnv() {
    Operation currentOperation = createCurrentOperation();
    currentOperation.setEnvironmentList(null);
    when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(currentOperation));
    AcceptResult result = underTest.accept(currentOperation);
    assertFalse(result.isAccepted());
    assertEquals("Bind user create must run only for one environment!", result.getRejectionMessage().get());
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) AcceptResult(com.sequenceiq.freeipa.service.freeipa.user.AcceptResult) Test(org.junit.jupiter.api.Test)

Example 7 with AcceptResult

use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.

the class BindUserCreateOperationAcceptorTest method testMultipleSuffix.

@Test
public void testMultipleSuffix() {
    Operation currentOperation = createCurrentOperation();
    currentOperation.setUserList(List.of(SUFFIX, "cluster2"));
    when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(currentOperation));
    AcceptResult result = underTest.accept(currentOperation);
    assertFalse(result.isAccepted());
    assertEquals("Bind user create must run only for one suffix!", result.getRejectionMessage().get());
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) AcceptResult(com.sequenceiq.freeipa.service.freeipa.user.AcceptResult) Test(org.junit.jupiter.api.Test)

Example 8 with AcceptResult

use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.

the class BindUserCreateOperationAcceptorTest method testSameEnvDifferentSuffixIsAccepted.

@Test
public void testSameEnvDifferentSuffixIsAccepted() {
    Operation runningOperation = createCurrentOperation();
    runningOperation.setId(0L);
    runningOperation.setOperationId("other");
    runningOperation.setUserList(List.of("cluster2"));
    Operation currentOperation = createCurrentOperation();
    when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(runningOperation, currentOperation));
    AcceptResult result = underTest.accept(currentOperation);
    assertTrue(result.isAccepted());
    assertTrue(result.getRejectionMessage().isEmpty());
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) AcceptResult(com.sequenceiq.freeipa.service.freeipa.user.AcceptResult) Test(org.junit.jupiter.api.Test)

Example 9 with AcceptResult

use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.

the class BindUserCreateOperationAcceptorTest method testMissingSuffix.

@Test
public void testMissingSuffix() {
    Operation currentOperation = createCurrentOperation();
    currentOperation.setUserList(null);
    when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(currentOperation));
    AcceptResult result = underTest.accept(currentOperation);
    assertFalse(result.isAccepted());
    assertEquals("Bind user create must run only for one suffix!", result.getRejectionMessage().get());
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) AcceptResult(com.sequenceiq.freeipa.service.freeipa.user.AcceptResult) Test(org.junit.jupiter.api.Test)

Example 10 with AcceptResult

use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.

the class BindUserCreateOperationAcceptorTest method testRejectedAlreadyRunning.

@Test
public void testRejectedAlreadyRunning() {
    Operation runningOperation = createCurrentOperation();
    runningOperation.setId(0L);
    runningOperation.setOperationId("other");
    Operation currentOperation = createCurrentOperation();
    when(repository.findRunningByAccountIdAndType(ACCOUNT, underTest.selector())).thenReturn(List.of(runningOperation, currentOperation));
    AcceptResult result = underTest.accept(currentOperation);
    assertFalse(result.isAccepted());
    assertEquals("There is already a running bind user creation for cluster", result.getRejectionMessage().get());
}
Also used : Operation(com.sequenceiq.freeipa.entity.Operation) AcceptResult(com.sequenceiq.freeipa.service.freeipa.user.AcceptResult) Test(org.junit.jupiter.api.Test)

Aggregations

Operation (com.sequenceiq.freeipa.entity.Operation)11 AcceptResult (com.sequenceiq.freeipa.service.freeipa.user.AcceptResult)11 Test (org.junit.jupiter.api.Test)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)2