use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.
the class RedbeamsDbCertificateProviderTest method getRelatedSslCertsWhenTheClusterSdxAndRdsConfiguredWithSSL.
@Test
void getRelatedSslCertsWhenTheClusterSdxAndRdsConfiguredWithSSL() {
String dbServerCrn = "adbservercrn";
String certificateA = "certificate-A";
Cluster cluster = TestUtil.cluster();
cluster.setDatabaseServerCrn(dbServerCrn);
Stack stack = cluster.getStack();
stack.setCluster(cluster);
stack.setType(StackType.DATALAKE);
when(dbServerConfigurer.isRemoteDatabaseNeeded(cluster)).thenReturn(Boolean.TRUE);
DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
SslConfigV4Response sslConfig = getSslConfigV4ResponseWithCertificate(Set.of(certificateA));
databaseServerV4Response.setSslConfig(sslConfig);
when(dbServerConfigurer.getDatabaseServer(dbServerCrn)).thenReturn(databaseServerV4Response);
Set<String> actual = underTest.getRelatedSslCerts(stack, cluster);
assertThat(actual).isNotEmpty();
assertThat(actual).contains(certificateA);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.
the class RedbeamsDbCertificateProviderTest method getSslConfigV4ResponseWithCertificate.
private SslConfigV4Response getSslConfigV4ResponseWithCertificate(Set<String> certs) {
SslConfigV4Response sslConfig = new SslConfigV4Response();
sslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
sslConfig.setSslMode(SslMode.ENABLED);
sslConfig.setSslCertificates(certs);
return sslConfig;
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeNone.
@Test
void testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeNone() {
DatabaseServerConfig server = new DatabaseServerConfig();
server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
DBStack dbStack = new DBStack();
dbStack.setSslConfig(new SslConfig());
initDBStackStatus(dbStack);
server.setDbStack(dbStack);
DatabaseServerV4Response response = converter.convert(server);
assertThat(response).isNotNull();
SslConfigV4Response sslConfigV4Response = response.getSslConfig();
assertThat(sslConfigV4Response).isNotNull();
assertThat(sslConfigV4Response.getSslMode()).isEqualTo(SslMode.DISABLED);
assertThat(sslConfigV4Response.getSslCertificateType()).isEqualTo(SslCertificateType.NONE);
assertThat(response.getStatus()).isEqualTo(dbStack.getStatus());
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeCloudProviderOwned.
@ParameterizedTest(name = "{0}")
@MethodSource("testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeCloudProviderOwnedDataProvider")
void testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeCloudProviderOwned(String testCaseName, Integer certActiveVersionInput, String certActiveCloudProviderIdentifierInput, int certActiveVersionExpected, String certActiveCloudProviderIdentifierExpected) {
DatabaseServerConfig server = new DatabaseServerConfig();
server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
DBStack dbStack = new DBStack();
dbStack.setCloudPlatform(CLOUD_PLATFORM);
dbStack.setRegion(REGION);
SslConfig sslConfig = new SslConfig();
sslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
sslConfig.setSslCertificates(CERTS);
sslConfig.setSslCertificateActiveVersion(certActiveVersionInput);
sslConfig.setSslCertificateActiveCloudProviderIdentifier(certActiveCloudProviderIdentifierInput);
dbStack.setSslConfig(sslConfig);
server.setDbStack(dbStack);
when(databaseServerSslCertificateConfig.getMaxVersionByCloudPlatformAndRegion(CLOUD_PLATFORM, REGION)).thenReturn(CERT_MAX_VERSION);
when(databaseServerSslCertificateConfig.getLegacyMaxVersionByCloudPlatformAndRegion(CLOUD_PLATFORM, REGION)).thenReturn(CERT_LEGACY_MAX_VERSION);
when(databaseServerSslCertificateConfig.getLegacyCloudProviderIdentifierByCloudPlatformAndRegion(CLOUD_PLATFORM, REGION)).thenReturn(CERT_LEGACY_CLOUD_PROVIDER_IDENTIFIER);
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.CLOUD_PROVIDER_OWNED);
assertThat(sslConfigV4Response.getSslCertificates()).isSameAs(CERTS);
assertThat(sslConfigV4Response.getSslCertificateHighestAvailableVersion()).isEqualTo(CERT_MAX_VERSION);
assertThat(sslConfigV4Response.getSslCertificateActiveVersion()).isEqualTo(certActiveVersionExpected);
assertThat(sslConfigV4Response.getSslCertificateActiveCloudProviderIdentifier()).isEqualTo(certActiveCloudProviderIdentifierExpected);
}
Aggregations