use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class UserMetadataConverterTest method testToUserMetadataInvalidInput.
private void testToUserMetadataInvalidInput(List<String> inputs) {
inputs.forEach(input -> {
User user = new User();
user.setUid("username");
user.setTitle(input);
assertFalse(underTest.toUserMetadata(user).isPresent());
});
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class UserMetadataConverterTest method testToUserMetadataEmptyJson.
@Test
void testToUserMetadataEmptyJson() {
User user = new User();
user.setUid("username");
assertFalse(underTest.toUserMetadata(user).isPresent());
user.setTitle("");
assertFalse(underTest.toUserMetadata(user).isPresent());
user.setTitle(" ");
assertFalse(underTest.toUserMetadata(user).isPresent());
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class UserMetadataConverterTest method testToUserMetadataValidInput.
private void testToUserMetadataValidInput(String input, String expectedCrn, long expectedWorkloadCredentialsVersion) {
User user = new User();
user.setUid("username");
user.setTitle(input);
Optional<UserMetadata> decoded = underTest.toUserMetadata(user);
assertTrue(decoded.isPresent());
assertEquals(expectedCrn, decoded.get().getCrn());
assertEquals(expectedWorkloadCredentialsVersion, decoded.get().getWorkloadCredentialsVersion());
String encoded = underTest.toUserMetadataJson(decoded.get());
assertTrue(encoded.contains(expectedCrn));
assertTrue(encoded.contains(makeValidEncodedMeta(expectedWorkloadCredentialsVersion)));
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class FreeIpaPostInstallService method modifyAdminPasswordExpirationIfNeeded.
private void modifyAdminPasswordExpirationIfNeeded(FreeIpaClient client) throws FreeIpaClientException {
Optional<User> user = client.userFind(freeIpaClientFactory.getAdminUser());
if (user.isPresent() && !FreeIpaClient.MAX_PASSWORD_EXPIRATION_DATETIME.equals(user.get().getKrbPasswordExpiration())) {
User actualUser = user.get();
LOGGER.debug(String.format("Modifying user [%s] current password expiration time [%s] to [%s]", actualUser.getUid(), actualUser.getKrbPasswordExpiration(), FreeIpaClient.MAX_PASSWORD_EXPIRATION_DATETIME));
client.updateUserPasswordMaxExpiration(actualUser.getUid());
} else if (user.isEmpty()) {
LOGGER.warn(String.format("No [%s] user found!", freeIpaClientFactory.getAdminUser()));
} else {
LOGGER.debug("Password expiration is already set.");
}
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class WorkloadCredentialServiceTest method getRpcResponse.
private RPCResponse<Object> getRpcResponse() {
RPCResponse<Object> response = new RPCResponse<>();
response.setResult(new User());
return response;
}
Aggregations