@Test public void collectAccessConfigsWhenWeGetBackInfoThenItShouldReturnListWithElements() { ListInstanceProfilesResult listInstanceProfilesResult = new ListInstanceProfilesResult(); Set<InstanceProfile> instanceProfileSet = new HashSet<>(); instanceProfileSet.add(instanceProfile(1)); instanceProfileSet.add(instanceProfile(2)); instanceProfileSet.add(instanceProfile(3)); instanceProfileSet.add(instanceProfile(4)); listInstanceProfilesResult.setInstanceProfiles(instanceProfileSet); listInstanceProfilesResult.setIsTruncated(false); when(awsClient.createAmazonIdentityManagement(any(AwsCredentialView.class))).thenReturn(amazonCFClient); when(amazonCFClient.listInstanceProfiles(any(ListInstanceProfilesRequest.class))).thenReturn(listInstanceProfilesResult); CloudAccessConfigs cloudAccessConfigs = underTest.accessConfigs(new CloudCredential("crn", "aws-credential"), region(REGION_NAME), Collections.emptyMap()); Assert.assertEquals(4L, cloudAccessConfigs.getCloudAccessConfigs().size()); }
@Override public CloudAccessConfigs accessConfigs(CloudCredential cloudCredential, Region region, Map<String, String> filters) { CloudAccessConfigs cloudAccessConfigs = new CloudAccessConfigs(new HashSet<>()); AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential); AmazonIdentityManagement client = awsClient.createAmazonIdentityManagement(awsCredentialView); String accessConfigType = filters.get(ACCESS_CONFIG_TYPE); Set<CloudAccessConfig> cloudAccessConfigSet; if (AwsAccessConfigType.ROLE.name().equals(accessConfigType)) { cloudAccessConfigSet = getAccessConfigByRole(client); } else { cloudAccessConfigSet = getAccessConfigByInstanceProfile(client); } cloudAccessConfigs.getCloudAccessConfigs().addAll(cloudAccessConfigSet); return cloudAccessConfigs; }
AwsPlatformResources implements PlatformResources { @Override public CloudAccessConfigs accessConfigs(CloudCredential cloudCredential, Region region, Map<String, String> filters) { CloudAccessConfigs cloudAccessConfigs = new CloudAccessConfigs(new HashSet<>()); AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential); AmazonIdentityManagement client = awsClient.createAmazonIdentityManagement(awsCredentialView); String accessConfigType = filters.get(ACCESS_CONFIG_TYPE); Set<CloudAccessConfig> cloudAccessConfigSet; if (AwsAccessConfigType.ROLE.name().equals(accessConfigType)) { cloudAccessConfigSet = getAccessConfigByRole(client); } else { cloudAccessConfigSet = getAccessConfigByInstanceProfile(client); } cloudAccessConfigs.getCloudAccessConfigs().addAll(cloudAccessConfigSet); return cloudAccessConfigs; } }
AwsPlatformResources implements PlatformResources { @Override public CloudAccessConfigs accessConfigs(CloudCredential cloudCredential, Region region, Map<String, String> filters) { CloudAccessConfigs cloudAccessConfigs = new CloudAccessConfigs(new HashSet<>()); AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential); AmazonIdentityManagement client = awsClient.createAmazonIdentityManagement(awsCredentialView); String accessConfigType = filters.get(ACCESS_CONFIG_TYPE); Set<CloudAccessConfig> cloudAccessConfigSet; if (AwsAccessConfigType.ROLE.name().equals(accessConfigType)) { cloudAccessConfigSet = getAccessConfigByRole(client); } else { cloudAccessConfigSet = getAccessConfigByInstanceProfile(client); } cloudAccessConfigs.getCloudAccessConfigs().addAll(cloudAccessConfigSet); return cloudAccessConfigs; }  }
AwsPlatformResources implements PlatformResources { @Override public CloudAccessConfigs accessConfigs(CloudCredential cloudCredential, Region region, Map<String, String> filters) { CloudAccessConfigs cloudAccessConfigs = new CloudAccessConfigs(new HashSet<>()); AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential); AmazonIdentityManagement client = awsClient.createAmazonIdentityManagement(awsCredentialView); String accessConfigType = filters.get(ACCESS_CONFIG_TYPE); Set<CloudAccessConfig> cloudAccessConfigSet; if (AwsAccessConfigType.ROLE.name().equals(accessConfigType)) { cloudAccessConfigSet = getAccessConfigByRole(client); } else { cloudAccessConfigSet = getAccessConfigByInstanceProfile(client); } cloudAccessConfigs.getCloudAccessConfigs().addAll(cloudAccessConfigSet); return cloudAccessConfigs; }  @PostConstruct void init(); String resourceDefinition(String resource); @Override CloudNetworks networks(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudSshKeys sshKeys(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudSecurityGroups securityGroups(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override @Cacheable(cacheNames = "cloudResourceRegionCache", key = "{ #cloudCredential?.id, #availabilityZonesNeeded }") CloudRegions regions(CloudCredential cloudCredential, Region region, Map<String, String> filters, boolean availabilityZonesNeeded); void addDisplayName(Map<Region, String> displayNames, com.amazonaws.services.ec2.model.Region awsRegion); void addCoordinate(Map<Region, Coordinate> coordinates, com.amazonaws.services.ec2.model.Region awsRegion); @Override @Cacheable(cacheNames = "cloudResourceVmTypeCache", key = "#cloudCredential?.id + #region.getRegionName()") CloudVmTypes virtualMachines(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override @Cacheable(cacheNames = "cloudResourceVmTypeCache", key = "#cloudCredential?.id + #region.getRegionName() + 'distrox'") CloudVmTypes virtualMachinesForDistroX(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudGateWays gateways(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudIpPools publicIpPool(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudAccessConfigs accessConfigs(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudEncryptionKeys encryptionKeys(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudNoSqlTables noSqlTables(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudResourceGroups resourceGroups(CloudCredential cloudCredential, Region region, Map<String, String> filters); }
AwsPlatformResources implements PlatformResources { @Override public CloudAccessConfigs accessConfigs(CloudCredential cloudCredential, Region region, Map<String, String> filters) { CloudAccessConfigs cloudAccessConfigs = new CloudAccessConfigs(new HashSet<>()); AwsCredentialView awsCredentialView = new AwsCredentialView(cloudCredential); AmazonIdentityManagement client = awsClient.createAmazonIdentityManagement(awsCredentialView); String accessConfigType = filters.get(ACCESS_CONFIG_TYPE); Set<CloudAccessConfig> cloudAccessConfigSet; if (AwsAccessConfigType.ROLE.name().equals(accessConfigType)) { cloudAccessConfigSet = getAccessConfigByRole(client); } else { cloudAccessConfigSet = getAccessConfigByInstanceProfile(client); } cloudAccessConfigs.getCloudAccessConfigs().addAll(cloudAccessConfigSet); return cloudAccessConfigs; }  @PostConstruct void init(); String resourceDefinition(String resource); @Override CloudNetworks networks(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudSshKeys sshKeys(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudSecurityGroups securityGroups(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override @Cacheable(cacheNames = "cloudResourceRegionCache", key = "{ #cloudCredential?.id, #availabilityZonesNeeded }") CloudRegions regions(CloudCredential cloudCredential, Region region, Map<String, String> filters, boolean availabilityZonesNeeded); void addDisplayName(Map<Region, String> displayNames, com.amazonaws.services.ec2.model.Region awsRegion); void addCoordinate(Map<Region, Coordinate> coordinates, com.amazonaws.services.ec2.model.Region awsRegion); @Override @Cacheable(cacheNames = "cloudResourceVmTypeCache", key = "#cloudCredential?.id + #region.getRegionName()") CloudVmTypes virtualMachines(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override @Cacheable(cacheNames = "cloudResourceVmTypeCache", key = "#cloudCredential?.id + #region.getRegionName() + 'distrox'") CloudVmTypes virtualMachinesForDistroX(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudGateWays gateways(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudIpPools publicIpPool(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudAccessConfigs accessConfigs(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudEncryptionKeys encryptionKeys(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudNoSqlTables noSqlTables(CloudCredential cloudCredential, Region region, Map<String, String> filters); @Override CloudResourceGroups resourceGroups(CloudCredential cloudCredential, Region region, Map<String, String> filters);  }