use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class GcpEnvironmentNetworkConverterTest method getSharedProjectIdAttributeForLegacyNetwork.
@Test
void getSharedProjectIdAttributeForLegacyNetwork() {
EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
EnvironmentNetworkGcpParams environmentNetworkGcpParams = mock(EnvironmentNetworkGcpParams.class);
when(environmentNetworkResponse.getGcp()).thenReturn(environmentNetworkGcpParams);
when(environmentNetworkGcpParams.getSharedProjectId()).thenReturn(GCP_SHARED_PROJECT_ID);
Map<String, Object> result = converter.getAttributesForLegacyNetwork(environmentNetworkResponse);
assertEquals(GCP_SHARED_PROJECT_ID, result.get("sharedProjectId"));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class GcpEnvironmentNetworkConverterTest method testAllNullAttributesForLegacyNetwork.
@Test
void testAllNullAttributesForLegacyNetwork() {
EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
EnvironmentNetworkGcpParams environmentNetworkGcpParams = mock(EnvironmentNetworkGcpParams.class);
when(environmentNetworkResponse.getGcp()).thenReturn(environmentNetworkGcpParams);
when(environmentNetworkGcpParams.getNetworkId()).thenReturn(null);
when(environmentNetworkGcpParams.getNoFirewallRules()).thenReturn(null);
when(environmentNetworkGcpParams.getNoPublicIp()).thenReturn(null);
when(environmentNetworkGcpParams.getSharedProjectId()).thenReturn(null);
Map<String, Object> result = converter.getAttributesForLegacyNetwork(environmentNetworkResponse);
assertFalse(result.containsKey("networkId"));
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class SubnetSelectorTest method testChooseEndpointGatewaySubnetNoPublicEnvironmentSubnetsEndpointGatewayValidationDisabled.
@Test
public void testChooseEndpointGatewaySubnetNoPublicEnvironmentSubnetsEndpointGatewayValidationDisabled() {
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(Map.of("key", getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
source.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
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 SubnetSelectorTest method setupResponse.
private EnvironmentNetworkResponse setupResponse() {
EnvironmentNetworkResponse source = new EnvironmentNetworkResponse();
source.setNetworkCidrs(NETWORK_CIDRS);
source.setOutboundInternetTraffic(OutboundInternetTraffic.DISABLED);
return source;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.
the class SubnetSelectorTest method testSubnetFoundInAvailabilityZone.
@Test
public void testSubnetFoundInAvailabilityZone() {
EnvironmentNetworkResponse source = setupResponse();
source.setSubnetMetas(Map.of("key", getCloudSubnet(AZ_1)));
Optional<CloudSubnet> subnet = underTest.chooseSubnet(source.getPreferedSubnetId(), source.getSubnetMetas(), AZ_1, SelectionFallbackStrategy.ALLOW_FALLBACK);
assert subnet.isPresent();
assertEquals(PRIVATE_ID_1, subnet.get().getId());
}
Aggregations