Search in sources :

Example 1 with UmsRight

use of com.sequenceiq.cloudbreak.auth.altus.UmsRight in project cloudbreak by hortonworks.

the class BasicEnvironmentVirtualGroupTest method getEnvironmentVirtualGroups.

private Map<UmsRight, String> getEnvironmentVirtualGroups(TestContext testContext, UmsClient client) {
    String accountId = testContext.getActingUserCrn().getAccountId();
    String environmentCrn = testContext.given(EnvironmentTestDto.class).getCrn();
    Map<UmsRight, String> virtualGroups = new HashMap<>();
    String virtualGroup = null;
    for (UmsRight right : UmsRight.values()) {
        try {
            virtualGroup = client.getDefaultClient().getWorkloadAdministrationGroupName(accountId, MDCUtils.getRequestId(), right.getRight(), environmentCrn);
        } catch (StatusRuntimeException ex) {
            if (Status.Code.NOT_FOUND != ex.getStatus().getCode()) {
                LOGGER.info(String.format(" Virtual groups is missing for right: '%s' ", right.getRight()));
            }
        }
        if (StringUtils.hasText(virtualGroup)) {
            virtualGroups.put(right, virtualGroup);
        }
    }
    if (MapUtils.isNotEmpty(virtualGroups)) {
        Log.then(LOGGER, format(" Virtual groups are present [%s] for environment '%s' ", virtualGroups, environmentCrn));
        LOGGER.info(String.format(" Virtual groups are present [%s] for environment '%s' ", virtualGroups, environmentCrn));
    } else {
        throw new TestFailException(String.format(" Cannot find virtual groups for environment '%s' ", environmentCrn));
    }
    return virtualGroups;
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) HashMap(java.util.HashMap) StatusRuntimeException(io.grpc.StatusRuntimeException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) UmsRight(com.sequenceiq.cloudbreak.auth.altus.UmsRight)

Aggregations

UmsRight (com.sequenceiq.cloudbreak.auth.altus.UmsRight)1 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 HashMap (java.util.HashMap)1