Search in sources :

Example 31 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentValidatorServiceTest method testValidateSecurityAccessModificationWhenDefaultSecGroupAdded.

@Test
void testValidateSecurityAccessModificationWhenDefaultSecGroupAdded() {
    Environment environment = new Environment();
    SecurityAccessDto securityAccessDto = SecurityAccessDto.builder().withDefaultSecurityGroupId("sec-group").build();
    ValidationResult validationResult = underTest.validateSecurityAccessModification(securityAccessDto, environment);
    assertFalse(validationResult.hasError());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SecurityAccessDto(com.sequenceiq.environment.environment.dto.SecurityAccessDto) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 32 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentValidatorServiceTest method testValidateSecurityAccessModificationWhenKnoxSecGroupAdded.

@Test
void testValidateSecurityAccessModificationWhenKnoxSecGroupAdded() {
    Environment environment = new Environment();
    SecurityAccessDto securityAccessDto = SecurityAccessDto.builder().withSecurityGroupIdForKnox("knox-sec-group").build();
    ValidationResult validationResult = underTest.validateSecurityAccessModification(securityAccessDto, environment);
    assertFalse(validationResult.hasError());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SecurityAccessDto(com.sequenceiq.environment.environment.dto.SecurityAccessDto) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentValidatorServiceTest method testValidateSecurityAccessModificationWhenCidrAndDefaultSecurityGroupAddedInRequest.

@Test
void testValidateSecurityAccessModificationWhenCidrAndDefaultSecurityGroupAddedInRequest() {
    Environment environment = new Environment();
    SecurityAccessDto securityAccessDto = SecurityAccessDto.builder().withCidr("cidr").withDefaultSecurityGroupId("sec-group").build();
    ValidationResult validationResult = underTest.validateSecurityAccessModification(securityAccessDto, environment);
    assertTrue(validationResult.hasError());
    assertEquals("The CIDR could not be updated in the environment", validationResult.getFormattedErrors());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SecurityAccessDto(com.sequenceiq.environment.environment.dto.SecurityAccessDto) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentValidatorServiceTest method shouldFailOnChildEnvironmentCloudPlatformNotSupported.

@Test
void shouldFailOnChildEnvironmentCloudPlatformNotSupported() {
    Environment environment = aValidEnvirontmentWithParent();
    environment.setCloudPlatform(CloudPlatform.GCP.name());
    ValidationResult validationResult = underTest.validateParentChildRelation(environment, "parentEnvName");
    assertEquals("'GCP' platform is not supported for child environment.", validationResult.getFormattedErrors());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentValidatorServiceTest method testValidateAuthenticationModificationWhenPublicKeyAndPublicKeyIdIsEmptyAsWell.

@Test
void testValidateAuthenticationModificationWhenPublicKeyAndPublicKeyIdIsEmptyAsWell() {
    Environment environment = new Environment();
    environment.setCloudPlatform("AWS");
    EnvironmentEditDto environmentEditDto = EnvironmentEditDto.builder().withAuthentication(AuthenticationDto.builder().build()).build();
    ValidationResult validationResult = underTest.validateAuthenticationModification(environmentEditDto, environment);
    assertEquals("You should define either the publicKey or the publicKeyId.", validationResult.getFormattedErrors());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) EnvironmentEditDto(com.sequenceiq.environment.environment.dto.EnvironmentEditDto) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Environment (com.sequenceiq.environment.environment.domain.Environment)187 Test (org.junit.jupiter.api.Test)145 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)48 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)42 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)29 Credential (com.sequenceiq.environment.credential.domain.Credential)26 EnvironmentAuthentication (com.sequenceiq.environment.environment.domain.EnvironmentAuthentication)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)21 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)16 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)15 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)14 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)13 SecurityAccessDto (com.sequenceiq.environment.environment.dto.SecurityAccessDto)12 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)11 AwsParametersDto (com.sequenceiq.environment.parameter.dto.AwsParametersDto)11 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)11 Headers (reactor.bus.Event.Headers)11 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)10 AuthenticationDto (com.sequenceiq.environment.environment.dto.AuthenticationDto)10