use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class SubnetSelectorTest method testChooseSubnetPreferPublic.
@Test
public void testChooseSubnetPreferPublic() {
EnvironmentNetworkResponse source = new EnvironmentNetworkResponse();
source.setSubnetMetas(Map.of("key1", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1), "key2", getPublicCloudSubnet(PUBLIC_ID_1, AZ_1)));
// Loop to ensure we select the public subnet every time
for (int i = 0; i < 10; i++) {
Optional<CloudSubnet> subnet = underTest.chooseSubnetPreferPublic(null, source.getSubnetMetas(), AZ_1);
assert subnet.isPresent();
assertEquals(PUBLIC_ID_1, subnet.get().getId());
}
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class SubnetSelectorTest method testChooseEndpointGatewaySubnetNoPublicEndpointSubnetsEndpointGatewayValidationEnabled.
@Test
public void testChooseEndpointGatewaySubnetNoPublicEndpointSubnetsEndpointGatewayValidationEnabled() {
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(Map.of("key", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
source.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
source.setGatewayEndpointSubnetMetas(Map.of("private-key", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
when(entitlementService.endpointGatewaySkipValidation(any())).thenReturn(false);
Optional<CloudSubnet> subnet = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.chooseSubnetForEndpointGateway(source, PRIVATE_ID_1));
assert subnet.isEmpty();
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class SubnetSelectorTest method testChooseEndpointGatewaySubnetNoPublicEndpointSubnetsEndpointGatewayValidationDisabled.
@Test
public void testChooseEndpointGatewaySubnetNoPublicEndpointSubnetsEndpointGatewayValidationDisabled() {
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(Map.of("key", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
source.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
source.setGatewayEndpointSubnetMetas(Map.of("private-key", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
when(entitlementService.endpointGatewaySkipValidation(any())).thenReturn(true);
Optional<CloudSubnet> subnet = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.chooseSubnetForEndpointGateway(source, PRIVATE_ID_1));
assert subnet.isPresent();
assertEquals(PRIVATE_ID_1, subnet.get().getId());
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class NetworkV1ToNetworkV4ConverterTest method testConvertToStackRequestWhenAzurePresentedWithSubnet.
@Test
public void testConvertToStackRequestWhenAzurePresentedWithSubnet() {
NetworkV1Request networkV1Request = azureNetworkV1Request();
DetailedEnvironmentResponse environmentNetworkResponse = azureEnvironmentNetwork();
NetworkV4Request networkV4Request = underTest.convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse));
assertEquals(networkV4Request.createAzure().getNetworkId(), VPC_ID);
assertEquals(networkV4Request.createAzure().getResourceGroupName(), GROUP_NAME);
assertEquals(networkV4Request.createAzure().getSubnetId(), SUBNET_ID);
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class NetworkV1ToNetworkV4ConverterTest method testConvertToStackRequestWhenAwsPresentedWithSubnet.
@Test
public void testConvertToStackRequestWhenAwsPresentedWithSubnet() {
NetworkV1Request networkV1Request = awsNetworkV1Request();
DetailedEnvironmentResponse environmentNetworkResponse = awsEnvironmentNetwork();
NetworkV4Request[] networkV4Request = new NetworkV4Request[1];
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
networkV4Request[0] = underTest.convertToNetworkV4Request(new ImmutablePair<>(networkV1Request, environmentNetworkResponse));
});
assertEquals(networkV4Request[0].createAws().getVpcId(), VPC_ID);
assertEquals(networkV4Request[0].createAws().getSubnetId(), SUBNET_ID);
}
Aggregations