Search in sources :

Example 1 with CheckUsersInGroupV1Request

use of com.sequenceiq.freeipa.api.v1.freeipa.test.model.CheckUsersInGroupV1Request in project cloudbreak by hortonworks.

the class FreeIpaFindUsersInGroupAction method action.

public FreeIpaTestDto action(TestContext testContext, FreeIpaTestDto testDto, FreeIpaClient client) throws Exception {
    CheckUsersInGroupV1Request checkUsersInGroupRequest = new CheckUsersInGroupV1Request();
    checkUsersInGroupRequest.setEnvironmentCrn(testDto.getResponse().getEnvironmentCrn());
    checkUsersInGroupRequest.setGroup(group);
    checkUsersInGroupRequest.setUsers(users);
    Log.when(LOGGER, format(" Checking users [%s] are present in group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
    Log.whenJson(LOGGER, format(" FreeIpa '%s' find users in group request:%n ", testDto.getResponse().getCrn()), checkUsersInGroupRequest);
    if (expectedPresence) {
        if (!client.getDefaultClient().getClientTestV1Endpoint().checkUsersInGroup(checkUsersInGroupRequest).getResult()) {
            throw new TestFailException("Given freeipa users cannot be found in the given group, please check FMS logs for details");
        }
        LOGGER.info(format(" Users [%s] are present in group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
        Log.when(LOGGER, format(" Users [%s] are present in group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
    } else {
        if (client.getDefaultClient().getClientTestV1Endpoint().checkUsersInGroup(checkUsersInGroupRequest).getResult()) {
            throw new TestFailException("Given freeipa users have been found in the given group, please check FMS logs for details");
        }
        LOGGER.info(format(" Users [%s] have been removed successfully from group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
        Log.when(LOGGER, format(" Users [%s] have been removed successfully from group '%s' at environment '%s'", users, group, testDto.getResponse().getEnvironmentCrn()));
    }
    return testDto;
}
Also used : TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) CheckUsersInGroupV1Request(com.sequenceiq.freeipa.api.v1.freeipa.test.model.CheckUsersInGroupV1Request)

Aggregations

CheckUsersInGroupV1Request (com.sequenceiq.freeipa.api.v1.freeipa.test.model.CheckUsersInGroupV1Request)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1