use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.
the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndNoFileSystemAndAzure.
@Test
public void getRoleConfigWhenIdBrokerAndNoFileSystemAndAzure() {
TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AZURE).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).withProductDetails(generateCMRepo(CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_1_0), null).build();
List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AZURE_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AZURE_GROUP_MAPPING, GROUP_MAPPINGS_STR));
Map<String, String> configNameToVariableNameMap = getConfigNameToVariableNameMap(result);
assertThat(configNameToVariableNameMap).isEmpty();
}
use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.
the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndWasbFileSystem.
@Test
public void getRoleConfigWhenIdBrokerAndWasbFileSystem() {
WasbFileSystemConfigurationsView fileSystemConfigurationsView = mock(WasbFileSystemConfigurationsView.class);
when(fileSystemConfigurationsView.getType()).thenReturn("WASB");
TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AZURE).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).withProductDetails(generateCMRepo(CMRepositoryVersionUtil.CLOUDERAMANAGER_VERSION_7_1_0), null).build();
List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AZURE_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AZURE_GROUP_MAPPING, GROUP_MAPPINGS_STR));
Map<String, String> configNameToVariableNameMap = getConfigNameToVariableNameMap(result);
assertThat(configNameToVariableNameMap).isEmpty();
}
use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverterTest method testStackInputAccountMappings.
@Test
public void testStackInputAccountMappings() {
when(cloudStorageValidationUtil.isCloudStorageConfigured(any(CloudStorageRequest.class))).thenReturn(true);
CloudStorageRequest cloudStorage = mock(CloudStorageRequest.class);
when(cluster.getCloudStorage()).thenReturn(cloudStorage);
AccountMappingBase accountMapping = new AccountMappingBase();
accountMapping.setGroupMappings(GROUP_MAPPINGS);
accountMapping.setUserMappings(USER_MAPPINGS);
when(cloudStorage.getAccountMapping()).thenReturn(accountMapping);
TemplatePreparationObject result = underTest.convert(source);
AccountMappingView accountMappingView = result.getAccountMappingView();
assertNotNull(accountMappingView);
assertEquals(GROUP_MAPPINGS, accountMappingView.getGroupMappings());
assertEquals(USER_MAPPINGS, accountMappingView.getUserMappings());
}
use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverterTest method testMockAccountMappings.
@Test
public void testMockAccountMappings() {
TemplatePreparationObject result = underTest.convert(source);
AccountMappingView accountMappingView = result.getAccountMappingView();
assertNotNull(accountMappingView);
assertEquals(MOCK_GROUP_MAPPINGS, accountMappingView.getGroupMappings());
assertEquals(MOCK_USER_MAPPINGS, accountMappingView.getUserMappings());
}
use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.
the class KnoxIdBrokerConfigProvider method getRoleConfigs.
@Override
protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) {
switch(roleType) {
case IDBROKER:
List<ApiClusterTemplateConfig> config;
AccountMappingView accountMappingView = source.getAccountMappingView() == null ? AccountMappingView.EMPTY_MAPPING : source.getAccountMappingView();
String userMappings = getAccountMappingSetting(accountMappingView.getUserMappings());
String groupMappings = getAccountMappingSetting(accountMappingView.getGroupMappings());
switch(getCloudPlatform(source)) {
case AWS:
config = List.of(config("idbroker_aws_user_mapping", userMappings), config("idbroker_aws_group_mapping", groupMappings));
break;
case AZURE:
config = new ArrayList<>(List.of(config("idbroker_azure_user_mapping", userMappings), config("idbroker_azure_group_mapping", groupMappings)));
ClouderaManagerRepo cmRepo = source.getProductDetailsView().getCm();
if (CMRepositoryVersionUtil.isIdBrokerManagedIdentitySupported(cmRepo)) {
String idBrokerManagedIdentity = getIdBrokerManagedIdentity(source.getFileSystemConfigurationView());
if (Objects.nonNull(idBrokerManagedIdentity)) {
config.add(config("idbroker_azure_vm_assumer_identity", idBrokerManagedIdentity));
}
}
break;
case GCP:
config = List.of(config("idbroker_gcp_user_mapping", userMappings), config("idbroker_gcp_group_mapping", groupMappings));
break;
default:
config = List.of();
break;
}
return config;
default:
return List.of();
}
}
Aggregations