Search in sources :

Example 66 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EndpointGatewayNetworkValidatorTest method validateProvidedEndpointGatwaySubnets.

@Test
public void validateProvidedEndpointGatwaySubnets() {
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
    CloudSubnet publicSubnet = getPublicCloudSubnet(PUBLIC_ID_1, AZ_1);
    network.setGatewayEndpointSubnetMetas(Map.of(KEY, publicSubnet));
    when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1)));
    when(subnetSelector.chooseSubnetForEndpointGateway(any(), anyString())).thenReturn(Optional.of(publicSubnet));
    ValidationResult result = underTest.validate(new ImmutablePair<>(PRIVATE_ID_1, network));
    assertNoError(result);
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest)

Example 67 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EndpointGatewayNetworkValidatorTest method validateNoBaseSubnetId.

@Test
public void validateNoBaseSubnetId() {
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
    ValidationResult result = underTest.validate(new ImmutablePair<>("", network));
    assert result.hasError();
    assertEquals(NO_BASE_SUBNET, result.getErrors().get(0));
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest)

Example 68 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EndpointGatewayNetworkValidatorTest method validateEndpointGatewayDisabled.

@Test
public void validateEndpointGatewayDisabled() {
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.DISABLED);
    ValidationResult result = underTest.validate(new ImmutablePair<>("", network));
    assertNoError(result);
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.Test) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest)

Example 69 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EndpointGatewayNetworkValidatorTest method validateProvidedClusterSubnets.

@Test
public void validateProvidedClusterSubnets() {
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
    CloudSubnet publicSubnet = getPublicCloudSubnet(PUBLIC_ID_1, AZ_1);
    CloudSubnet privateSubnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    network.setSubnetMetas(Map.of(KEY, privateSubnet, KEY + '2', publicSubnet));
    when(subnetSelector.findSubnetById(anyMap(), anyString())).thenReturn(Optional.of(privateSubnet));
    when(subnetSelector.chooseSubnetForEndpointGateway(any(), anyString())).thenReturn(Optional.of(publicSubnet));
    ValidationResult result = underTest.validate(new ImmutablePair<>(PRIVATE_ID_1, network));
    assertNoError(result);
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.Test) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest)

Example 70 with EnvironmentNetworkResponse

use of com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse in project cloudbreak by hortonworks.

the class EndpointGatewayNetworkValidatorTest method validateNoBaseSubnetMeta.

@Test
public void validateNoBaseSubnetMeta() {
    EnvironmentNetworkResponse network = new EnvironmentNetworkResponse();
    network.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
    when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.empty());
    ValidationResult result = underTest.validate(new ImmutablePair<>(PRIVATE_ID_1, network));
    assert result.hasError();
    assertEquals(String.format(NO_BASE_SUBNET_META, PRIVATE_ID_1), result.getErrors().get(0));
}
Also used : EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.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