Search in sources :

Example 11 with AccountMappingView

use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.

the class StackToTemplatePreparationObjectConverterTest method testMockAccountMappingsWhenNoFileSystemShouldReturnEmptyList.

@Test
public void testMockAccountMappingsWhenNoFileSystemShouldReturnEmptyList() {
    when(virtualGroupService.createOrGetVirtualGroup(any(VirtualGroupRequest.class), eq(CLOUDER_MANAGER_ADMIN))).thenReturn("mockAdmins");
    when(stackMock.getCluster().getFileSystem()).thenReturn(null);
    when(blueprintViewProvider.getBlueprintView(any())).thenReturn(getBlueprintView());
    TemplatePreparationObject result = underTest.convert(stackMock);
    AccountMappingView accountMappingView = result.getAccountMappingView();
    assertThat(accountMappingView).isNull();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.jupiter.api.Test)

Example 12 with AccountMappingView

use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.

the class StackToTemplatePreparationObjectConverterTest method testStackInputAccountMappings.

@Test
public void testStackInputAccountMappings() {
    FileSystem sourceFileSystem = mock(FileSystem.class);
    CloudStorage sourceCloudStorage = mock(CloudStorage.class);
    when(sourceCluster.getFileSystem()).thenReturn(sourceFileSystem);
    when(sourceFileSystem.getCloudStorage()).thenReturn(sourceCloudStorage);
    AccountMapping accountMapping = new AccountMapping();
    accountMapping.setGroupMappings(GROUP_MAPPINGS);
    accountMapping.setUserMappings(USER_MAPPINGS);
    when(sourceCloudStorage.getAccountMapping()).thenReturn(accountMapping);
    when(blueprintViewProvider.getBlueprintView(any())).thenReturn(getBlueprintView());
    TemplatePreparationObject result = underTest.convert(stackMock);
    AccountMappingView accountMappingView = result.getAccountMappingView();
    assertThat(accountMappingView).isNotNull();
    assertThat(accountMappingView.getGroupMappings()).isEqualTo(GROUP_MAPPINGS);
    assertThat(accountMappingView.getUserMappings()).isEqualTo(USER_MAPPINGS);
}
Also used : CloudStorage(com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage) TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) AccountMapping(com.sequenceiq.cloudbreak.domain.cloudstorage.AccountMapping) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.jupiter.api.Test)

Example 13 with AccountMappingView

use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.

the class StackToTemplatePreparationObjectConverterTest method testMockAccountMappings.

@Test
public void testMockAccountMappings() {
    when(virtualGroupService.createOrGetVirtualGroup(any(VirtualGroupRequest.class), eq(CLOUDER_MANAGER_ADMIN))).thenReturn("mockAdmins");
    when(stackMock.getCluster().getFileSystem()).thenReturn(new FileSystem());
    when(blueprintViewProvider.getBlueprintView(any())).thenReturn(getBlueprintView());
    TemplatePreparationObject result = underTest.convert(stackMock);
    AccountMappingView accountMappingView = result.getAccountMappingView();
    assertThat(accountMappingView).isNotNull();
    assertThat(accountMappingView.getGroupMappings()).isEqualTo(MOCK_GROUP_MAPPINGS);
    assertThat(accountMappingView.getUserMappings()).isEqualTo(MOCK_USER_MAPPINGS);
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) FileSystem(com.sequenceiq.cloudbreak.domain.FileSystem) AccountMappingView(com.sequenceiq.cloudbreak.template.views.AccountMappingView) Test(org.junit.jupiter.api.Test)

Example 14 with AccountMappingView

use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndS3FileSystem.

@Test
public void getRoleConfigWhenIdBrokerAndS3FileSystem() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("S3");
    TemplatePreparationObject tpo = new Builder().withCloudPlatform(CloudPlatform.AWS).withFileSystemConfigurationView(fileSystemConfigurationsView).withAccountMappingView(new AccountMappingView(GROUP_MAPPINGS, USER_MAPPINGS)).build();
    List<ApiClusterTemplateConfig> result = underTest.getRoleConfigs(IDBROKER, tpo);
    Map<String, String> configNameToValueMap = getConfigNameToValueMap(result);
    assertThat(configNameToValueMap).containsOnly(Map.entry(IDBROKER_AWS_USER_MAPPING, USER_MAPPINGS_STR), Map.entry(IDBROKER_AWS_GROUP_MAPPING, GROUP_MAPPINGS_STR));
    Map<String, String> configNameToVariableNameMap = getConfigNameToVariableNameMap(result);
    assertThat(configNameToVariableNameMap).isEmpty();
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) 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 15 with AccountMappingView

use of com.sequenceiq.cloudbreak.template.views.AccountMappingView in project cloudbreak by hortonworks.

the class KnoxIdBrokerConfigProviderTest method getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndValidCMVersionInvalidEntity.

@Test
public void getRoleConfigWhenIdBrokerAndAdlsGen2FileSystemAndValidCMVersionInvalidEntity() {
    BaseFileSystemConfigurationsView fileSystemConfigurationsView = mock(BaseFileSystemConfigurationsView.class);
    when(fileSystemConfigurationsView.getType()).thenReturn("ADLS_GEN_2");
    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) BaseFileSystemConfigurationsView(com.sequenceiq.cloudbreak.template.filesystem.BaseFileSystemConfigurationsView) 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)

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