Search in sources :

Example 36 with ValidationResultBuilder

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

the class AwsEnvironmentSecurityGroupValidatorTest method testValidationWhenGroupsWhenGroupHasMoreGroupIdInTheSameVpcReturnIsValid.

@Test
public void testValidationWhenGroupsWhenGroupHasMoreGroupIdInTheSameVpcReturnIsValid() {
    Region region = getRegion();
    String sec1 = "sec-1,sec-2";
    String sec2 = "sec-2,sec-1";
    String requestVpcId = "vpc-124";
    when(platformParameterService.getSecurityGroups(any(PlatformResourceRequest.class))).thenReturn(cloudSecurityGroups(region.getName(), requestVpcId, "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);
    requestIsValid(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 37 with ValidationResultBuilder

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

the class AzureEnvironmentSecurityGroupValidatorTest method testValidationWhenGroupsInTheSameRegionReturnValid.

@Test
public void testValidationWhenGroupsInTheSameRegionReturnValid() {
    Region region = getRegion();
    when(platformParameterService.getSecurityGroups(any(PlatformResourceRequest.class))).thenReturn(cloudSecurityGroups(REGION, SECURITY_GROUP_1, SECURITY_GROUP_2));
    EnvironmentDto environmentDto = EnvironmentDto.builder().withRegions(Set.of(region)).withSecurityAccess(getSecurityAccessDto(SECURITY_GROUP_1, SECURITY_GROUP_2)).withCredential(getCredential()).build();
    EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
    ValidationResultBuilder builder = ValidationResult.builder();
    underTest.validate(environmentValidationDto, builder);
    requestIsValid(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 38 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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 39 with ValidationResultBuilder

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

the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheNetworkIsNull.

@Test
void testValidateDuringFlowWhenTheNetworkIsNull() {
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validateDuringFlow(mock(EnvironmentValidationDto.class), null, validationResultBuilder);
    assertFalse(validationResultBuilder.build().hasError());
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) Test(org.junit.jupiter.api.Test)

Example 40 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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)

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