Search in sources :

Example 11 with User

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());
    });
}
Also used : User(com.sequenceiq.freeipa.client.model.User)

Example 12 with User

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());
}
Also used : User(com.sequenceiq.freeipa.client.model.User) Test(org.junit.jupiter.api.Test)

Example 13 with User

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)));
}
Also used : User(com.sequenceiq.freeipa.client.model.User) UserMetadata(com.sequenceiq.freeipa.service.freeipa.user.model.UserMetadata)

Example 14 with User

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.");
    }
}
Also used : User(com.sequenceiq.freeipa.client.model.User)

Example 15 with User

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;
}
Also used : User(com.sequenceiq.freeipa.client.model.User) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse)

Aggregations

User (com.sequenceiq.freeipa.client.model.User)38 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)15 Test (org.junit.jupiter.api.Test)13 Map (java.util.Map)11 RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)10 Set (java.util.Set)8 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)7 FmsUser (com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser)7 List (java.util.List)7 Test (org.junit.Test)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 UserMetadata (com.sequenceiq.freeipa.service.freeipa.user.model.UserMetadata)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)3 SetPasswordRequest (com.sequenceiq.freeipa.flow.freeipa.user.event.SetPasswordRequest)3 FmsGroup (com.sequenceiq.freeipa.service.freeipa.user.model.FmsGroup)3 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)2 FreeIpaErrorCodes (com.sequenceiq.freeipa.client.FreeIpaErrorCodes)2