Search in sources :

Example 6 with AccountMappingView

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();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.Test)

Example 7 with AccountMappingView

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();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) Builder(com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder) WasbFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.wasb.WasbFileSystemConfigurationsView) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.Test)

Example 8 with AccountMappingView

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());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) AccountMappingBase(com.sequenceiq.common.api.cloudstorage.AccountMappingBase) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.Test)

Example 9 with AccountMappingView

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());
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.Test)

Example 10 with AccountMappingView

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();
    }
}
Also used : ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ApiClusterTemplateConfig(com.cloudera.api.swagger.model.ApiClusterTemplateConfig) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView)

Aggregations

AccountMappingView (com.sequenceiq.cloudbreak.template.views.AccountMappingView)18 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)17 Test (org.junit.Test)14 ApiClusterTemplateConfig (com.cloudera.api.swagger.model.ApiClusterTemplateConfig)13 Builder (com.sequenceiq.cloudbreak.template.TemplatePreparationObject.Builder)12 BaseFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView)7 Test (org.junit.jupiter.api.Test)3 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)2 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)2 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)1 AccountMapping (com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping)1 CloudStorage (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage)1 WasbFileSystemConfigurationsView (com.sequenceiq.cloudbreak.template.filesystem.wasb.WasbFileSystemConfigurationsView)1 AccountMappingBase (com.sequenceiq.common.api.cloudstorage.AccountMappingBase)1 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)1