use of com.sequenceiq.freeipa.flow.freeipa.user.event.SetPasswordRequest in project cloudbreak by hortonworks.
the class SetPasswordHandlerTest method testWithPasswordHashSupportWithUmsPasswordWithoutUpdateOptimization.
@Test
void testWithPasswordHashSupportWithUmsPasswordWithoutUpdateOptimization() throws FreeIpaClientException, IOException {
SetPasswordRequest request = new SetPasswordRequest(1L, "environment", USER, USER_CRN, "password", Optional.empty());
FreeIpaClient mockFreeIpaClient = newfreeIpaClient(true);
when(freeIpaClientFactory.getFreeIpaClientForStack(any())).thenReturn(mockFreeIpaClient);
setupMocksForPasswordHashSupport(true, false);
underTest.accept(new Event<>(request));
verify(workloadCredentialService, times(1)).setWorkloadCredential(eq(false), any(), any());
verify(mockFreeIpaClient, times(0)).userSetPasswordWithExpiration(any(), any(), any());
}
use of com.sequenceiq.freeipa.flow.freeipa.user.event.SetPasswordRequest in project cloudbreak by hortonworks.
the class SetPasswordHandlerTest method testWithoutPasswordHashSupport.
@Test
void testWithoutPasswordHashSupport() throws FreeIpaClientException {
SetPasswordRequest request = new SetPasswordRequest(1L, "environment", USER, USER_CRN, "password", Optional.empty());
FreeIpaClient mockFreeIpaClient = newfreeIpaClient(false);
when(freeIpaClientFactory.getFreeIpaClientForStack(any())).thenReturn(mockFreeIpaClient);
underTest.accept(new Event<>(request));
verify(mockFreeIpaClient, times(1)).userSetPasswordWithExpiration(any(), any(), any());
}
use of com.sequenceiq.freeipa.flow.freeipa.user.event.SetPasswordRequest in project cloudbreak by hortonworks.
the class PasswordService method triggerSetPassword.
private SetPasswordRequest triggerSetPassword(Stack stack, String environment, String username, String userCrn, String password, Optional<Instant> expirationInstant) {
SetPasswordRequest request = new SetPasswordRequest(stack.getId(), environment, username, userCrn, password, expirationInstant);
freeIpaFlowManager.notifyNonFlowEvent(request);
return request;
}
use of com.sequenceiq.freeipa.flow.freeipa.user.event.SetPasswordRequest in project cloudbreak by hortonworks.
the class PasswordService method internalSetPasswords.
private void internalSetPasswords(String operationId, String accountId, String userCrn, String password, List<Stack> stacks) {
try {
String userId = getUserIdFromUserCrn(userCrn);
Optional<Instant> expirationInstant = calculateExpirationTime(userCrn, accountId);
List<SetPasswordRequest> requests = new ArrayList<>();
for (Stack stack : stacks) {
requests.add(triggerSetPassword(stack, stack.getEnvironmentCrn(), userId, userCrn, password, expirationInstant));
}
List<SuccessDetails> success = new ArrayList<>();
List<FailureDetails> failure = new ArrayList<>();
for (SetPasswordRequest request : requests) {
try {
waitSetPassword(request);
success.add(new SuccessDetails(request.getEnvironment()));
} catch (InterruptedException e) {
LOGGER.error("Interrupted while setting passwords for user {} in account {}", userCrn, accountId);
throw e;
} catch (Exception e) {
LOGGER.debug("Failed to set password for user {} in environment {}", userCrn, request.getEnvironment(), e);
failure.add(new FailureDetails(request.getEnvironment(), e.getLocalizedMessage()));
}
}
operationService.completeOperation(accountId, operationId, success, failure);
} catch (InterruptedException e) {
operationService.failOperation(accountId, operationId, e.getLocalizedMessage());
Thread.currentThread().interrupt();
} catch (RuntimeException e) {
operationService.failOperation(accountId, operationId, e.getLocalizedMessage());
throw e;
}
}
Aggregations