use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class GcpEnvironmentNetworkConverterTest method getNoFirewallRulesAttributeForLegacyNetwork.
@Test
void getNoFirewallRulesAttributeForLegacyNetwork() {
EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
EnvironmentNetworkGcpParams environmentNetworkGcpParams = mock(EnvironmentNetworkGcpParams.class);
when(environmentNetworkResponse.getGcp()).thenReturn(environmentNetworkGcpParams);
when(environmentNetworkGcpParams.getNoFirewallRules()).thenReturn(true);
Map<String, Object> result = converter.getAttributesForLegacyNetwork(environmentNetworkResponse);
assertEquals(true, result.get("noFirewallRules"));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class SubnetSelectorTest method testChooseEndpointGatewaySubnetFromEnvironmentSubnetst.
@Test
public void testChooseEndpointGatewaySubnetFromEnvironmentSubnetst() {
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(Map.of("key1", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1), "key2", getPublicCloudSubnet(PUBLIC_ID_1, AZ_1)));
source.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
when(entitlementService.endpointGatewaySkipValidation(any())).thenReturn(false);
Optional<CloudSubnet> subnet = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.chooseSubnetForEndpointGateway(source, PRIVATE_ID_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 testNoSubnetInAvailabilityZone.
@Test
public void testNoSubnetInAvailabilityZone() {
EnvironmentNetworkResponse source = new EnvironmentNetworkResponse();
source.setSubnetMetas(Map.of("key", getCloudSubnet("any")));
Optional<CloudSubnet> subnet = underTest.chooseSubnet(source.getPreferedSubnetId(), source.getSubnetMetas(), AZ_1, SelectionFallbackStrategy.ALLOW_FALLBACK);
assert subnet.isEmpty();
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class SubnetSelectorTest method testChooseEndpointGatewaySubnetNoPublicEnvironmentSubnetsEndpointGatewayValidationEnabled.
@Test
public void testChooseEndpointGatewaySubnetNoPublicEnvironmentSubnetsEndpointGatewayValidationEnabled() {
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(Map.of("key", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
source.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
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 testChooseSubnetPreferPublicWhenNoPublicSubnet.
@Test
public void testChooseSubnetPreferPublicWhenNoPublicSubnet() {
EnvironmentNetworkResponse source = new EnvironmentNetworkResponse();
source.setSubnetMetas(Map.of("key1", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
Optional<CloudSubnet> subnet = underTest.chooseSubnetPreferPublic(null, source.getSubnetMetas(), AZ_1);
assert subnet.isPresent();
assertEquals(PRIVATE_ID_1, subnet.get().getId());
}
Aggregations