Search in sources :

Example 6 with EnvironmentNetworkResponse

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"));
}
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 7 with EnvironmentNetworkResponse

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());
}
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 8 with EnvironmentNetworkResponse

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();
}
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 9 with EnvironmentNetworkResponse

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();
}
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 10 with EnvironmentNetworkResponse

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());
}
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