Search in sources :

Example 26 with Environment

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

the class EnvironmentSyncServiceTest method testGetStatusByFreeipa.

@ParameterizedTest(name = "{0}")
@MethodSource("getStatusByFreeipaParams")
void testGetStatusByFreeipa(String testName, DescribeFreeIpaResponse freeIpaResponse, EnvironmentStatus expected) {
    Environment environment = new Environment();
    environment.setAccountId("cloudera");
    environment.setResourceCrn("crn");
    when(freeIpaService.internalDescribe(environment.getResourceCrn(), "cloudera")).thenReturn(Optional.of(freeIpaResponse));
    EnvironmentStatus actual = underTest.getStatusByFreeipa(environment);
    Assertions.assertEquals(expected, actual);
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) Environment(com.sequenceiq.environment.environment.domain.Environment) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 27 with Environment

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

the class EnvironmentSyncServiceTest method testGetStatusByFreeipaWhenFreeipaAttachedButNotFound.

@Test
void testGetStatusByFreeipaWhenFreeipaAttachedButNotFound() {
    Environment environment = new Environment();
    environment.setResourceCrn("crn");
    environment.setCreateFreeIpa(true);
    when(freeIpaService.internalDescribe(environment.getResourceCrn(), "cloudera")).thenReturn(Optional.empty());
    EnvironmentStatus actual = underTest.getStatusByFreeipa(environment);
    Assertions.assertEquals(EnvironmentStatus.FREEIPA_DELETED_ON_PROVIDER_SIDE, actual);
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with Environment

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

the class EnvironmentValidatorServiceTest method testValidateAuthenticationModificationWhenHasPublicKeyIdButNotExists.

@Test
void testValidateAuthenticationModificationWhenHasPublicKeyIdButNotExists() {
    Environment environment = new Environment();
    environment.setCloudPlatform("AWS");
    EnvironmentEditDto environmentEditDto = EnvironmentEditDto.builder().withAuthentication(AuthenticationDto.builder().withPublicKeyId("pub-key-id").build()).build();
    PublicKeyConnector connector = mock(PublicKeyConnector.class);
    when(environmentResourceService.isPublicKeyIdExists(environment, "pub-key-id")).thenReturn(false);
    when(environmentResourceService.getPublicKeyConnector(environment.getCloudPlatform())).thenReturn(Optional.of(connector));
    ValidationResult validationResult = underTest.validateAuthenticationModification(environmentEditDto, environment);
    assertEquals("The publicKeyId with name of 'pub-key-id' does not exist on the provider.", validationResult.getFormattedErrors());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) PublicKeyConnector(com.sequenceiq.cloudbreak.cloud.PublicKeyConnector) 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)

Example 29 with Environment

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

the class EnvironmentValidatorServiceTest method testValidateAuthenticationModificationWhenNotAwsAndHasPublicKeyId.

@Test
void testValidateAuthenticationModificationWhenNotAwsAndHasPublicKeyId() {
    Environment environment = new Environment();
    environment.setCloudPlatform("AZURE");
    EnvironmentEditDto environmentEditDto = EnvironmentEditDto.builder().withAuthentication(AuthenticationDto.builder().withPublicKeyId("pub-key-id").build()).build();
    when(environmentResourceService.getPublicKeyConnector(environment.getCloudPlatform())).thenReturn(Optional.empty());
    ValidationResult validationResult = underTest.validateAuthenticationModification(environmentEditDto, environment);
    assertEquals("The change of publicKeyId is not supported on AZURE", 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)

Example 30 with Environment

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

the class EnvironmentValidatorServiceTest method shouldFailOnExistingParentEnvironmentNameButMissingParentEntity.

@Test
void shouldFailOnExistingParentEnvironmentNameButMissingParentEntity() {
    Environment environment = aValidEnvirontmentWithParent();
    environment.setParentEnvironment(null);
    ValidationResult validationResult = underTest.validateParentChildRelation(environment, "parentEnvName");
    assertEquals("Active parent environment with name 'parentEnvName' is not available in account '" + ACCOUNT + "'.", 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)

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