use of com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory in project cloudbreak by hortonworks.
the class DistroXRepairTests method testEphemeralDistroXMasterRepairWithTerminatedInstances.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running environment with FreeIPA and SDX in available state", when = "a new DistroX should be created", and = "MASTER host group should be recovered, where the instance had been terminated", then = "DistroX recovery should be successful, the cluster should be up and running with same volumes")
public void testEphemeralDistroXMasterRepairWithTerminatedInstances(TestContext testContext) {
String distrox = resourcePropertyProvider().getName();
List<String> actualVolumeIds = new ArrayList<>();
List<String> expectedVolumeIds = new ArrayList<>();
String userCrn = testContext.getActingUserCrn().toString();
String workloadUsername = testContext.given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).when(umsTestClient.getUserDetails(userCrn, regionAwareInternalCrnGeneratorFactory)).getResponse().getWorkloadUsername();
testContext.given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).given(FreeIpaUserSyncTestDto.class).when(freeIpaTestClient.getLastSyncOperationStatus()).await(OperationState.COMPLETED).given(UmsTestDto.class).assignTarget(EnvironmentTestDto.class.getSimpleName()).when(umsTestClient.setWorkloadPassword(workloadPassword, regionAwareInternalCrnGeneratorFactory)).given(FreeIpaUserSyncTestDto.class).when(freeIpaTestClient.syncAll()).await(OperationState.COMPLETED).given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).validate();
testContext.given(DistroXTestDto.class).when(distroXTestClient.get()).then(this::verifyMountedDisks).then((tc, testDto, client) -> {
List<InstanceGroupV4Response> instanceGroups = testDto.getResponse().getInstanceGroups();
return sshJUtil.checkMeteringStatus(testDto, instanceGroups, List.of(MASTER.getName()));
}).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instancesToDelete = distroxUtil.getInstanceIds(testDto, client, MASTER.getName());
expectedVolumeIds.addAll(cloudFunctionality.listInstanceVolumeIds(testDto.getName(), instancesToDelete));
cloudFunctionality.deleteInstances(testDto.getName(), instancesToDelete);
return testDto;
}).awaitForHostGroup(MASTER.getName(), InstanceStatus.DELETED_ON_PROVIDER_SIDE).when(distroXTestClient.repair(MASTER), key(distrox)).await(STACK_AVAILABLE, key(distrox)).awaitForHealthyInstances().then(this::verifyMountedDisks).then((tc, testDto, client) -> clouderaManagerUtil.checkClouderaManagerYarnNodemanagerRoleConfigGroups(testDto, workloadUsername, workloadPassword)).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instanceIds = distroxUtil.getInstanceIds(testDto, client, MASTER.getName());
actualVolumeIds.addAll(cloudFunctionality.listInstanceVolumeIds(testDto.getName(), instanceIds));
return testDto;
}).then((tc, testDto, client) -> VolumeUtils.compareVolumeIdsAfterRepair(testDto, actualVolumeIds, expectedVolumeIds)).validate();
}
use of com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory in project cloudbreak by hortonworks.
the class DefaultUmsUsersStateProviderTest method setupMocks.
private void setupMocks() {
doAnswer(invocation -> {
String environmentCrn = invocation.getArgument(0, String.class);
return new EnvironmentAccessChecker(grpcUmsClient, environmentCrn, authorizationRightChecksFactory.create(environmentCrn), regionAwareInternalCrnGeneratorFactory);
}).when(environmentAccessCheckerFactory).create(anyString());
when(grpcUmsClient.listAllGroups(eq(ACCOUNT_ID), any(Optional.class), any())).thenReturn(testData.groups);
when(grpcUmsClient.listWorkloadAdministrationGroups(eq(ACCOUNT_ID), any(Optional.class), any())).thenReturn(testData.allWags);
when(grpcUmsClient.listAllUsers(eq(ACCOUNT_ID), any(Optional.class), any())).thenReturn(testData.users);
when(grpcUmsClient.listAllMachineUsers(eq(ACCOUNT_ID), eq(DefaultUmsUsersStateProvider.DONT_INCLUDE_INTERNAL_MACHINE_USERS), eq(DefaultUmsUsersStateProvider.INCLUDE_WORKLOAD_MACHINE_USERS), any(Optional.class), any())).thenReturn(testData.machineUsers);
doAnswer(invocation -> {
String crn = invocation.getArgument(0, String.class);
Map<String, Boolean> actorRights = testData.memberCrnToActorRights.get(crn);
return UserSyncConstants.RIGHTS.stream().map(right -> actorRights.get(right)).collect(Collectors.toList());
}).when(grpcUmsClient).hasRightsNoCache(anyString(), any(List.class), any(Optional.class), any());
doAnswer(invocation -> {
String memberCrn = invocation.getArgument(1, String.class);
return testData.memberCrnToGroupMembership.get(memberCrn).entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).collect(Collectors.toList());
}).when(grpcUmsClient).listGroupsForMember(eq(ACCOUNT_ID), anyString(), any(Optional.class), any());
doAnswer(invocation -> {
String memberCrn = invocation.getArgument(0, String.class);
return testData.memberCrnToWagMembership.get(memberCrn).entrySet().stream().filter(Map.Entry::getValue).map(Map.Entry::getKey).collect(Collectors.toList());
}).when(grpcUmsClient).listWorkloadAdministrationGroupsForMember(anyString(), any(Optional.class), any());
doAnswer(invocation -> workloadCredentialConverter.toWorkloadCredential(testData.memberCrnToWorkloadCredentials.get(invocation.getArgument(0, String.class)))).when(umsCredentialProvider).getCredentials(anyString(), any(Optional.class));
setupServicePrincipals();
}
use of com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory in project cloudbreak by hortonworks.
the class UtilAuthorizationService method checkRights.
public CheckRightV4Response checkRights(CheckRightV4Request rightReq) {
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
List<AuthorizationProto.RightCheck> rightChecks = rightReq.getRights().stream().map(rightV4 -> createRightCheckObject(umsRightProvider.getRight(rightV4.getAction()), null)).collect(Collectors.toList());
List<Boolean> results = grpcUmsClient.hasRights(userCrn, rightChecks, MDCUtils.getRequestId(), regionAwareInternalCrnGeneratorFactory);
return new CheckRightV4Response(rightReq.getRights().stream().map(rightV4 -> new CheckRightV4SingleResponse(rightV4, results.get(rightReq.getRights().indexOf(rightV4)))).collect(Collectors.toList()));
}
Aggregations