use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProviderTest method testProvideWhenPrivateSubnetsAreDisabledAndInterfaceServicesWithDifferentAzs.
@Test
public void testProvideWhenPrivateSubnetsAreDisabledAndInterfaceServicesWithDifferentAzs() throws IOException, TemplateException {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-publicsubnet-vpcendpoints-differentazs.json"));
when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
AmazonEc2Client ec2Client = mock(AmazonEc2Client.class);
when(awsClient.createEc2Client(any(), anyString())).thenReturn(ec2Client);
when(ec2Client.describeVpcEndpointServices()).thenReturn(createDescribeVpcEndpointServicesResultWithDifferentAzs());
NetworkCreationRequest networkCreationRequest = createNetworkRequest(false, PrivateEndpointType.USE_VPC_ENDPOINT);
List<SubnetRequest> subnetRequestList = createPublicSubnetRequestList();
String actual = underTest.provide(networkCreationRequest, subnetRequestList);
JsonNode json = objectMapper.readTree(actual);
assertEquals(expectedJson, json);
verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProviderTest method createPublicSubnetRequestList.
private static List<SubnetRequest> createPublicSubnetRequestList() {
SubnetRequest subnetRequest1 = new SubnetRequest();
subnetRequest1.setPublicSubnetCidr("2.2.2.2/24");
subnetRequest1.setIndex(0);
subnetRequest1.setSubnetGroup(0);
subnetRequest1.setAvailabilityZone("az1");
SubnetRequest subnetRequest2 = new SubnetRequest();
subnetRequest2.setPublicSubnetCidr("2.2.2.2/24");
subnetRequest2.setIndex(1);
subnetRequest2.setSubnetGroup(1);
subnetRequest2.setAvailabilityZone("az2");
SubnetRequest subnetRequest3 = new SubnetRequest();
subnetRequest3.setPublicSubnetCidr("2.2.2.2/24");
subnetRequest3.setIndex(2);
subnetRequest3.setSubnetGroup(2);
subnetRequest3.setAvailabilityZone("az3");
SubnetRequest subnetRequest4 = new SubnetRequest();
subnetRequest4.setPublicSubnetCidr("2.2.2.2/24");
subnetRequest4.setIndex(3);
subnetRequest4.setSubnetGroup(3);
subnetRequest4.setAvailabilityZone("az4");
return List.of(subnetRequest1, subnetRequest2, subnetRequest3, subnetRequest4);
}
use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProviderTest method testProvideWhenPrivateSubnetsAndInterfaceServicesAreDisabled.
@Test
public void testProvideWhenPrivateSubnetsAndInterfaceServicesAreDisabled() throws IOException, TemplateException {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-privatesubnet-onlygatewayvpcendpoints.json"));
when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
NetworkCreationRequest networkCreationRequest = createNetworkRequest(true, PrivateEndpointType.NONE);
List<SubnetRequest> subnetRequestList = createPrivateAndPublicSubnetRequestList();
String actual = underTest.provide(networkCreationRequest, subnetRequestList);
JsonNode json = objectMapper.readTree(actual);
assertEquals(expectedJson, json);
verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProviderTest method testProvideWhenPublicSubnetsAndInterfaceServicesAreDisabled.
@Test
public void testProvideWhenPublicSubnetsAndInterfaceServicesAreDisabled() throws IOException, TemplateException {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-publicsubnet-onlygatewayvpcendpoints.json"));
when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
NetworkCreationRequest networkCreationRequest = createNetworkRequest(false, PrivateEndpointType.NONE);
List<SubnetRequest> subnetRequestList = createPrivateAndPublicSubnetRequestList();
String actual = underTest.provide(networkCreationRequest, subnetRequestList);
JsonNode json = objectMapper.readTree(actual);
assertEquals(expectedJson, json);
verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
use of com.sequenceiq.cloudbreak.cloud.model.network.SubnetRequest in project cloudbreak by hortonworks.
the class AwsNetworkCfTemplateProviderTest method testProvideWhenOnlyPublicSubnetsAndInterfaceServicesWithDifferentAzs.
@Test
public void testProvideWhenOnlyPublicSubnetsAndInterfaceServicesWithDifferentAzs() throws IOException, TemplateException {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode expectedJson = objectMapper.readTree(new File("src/test/resources/json/aws-cf-network-publicsubnet-vpcendpoints-differentazs.json"));
when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
AmazonEc2Client ec2Client = mock(AmazonEc2Client.class);
when(awsClient.createEc2Client(any(), anyString())).thenReturn(ec2Client);
when(ec2Client.describeVpcEndpointServices()).thenReturn(createDescribeVpcEndpointServicesResultWithDifferentAzs());
NetworkCreationRequest networkCreationRequest = createNetworkRequest(true, PrivateEndpointType.USE_VPC_ENDPOINT);
List<SubnetRequest> subnetRequestList = createPublicSubnetRequestList();
String actual = underTest.provide(networkCreationRequest, subnetRequestList);
JsonNode json = objectMapper.readTree(actual);
assertEquals(expectedJson, json);
verify(freeMarkerTemplateUtils).processTemplateIntoString(any(Template.class), anyMap());
}
Aggregations