Search in sources :

Example 31 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class AzurePrivateEndpointValidatorTest method testCheckNetworkPoliciesWhenExistingNetworkWhenPrivateEndpointNetworkPoliciesDisabled.

@Test
void testCheckNetworkPoliciesWhenExistingNetworkWhenPrivateEndpointNetworkPoliciesDisabled() {
    ValidationResult.ValidationResultBuilder validationResultBuilder = new ValidationResult.ValidationResultBuilder();
    NetworkDto networkDto = getNetworkDto(getAzureParams());
    when(azureCloudSubnetParametersService.isPrivateEndpointNetworkPoliciesDisabled(any())).thenCallRealMethod();
    underTest.checkNetworkPoliciesWhenExistingNetwork(networkDto, getCloudSubnets(false), validationResultBuilder);
    assertFalse(validationResultBuilder.build().hasError());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 32 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class AzurePrivateEndpointValidatorTest method testCheckExistingPrivateDnsZoneWhenNoExistingDnsZonesProvided.

@Test
void testCheckExistingPrivateDnsZoneWhenNoExistingDnsZonesProvided() {
    ValidationResult.ValidationResultBuilder validationResultBuilder = new ValidationResult.ValidationResultBuilder();
    EnvironmentDto environmentDto = getEnvironmentDto(null, ResourceGroupUsagePattern.USE_SINGLE);
    NetworkDto networkDto = getNetworkDto(getAzureParams(), ServiceEndpointCreation.ENABLED_PRIVATE_ENDPOINT);
    when(azureExistingPrivateDnsZonesService.hasNoExistingZones(networkDto)).thenReturn(true);
    underTest.checkExistingPrivateDnsZone(validationResultBuilder, environmentDto, networkDto);
    verify(credentialToCloudCredentialConverter, never()).convert(any());
    verify(azureClientService, never()).getClient(any());
    verify(azureExistingPrivateDnsZoneValidatorService, never()).validate(any(), any(), any(), any(), any());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 33 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasCidr.

@Test
void testValidateDuringRequestWhenNetworkHasCidr() {
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, null, null, null, "1.2.3.4/16", 1, RegistrationType.CREATE_NEW);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setNetwork(networkDto);
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
    assertFalse(validationResultBuilder.build().hasError());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) Test(org.junit.jupiter.api.Test)

Example 34 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheAwsNetworkParamsContainsVPCId.

@Test
void testValidateDuringFlowWhenTheAwsNetworkParamsContainsVPCId() {
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    AwsParams awsParams = AwsParams.builder().withVpcId("aVPCResourceIDFromAWS").build();
    NetworkDto networkDto = NetworkDto.builder().withId(1L).withName("networkName").withResourceCrn("aResourceCRN").withAws(awsParams).build();
    underTest.validateDuringRequest(networkDto, validationResultBuilder);
    assertFalse(validationResultBuilder.build().hasError());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) AwsParams(com.sequenceiq.environment.network.dto.AwsParams) Test(org.junit.jupiter.api.Test)

Example 35 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheAwsNetworkParamsDoesNotContainVPCId.

@Test
void testValidateDuringFlowWhenTheAwsNetworkParamsDoesNotContainVPCId() {
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    AwsParams awsParams = AwsParams.builder().build();
    NetworkDto networkDto = NetworkDto.builder().withId(1L).withName("networkName").withResourceCrn("aResourceCRN").withAws(awsParams).build();
    underTest.validateDuringRequest(networkDto, validationResultBuilder);
    NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("The 'VPC identifier(vpcId)' parameter should be specified for the 'AWS' environment specific network!"));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) AwsParams(com.sequenceiq.environment.network.dto.AwsParams) Test(org.junit.jupiter.api.Test)

Aggregations

NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)144 Test (org.junit.jupiter.api.Test)124 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)59 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)40 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)31 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)27 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)21 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)21 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)15 Environment (com.sequenceiq.environment.environment.domain.Environment)15 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)12 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)10 AwsParams (com.sequenceiq.environment.network.dto.AwsParams)9 Features (com.sequenceiq.common.api.telemetry.model.Features)8 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)7 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)7