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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations