@Test public void testSetupCloudStorageAccountMappingWhenNoCloudStorage() { when(stackV4Request.getCluster()).thenReturn(clusterV4Request); when(stackV4Request.getName()).thenReturn(STACK_NAME); underTest.setupCloudStorageAccountMapping(stackV4Request, ENVIRONMENT_CRN, IdBrokerMappingSource.IDBMMS, CLOUD_PLATFORM_AWS); assertThat(clusterV4Request.getCloudStorage()).isNull(); }
@VisibleForTesting void setupCloudStorageAccountMapping(StackV4Request stackRequest, String environmentCrn, IdBrokerMappingSource mappingSource, String cloudPlatform) { String stackName = stackRequest.getName(); CloudStorageRequest cloudStorage = stackRequest.getCluster().getCloudStorage(); if (cloudStorage != null && cloudStorage.getAccountMapping() == null) { if (mappingSource == IdBrokerMappingSource.IDBMMS) { LOGGER.info("Fetching account mappings from IDBMMS associated with environment {} for stack {}.", environmentCrn, stackName); MappingsConfig mappingsConfig; try { mappingsConfig = idbmmsClient.getMappingsConfig(INTERNAL_ACTOR_CRN, environmentCrn, Optional.empty()); } catch (IdbmmsOperationException e) { throw new BadRequestException(String.format("Unable to get mappings: %s", e.getMessage()), e); } AccountMappingBase accountMapping = new AccountMappingBase(); accountMapping.setGroupMappings(mappingsConfig.getGroupMappings()); accountMapping.setUserMappings(mappingsConfig.getActorMappings()); cloudStorage.setAccountMapping(accountMapping); LOGGER.info("Initial account mappings fetched from IDBMMS: {}", JsonUtil.writeValueAsStringSilent(accountMapping)); } else { LOGGER.info("IDBMMS usage is disabled for environment {}. Proceeding with {} mappings for stack {}.", environmentCrn, mappingSource == IdBrokerMappingSource.MOCK && (CloudPlatform.AWS.name().equals(cloudPlatform) || CloudPlatform.AZURE.name().equals(cloudPlatform) || CloudPlatform.GCP.name().equals(cloudPlatform)) ? "mock" : "missing", stackName); } } else { LOGGER.info("{} for stack {} in environment {}.", cloudStorage == null ? "Cloud storage is disabled" : "Applying user-provided mappings", stackName, environmentCrn); } }
StackRequestManifester { @VisibleForTesting void setupCloudStorageAccountMapping(StackV4Request stackRequest, String environmentCrn, IdBrokerMappingSource mappingSource, String cloudPlatform) { String stackName = stackRequest.getName(); CloudStorageRequest cloudStorage = stackRequest.getCluster().getCloudStorage(); if (cloudStorage != null && cloudStorage.getAccountMapping() == null) { if (mappingSource == IdBrokerMappingSource.IDBMMS) { LOGGER.info("Fetching account mappings from IDBMMS associated with environment {} for stack {}.", environmentCrn, stackName); MappingsConfig mappingsConfig; try { mappingsConfig = idbmmsClient.getMappingsConfig(INTERNAL_ACTOR_CRN, environmentCrn, Optional.empty()); } catch (IdbmmsOperationException e) { throw new BadRequestException(String.format("Unable to get mappings: %s", e.getMessage()), e); } AccountMappingBase accountMapping = new AccountMappingBase(); accountMapping.setGroupMappings(mappingsConfig.getGroupMappings()); accountMapping.setUserMappings(mappingsConfig.getActorMappings()); cloudStorage.setAccountMapping(accountMapping); LOGGER.info("Initial account mappings fetched from IDBMMS: {}", JsonUtil.writeValueAsStringSilent(accountMapping)); } else { LOGGER.info("IDBMMS usage is disabled for environment {}. Proceeding with {} mappings for stack {}.", environmentCrn, mappingSource == IdBrokerMappingSource.MOCK && (CloudPlatform.AWS.name().equals(cloudPlatform) || CloudPlatform.AZURE.name().equals(cloudPlatform) || CloudPlatform.GCP.name().equals(cloudPlatform)) ? "mock" : "missing", stackName); } } else { LOGGER.info("{} for stack {} in environment {}.", cloudStorage == null ? "Cloud storage is disabled" : "Applying user-provided mappings", stackName, environmentCrn); } } }
StackRequestManifester { @VisibleForTesting void setupCloudStorageAccountMapping(StackV4Request stackRequest, String environmentCrn, IdBrokerMappingSource mappingSource, String cloudPlatform) { String stackName = stackRequest.getName(); CloudStorageRequest cloudStorage = stackRequest.getCluster().getCloudStorage(); if (cloudStorage != null && cloudStorage.getAccountMapping() == null) { if (mappingSource == IdBrokerMappingSource.IDBMMS) { LOGGER.info("Fetching account mappings from IDBMMS associated with environment {} for stack {}.", environmentCrn, stackName); MappingsConfig mappingsConfig; try { mappingsConfig = idbmmsClient.getMappingsConfig(INTERNAL_ACTOR_CRN, environmentCrn, Optional.empty()); } catch (IdbmmsOperationException e) { throw new BadRequestException(String.format("Unable to get mappings: %s", e.getMessage()), e); } AccountMappingBase accountMapping = new AccountMappingBase(); accountMapping.setGroupMappings(mappingsConfig.getGroupMappings()); accountMapping.setUserMappings(mappingsConfig.getActorMappings()); cloudStorage.setAccountMapping(accountMapping); LOGGER.info("Initial account mappings fetched from IDBMMS: {}", JsonUtil.writeValueAsStringSilent(accountMapping)); } else { LOGGER.info("IDBMMS usage is disabled for environment {}. Proceeding with {} mappings for stack {}.", environmentCrn, mappingSource == IdBrokerMappingSource.MOCK && (CloudPlatform.AWS.name().equals(cloudPlatform) || CloudPlatform.AZURE.name().equals(cloudPlatform) || CloudPlatform.GCP.name().equals(cloudPlatform)) ? "mock" : "missing", stackName); } } else { LOGGER.info("{} for stack {} in environment {}.", cloudStorage == null ? "Cloud storage is disabled" : "Applying user-provided mappings", stackName, environmentCrn); } }  }
StackRequestManifester { @VisibleForTesting void setupCloudStorageAccountMapping(StackV4Request stackRequest, String environmentCrn, IdBrokerMappingSource mappingSource, String cloudPlatform) { String stackName = stackRequest.getName(); CloudStorageRequest cloudStorage = stackRequest.getCluster().getCloudStorage(); if (cloudStorage != null && cloudStorage.getAccountMapping() == null) { if (mappingSource == IdBrokerMappingSource.IDBMMS) { LOGGER.info("Fetching account mappings from IDBMMS associated with environment {} for stack {}.", environmentCrn, stackName); MappingsConfig mappingsConfig; try { mappingsConfig = idbmmsClient.getMappingsConfig(INTERNAL_ACTOR_CRN, environmentCrn, Optional.empty()); } catch (IdbmmsOperationException e) { throw new BadRequestException(String.format("Unable to get mappings: %s", e.getMessage()), e); } AccountMappingBase accountMapping = new AccountMappingBase(); accountMapping.setGroupMappings(mappingsConfig.getGroupMappings()); accountMapping.setUserMappings(mappingsConfig.getActorMappings()); cloudStorage.setAccountMapping(accountMapping); LOGGER.info("Initial account mappings fetched from IDBMMS: {}", JsonUtil.writeValueAsStringSilent(accountMapping)); } else { LOGGER.info("IDBMMS usage is disabled for environment {}. Proceeding with {} mappings for stack {}.", environmentCrn, mappingSource == IdBrokerMappingSource.MOCK && (CloudPlatform.AWS.name().equals(cloudPlatform) || CloudPlatform.AZURE.name().equals(cloudPlatform) || CloudPlatform.GCP.name().equals(cloudPlatform)) ? "mock" : "missing", stackName); } } else { LOGGER.info("{} for stack {} in environment {}.", cloudStorage == null ? "Cloud storage is disabled" : "Applying user-provided mappings", stackName, environmentCrn); } }  void configureStackForSdxCluster(SdxCluster sdxCluster, DetailedEnvironmentResponse environment); }
StackRequestManifester { @VisibleForTesting void setupCloudStorageAccountMapping(StackV4Request stackRequest, String environmentCrn, IdBrokerMappingSource mappingSource, String cloudPlatform) { String stackName = stackRequest.getName(); CloudStorageRequest cloudStorage = stackRequest.getCluster().getCloudStorage(); if (cloudStorage != null && cloudStorage.getAccountMapping() == null) { if (mappingSource == IdBrokerMappingSource.IDBMMS) { LOGGER.info("Fetching account mappings from IDBMMS associated with environment {} for stack {}.", environmentCrn, stackName); MappingsConfig mappingsConfig; try { mappingsConfig = idbmmsClient.getMappingsConfig(INTERNAL_ACTOR_CRN, environmentCrn, Optional.empty()); } catch (IdbmmsOperationException e) { throw new BadRequestException(String.format("Unable to get mappings: %s", e.getMessage()), e); } AccountMappingBase accountMapping = new AccountMappingBase(); accountMapping.setGroupMappings(mappingsConfig.getGroupMappings()); accountMapping.setUserMappings(mappingsConfig.getActorMappings()); cloudStorage.setAccountMapping(accountMapping); LOGGER.info("Initial account mappings fetched from IDBMMS: {}", JsonUtil.writeValueAsStringSilent(accountMapping)); } else { LOGGER.info("IDBMMS usage is disabled for environment {}. Proceeding with {} mappings for stack {}.", environmentCrn, mappingSource == IdBrokerMappingSource.MOCK && (CloudPlatform.AWS.name().equals(cloudPlatform) || CloudPlatform.AZURE.name().equals(cloudPlatform) || CloudPlatform.GCP.name().equals(cloudPlatform)) ? "mock" : "missing", stackName); } } else { LOGGER.info("{} for stack {} in environment {}.", cloudStorage == null ? "Cloud storage is disabled" : "Applying user-provided mappings", stackName, environmentCrn); } }  void configureStackForSdxCluster(SdxCluster sdxCluster, DetailedEnvironmentResponse environment);  }