Search in sources :

Example 31 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class AzureEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNoNetworkCidrAndNetworkId.

@Test
void testValidateDuringRequestWhenNoNetworkCidrAndNetworkId() {
    AzureParams azureParams = NetworkTestUtils.getAzureParams(true, true, true);
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(azureParams, null, null, azureParams.getNetworkId(), null, 1);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    underTest.validateDuringRequest(networkDto, resultBuilder);
    ValidationResult validationResult = resultBuilder.build();
    assertFalse(validationResult.hasError());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 32 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class AzureEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenSubnetsWithNoNetworkId.

@Test
void testValidateDuringRequestWhenSubnetsWithNoNetworkId() {
    AzureParams azureParams = NetworkTestUtils.getAzureParams(true, false, true);
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(azureParams, null, null, null, null, 2);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    underTest.validateDuringRequest(networkDto, resultBuilder);
    NetworkTestUtils.checkErrorsPresent(resultBuilder, List.of("Either the AZURE network id or cidr needs to be defined!", "If resourceGroupName is specified, then networkId must be specified too.", "If subnetIds are specified, then networkId must be specified too."));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Test(org.junit.jupiter.api.Test)

Example 33 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class AzureEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNoNetworkCidrAndNoResourceGroupName.

@Test
void testValidateDuringRequestWhenNoNetworkCidrAndNoResourceGroupName() {
    AzureParams azureParams = NetworkTestUtils.getAzureParams(true, true, false);
    NetworkDto networkDto = NetworkTestUtils.getNetworkDto(azureParams, null, null, azureParams.getNetworkId(), null, 1);
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    underTest.validateDuringRequest(networkDto, resultBuilder);
    NetworkTestUtils.checkErrorsPresent(resultBuilder, List.of("If networkId is specified, then resourceGroupName must be specified too."));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Test(org.junit.jupiter.api.Test)

Example 34 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class AwsEnvironmentSecurityGroupValidatorTest method testValidationWhenOnlyOneGroupDefinedReturnInValid.

@Test
public void testValidationWhenOnlyOneGroupDefinedReturnInValid() {
    Region region = getRegion();
    String sec1 = null;
    String sec2 = "sec-2";
    String vpcId = "vpc-123";
    when(platformParameterService.getSecurityGroups(any(PlatformResourceRequest.class))).thenReturn(cloudSecurityGroups(region.getName(), vpcId, sec1, sec2));
    EnvironmentDto environmentDto = EnvironmentDto.builder().withRegions(Set.of(region)).withSecurityAccess(getSecurityAccessDto(sec1, sec2)).withNetwork(getNetworkDto(vpcId)).withCredential(getCredential()).build();
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    ValidationResultBuilder builder = ValidationResult.builder();
    underTest.validate(environmentValidationDto, builder);
    requestIsInvalid(builder);
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Region(com.sequenceiq.environment.environment.domain.Region) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) Test(org.junit.jupiter.api.Test)

Example 35 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class AwsEnvironmentSecurityGroupValidatorTest method testValidationWhenGroupsInDifferentVpcReturnInValid.

@Test
public void testValidationWhenGroupsInDifferentVpcReturnInValid() {
    Region region = getRegion();
    String sec1 = "sec-1,sec-2";
    String sec2 = "sec-2";
    String vpcId = "vpc-123";
    String requestVpcId = "vpc-124";
    when(platformParameterService.getSecurityGroups(any(PlatformResourceRequest.class))).thenReturn(cloudSecurityGroups(region.getName(), vpcId, "sec-1", "sec-2"));
    EnvironmentDto environmentDto = EnvironmentDto.builder().withRegions(Set.of(region)).withSecurityAccess(getSecurityAccessDto(sec1, sec2)).withNetwork(getNetworkDto(requestVpcId)).withCredential(getCredential()).build();
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    ValidationResultBuilder builder = ValidationResult.builder();
    underTest.validate(environmentValidationDto, builder);
    requestIsInvalid(builder);
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Region(com.sequenceiq.environment.environment.domain.Region) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) PlatformResourceRequest(com.sequenceiq.environment.platformresource.PlatformResourceRequest) Test(org.junit.jupiter.api.Test)

Aggregations

ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)169 Test (org.junit.jupiter.api.Test)107 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)67 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)62 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)35 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)33 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)33 Test (org.junit.Test)20 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)16 Environment (com.sequenceiq.environment.environment.domain.Environment)11 ObjectStorageMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest)10 ObjectStorageMetadataResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse)10 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Credential (com.sequenceiq.environment.credential.domain.Credential)10 Region (com.sequenceiq.environment.environment.domain.Region)9 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)9 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 InstanceProfile (com.amazonaws.services.identitymanagement.model.InstanceProfile)6 Role (com.amazonaws.services.identitymanagement.model.Role)6 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)6