use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method setUp.
@BeforeEach
public void setUp() {
dbStack = new DBStack();
dbStack.setId(1L);
dbStack.setName("mystack");
dbStack.setDisplayName("My Stack");
dbStack.setDescription("my stack");
dbStack.setEnvironmentId("myenv");
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenSslDisabled.
@ParameterizedTest(name = "{0}")
@MethodSource("conversionTestWhenSslDisabledDataProvider")
void conversionTestWhenSslDisabled(String testCaseName, boolean fieldSslEnabled, SslConfigV4Request sslConfigV4Request) {
setupMinimalValid(sslConfigV4Request, AWS_CLOUD_PLATFORM);
ReflectionTestUtils.setField(underTest, FIELD_SSL_ENABLED, fieldSslEnabled);
DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
SslConfig sslConfig = dbStack.getSslConfig();
assertThat(sslConfig).isNotNull();
Set<String> sslCertificates = sslConfig.getSslCertificates();
assertThat(sslCertificates).isNotNull();
assertThat(sslCertificates).isEmpty();
assertThat(sslConfig.getSslCertificateType()).isEqualTo(SslCertificateType.NONE);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenSslEnabledAndAwsAndNoCerts.
@Test
void conversionTestWhenSslEnabledAndAwsAndNoCerts() {
setupMinimalValid(createSslConfigV4Request(SslMode.ENABLED), AWS_CLOUD_PLATFORM);
when(databaseServerSslCertificateConfig.getNumberOfCertsByCloudPlatformAndRegion(AWS_CLOUD_PLATFORM.name(), REGION)).thenReturn(NO_CERTS);
DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
verifySsl(dbStack, Set.of(), null);
verify(databaseServerSslCertificateConfig, never()).getCertByCloudPlatformAndRegionAndVersion(anyString(), anyString(), anyInt());
verify(databaseServerSslCertificateConfig, never()).getCertsByCloudPlatformAndRegionAndVersions(anyString(), anyString(), any());
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenSslEnabledAndSingleCertReturnedInternal.
private void conversionTestWhenSslEnabledAndSingleCertReturnedInternal(String cloudPlatform, int numOfCerts) {
when(databaseServerSslCertificateConfig.getNumberOfCertsByCloudPlatformAndRegion(cloudPlatform, REGION)).thenReturn(numOfCerts);
when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndVersion(cloudPlatform, REGION, VERSION_3)).thenReturn(sslCertificateEntryV3);
DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
verifySsl(dbStack, Set.of(CERT_PEM_V3), CLOUD_PROVIDER_IDENTIFIER_V3);
verify(databaseServerSslCertificateConfig, never()).getCertsByCloudPlatformAndRegionAndVersions(anyString(), anyString(), any());
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeBringYourOwn.
@Test
void testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeBringYourOwn() {
DatabaseServerConfig server = new DatabaseServerConfig();
server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
DBStack dbStack = new DBStack();
SslConfig sslConfig = new SslConfig();
sslConfig.setSslCertificateType(SslCertificateType.BRING_YOUR_OWN);
dbStack.setSslConfig(sslConfig);
server.setDbStack(dbStack);
DatabaseServerV4Response response = converter.convert(server);
assertThat(response).isNotNull();
SslConfigV4Response sslConfigV4Response = response.getSslConfig();
assertThat(sslConfigV4Response).isNotNull();
assertThat(sslConfigV4Response.getSslMode()).isEqualTo(SslMode.ENABLED);
assertThat(sslConfigV4Response.getSslCertificateType()).isEqualTo(SslCertificateType.BRING_YOUR_OWN);
}
Aggregations