use of com.sequenceiq.cloudbreak.dto.LdapView in project cloudbreak by hortonworks.
the class ClouderaManagerLdapServiceTest method testSetupLdapWithoutGroupMapping.
@Test
public void testSetupLdapWithoutGroupMapping() throws ApiException, ClouderaManagerClientInitException {
// GIVEN
LdapView ldapConfig = getLdapConfig();
when(authRolesResourceApi.readAuthRolesMetadata(null)).thenReturn(new ApiAuthRoleMetadataList());
// WHEN
underTest.setupLdap(stack, cluster, httpClientConfig, ldapConfig, null);
// THEN
verify(externalUserMappingsResourceApi, never()).createExternalUserMappings(any(ApiExternalUserMappingList.class));
}
use of com.sequenceiq.cloudbreak.dto.LdapView in project cloudbreak by hortonworks.
the class ClouderaManagerLdapServiceTest method testSetupLdapWithNoRoleAdmin.
@Test
public void testSetupLdapWithNoRoleAdmin() throws ApiException, ClouderaManagerClientInitException {
// GIVEN
ReflectionTestUtils.setField(underTest, "adminRole", "ROLE_CONFIGURATOR");
ReflectionTestUtils.setField(underTest, "limitedAdminRole", "ROLE_CONFIGURATOR_2");
ReflectionTestUtils.setField(underTest, "userRole", "ROLE_USER");
ReflectionTestUtils.setField(underTest, "dashboardUserRole", "ROLE_DASHBOARD_USER");
LdapView ldapConfig = getLdapConfig();
when(authRolesResourceApi.readAuthRolesMetadata(null)).thenReturn(new ApiAuthRoleMetadataList().addItemsItem(new ApiAuthRoleMetadata().displayName("role").uuid("uuid").role("NO_ROLE_ADMIN")));
// WHEN
underTest.setupLdap(stack, cluster, httpClientConfig, ldapConfig, null);
// THEN
verify(externalUserMappingsResourceApi, never()).createExternalUserMappings(any(ApiExternalUserMappingList.class));
}
use of com.sequenceiq.cloudbreak.dto.LdapView in project cloudbreak by hortonworks.
the class RangerVirtualGroupServiceTest method getRangerVirtualGroupTestSuccess.
@Test
public void getRangerVirtualGroupTestSuccess() {
Mockito.when(virtualGroupService.createOrGetVirtualGroup(any(), any())).thenReturn("_c_environments_adminranger");
LdapView ldapView = LdapView.LdapViewBuilder.aLdapView().withProtocol("").withAdminGroup("admin<>").build();
when(ldapConfigService.get(anyString(), anyString())).thenReturn(Optional.of(ldapView));
when(environmentConfigProvider.getParentEnvironmentCrn(anyString())).thenReturn(TestConstants.CRN);
Stack stack = new Stack();
stack.setEnvironmentCrn(TestConstants.CRN);
stack.setName("datalake-stack");
Assert.assertEquals("_c_environments_adminranger", underTest.getRangerVirtualGroup(stack));
}
use of com.sequenceiq.cloudbreak.dto.LdapView in project cloudbreak by hortonworks.
the class StackToTemplatePreparationObjectConverter method convert.
public TemplatePreparationObject convert(Stack source) {
try {
Map<String, Collection<ClusterExposedServiceView>> views = serviceEndpointCollector.prepareClusterExposedServicesViews(source.getCluster(), stackUtil.extractClusterManagerAddress(source));
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
Credential credential = credentialConverter.convert(environment.getCredential());
Cluster cluster = clusterService.getById(source.getCluster().getId());
FileSystem fileSystem = cluster.getFileSystem();
Optional<LdapView> ldapView = ldapConfigService.get(source.getEnvironmentCrn(), source.getName());
ClouderaManagerRepo cm = clusterComponentConfigProvider.getClouderaManagerRepoDetails(cluster.getId());
List<ClouderaManagerProduct> products = clusterComponentConfigProvider.getClouderaManagerProductDetails(cluster.getId());
BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(credential, source, fileSystem);
updateFileSystemViewWithBackupLocation(environment, fileSystemConfigurationView);
StackInputs stackInputs = getStackInputs(source);
Map<String, Object> fixInputs = stackInputs.getFixInputs() == null ? new HashMap<>() : stackInputs.getFixInputs();
fixInputs.putAll(stackInputs.getDatalakeInputs() == null ? new HashMap<>() : stackInputs.getDatalakeInputs());
Gateway gateway = cluster.getGateway();
String gatewaySignKey = null;
if (gateway != null) {
gatewaySignKey = gateway.getSignKey();
}
IdBroker idbroker = idBrokerService.getByCluster(cluster);
if (idbroker == null) {
idbroker = idBrokerConverterUtil.generateIdBrokerSignKeys(cluster);
idBrokerService.save(idbroker);
}
String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapView.map(LdapView::getAdminGroup).orElse(""));
String accountId = Crn.safeFromString(source.getResourceCrn()).getAccountId();
List<UserManagementProto.ServicePrincipalCloudIdentities> servicePrincipalCloudIdentities = grpcUmsClient.listServicePrincipalCloudIdentities(accountId, source.getEnvironmentCrn(), MDCUtils.getRequestId());
BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(cluster.getBlueprint());
Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
Builder builder = Builder.builder().withCloudPlatform(CloudPlatform.valueOf(source.getCloudPlatform())).withRdsConfigs(postgresConfigService.createRdsConfigIfNeeded(source, cluster)).withRdsSslCertificateFilePath(dbCertificateProvider.getSslCertsFilePath()).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withIdBroker(idbroker).withCustomConfigurationsView(getCustomConfigurationsView(source, cluster)).withCustomInputs(stackInputs.getCustomInputs() == null ? new HashMap<>() : stackInputs.getCustomInputs()).withFixInputs(fixInputs).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(calculateGeneralClusterConfigs(source, cluster)).withLdapConfig(ldapView.orElse(null)).withKerberosConfig(kerberosConfigService.get(source.getEnvironmentCrn(), source.getName()).orElse(null)).withProductDetails(cm, products).withExposedServices(views).withDefaultTags(getStackTags(source)).withSharedServiceConfigs(datalakeService.createSharedServiceConfigsView(source)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
transactionService.required(() -> {
builder.withHostgroups(hostGroupService.getByCluster(cluster.getId()));
});
decorateBuilderWithPlacement(source, builder);
decorateBuilderWithAccountMapping(source, environment, credential, builder, virtualGroupRequest);
decorateBuilderWithServicePrincipals(source, builder, servicePrincipalCloudIdentities);
decorateDatalakeView(source, builder);
return builder.build();
} catch (AccountTagValidationFailed aTVF) {
throw new CloudbreakServiceException(aTVF);
} catch (BlueprintProcessingException | IOException | TransactionService.TransactionExecutionException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.dto.LdapView in project cloudbreak by hortonworks.
the class RangerVirtualGroupService method getRangerVirtualGroup.
public String getRangerVirtualGroup(Stack stack) {
if (CloudPlatform.MOCK.equalsIgnoreCase(stack.getCloudPlatform())) {
return "mockGroup";
}
Optional<LdapView> ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName());
String virtualGroupsEnvironmentCrn = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn());
String adminGroup = ldapView.orElseThrow(() -> new CloudbreakServiceException("Ranger admin group not found.")).getAdminGroup();
LOGGER.debug("Admin Group:", adminGroup);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(virtualGroupsEnvironmentCrn, adminGroup);
return virtualGroupService.createOrGetVirtualGroup(virtualGroupRequest, UmsVirtualGroupRight.RANGER_ADMIN);
}
Aggregations