use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.
the class OperationService method startOperation.
public Operation startOperation(String accountId, OperationType operationType, Collection<String> environmentCrns, Collection<String> userCrns) {
Operation requestedOperation = requestOperation(accountId, operationType, environmentCrns, userCrns);
OperationAcceptor acceptor = operationAcceptorMap.get(operationType);
AcceptResult acceptResult = acceptor.accept(requestedOperation);
if (acceptResult.isAccepted()) {
return acceptOperation(requestedOperation);
} else {
return rejectOperation(requestedOperation, acceptResult.getRejectionMessage().orElse("Rejected for unspecified reason."));
}
}
use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.
the class UpgradeCcmOperationAcceptorTest method acceptTestWhenHasRunningOperationForSameStack.
@Test
void acceptTestWhenHasRunningOperationForSameStack() {
Operation operation = createOperation(ID_1, List.of(ENVIRONMENT_CRN_1));
when(operationRepository.findRunningByAccountIdAndType(ACCOUNT_ID, OperationType.UPGRADE_CCM)).thenReturn(List.of(createOperation(ID_2, List.of(ENVIRONMENT_CRN_1))));
AcceptResult result = underTest.accept(operation);
assertThat(result).isNotNull();
assertThat(result.isAccepted()).isFalse();
Optional<String> rejectionMessage = result.getRejectionMessage();
assertThat(rejectionMessage).isNotNull();
assertThat(rejectionMessage).isPresent();
assertThat(rejectionMessage.get()).isEqualTo("There is already a running Cluster Connectivity Manager upgrade for FreeIPA stack");
}
use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.
the class UpgradeCcmOperationAcceptorTest method acceptTestWhenSuccess.
@ParameterizedTest(name = "{0}")
@MethodSource("acceptTestWhenSuccessDataProvider")
void acceptTestWhenSuccess(String testCaseName, List<Operation> runningOperations) {
Operation operation = createOperation(ID_1, List.of(ENVIRONMENT_CRN_1));
when(operationRepository.findRunningByAccountIdAndType(ACCOUNT_ID, OperationType.UPGRADE_CCM)).thenReturn(runningOperations);
AcceptResult result = underTest.accept(operation);
assertThat(result).isNotNull();
assertThat(result.isAccepted()).isTrue();
}
use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.
the class UpgradeCcmOperationAcceptorTest method acceptTestWhenValidationFailure.
@ParameterizedTest(name = "{0}")
@MethodSource("acceptTestWhenValidationFailureDataProvider")
void acceptTestWhenValidationFailure(String testCaseName, List<String> environmentList) {
Operation operation = createOperation(ID_1, environmentList);
AcceptResult result = underTest.accept(operation);
assertThat(result).isNotNull();
assertThat(result.isAccepted()).isFalse();
Optional<String> rejectionMessage = result.getRejectionMessage();
assertThat(rejectionMessage).isNotNull();
assertThat(rejectionMessage).isPresent();
assertThat(rejectionMessage.get()).isEqualTo("Cluster Connectivity Manager upgrade must be invoked for a single environment!");
}
use of com.sequenceiq.freeipa.service.freeipa.user.AcceptResult in project cloudbreak by hortonworks.
the class BindUserCreateOperationAcceptorTest method testMultipleEnv.
@Test
public void testMultipleEnv() {
Operation currentOperation = createCurrentOperation();
currentOperation.setEnvironmentList(List.of(ENV_CRN, "env2"));
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());
}
Aggregations