Search in sources :

Example 46 with EnvironmentNetworkResponse

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"));
}
Also used : EnvironmentNetworkGcpParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 47 with EnvironmentNetworkResponse

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"));
}
Also used : EnvironmentNetworkGcpParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 48 with EnvironmentNetworkResponse

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());
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.jupiter.api.Test) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest)

Example 49 with EnvironmentNetworkResponse

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;
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)

Example 50 with EnvironmentNetworkResponse

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());
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.jupiter.api.Test) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest)

Aggregations

EnvironmentNetworkResponse (com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse)70 Test (org.junit.jupiter.api.Test)40 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)27 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)24 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)22 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)8 NetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.NetworkV1Request)8 NetworkV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.network.NetworkV4Request)7 Test (org.junit.Test)7 EnvironmentNetworkGcpParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkGcpParams)6 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)5 Network (com.sequenceiq.cloudbreak.domain.Network)5 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)5 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)3 SubnetType (com.sequenceiq.cloudbreak.cloud.model.network.SubnetType)3 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)3 Tunnel (com.sequenceiq.common.api.type.Tunnel)3 EnvironmentNetworkAwsParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkAwsParams)3