use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class RedbeamsDbCertificateProviderTest method getRelatedSslCertsWhenTheClusterDistroXAndNoRdsConfiguredAndRelatedSdxDoesNotHaveRdsConfigured.
@Test
void getRelatedSslCertsWhenTheClusterDistroXAndNoRdsConfiguredAndRelatedSdxDoesNotHaveRdsConfigured() {
String dbServerCrn = "adbservercrn";
String certificateA = "certificate-A";
Cluster sdxCluster = TestUtil.cluster();
sdxCluster.setId(2L);
sdxCluster.setDatabaseServerCrn(null);
Stack sdxStack = sdxCluster.getStack();
sdxStack.setCluster(sdxCluster);
sdxStack.setType(StackType.DATALAKE);
sdxStack.setId(2L);
Cluster cluster = TestUtil.cluster();
cluster.setDatabaseServerCrn(dbServerCrn);
Stack stack = cluster.getStack();
stack.setCluster(cluster);
stack.setType(StackType.WORKLOAD);
when(datalakeService.getDatalakeStackByDatahubStack(any())).thenReturn(Optional.of(sdxStack));
when(dbServerConfigurer.isRemoteDatabaseNeeded(sdxCluster)).thenReturn(Boolean.FALSE);
when(dbServerConfigurer.isRemoteDatabaseNeeded(cluster)).thenReturn(Boolean.TRUE);
DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
databaseServerV4Response.setSslConfig(getSslConfigV4ResponseWithCertificate(Set.of(certificateA)));
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.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class RedbeamsDbCertificateProviderTest method getRelatedSslCertsWhenTheClusterDistroXAndRdsConfiguredButRelatedSdxRdsHasNoSSLConfigured.
@Test
void getRelatedSslCertsWhenTheClusterDistroXAndRdsConfiguredButRelatedSdxRdsHasNoSSLConfigured() {
String dbServerCrn = "dbservercrn-A";
String dbServerCrnB = "dbservercrn-B";
String certificateA = "certificate-A";
Cluster sdxCluster = TestUtil.cluster();
sdxCluster.setId(2L);
sdxCluster.setDatabaseServerCrn(dbServerCrnB);
Stack sdxStack = sdxCluster.getStack();
sdxStack.setCluster(sdxCluster);
sdxStack.setType(StackType.DATALAKE);
sdxStack.setId(2L);
Cluster cluster = TestUtil.cluster();
cluster.setDatabaseServerCrn(dbServerCrn);
Stack stack = cluster.getStack();
stack.setCluster(cluster);
stack.setType(StackType.WORKLOAD);
when(datalakeService.getDatalakeStackByDatahubStack(any())).thenReturn(Optional.of(sdxStack));
when(dbServerConfigurer.isRemoteDatabaseNeeded(any())).thenReturn(Boolean.TRUE);
DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
databaseServerV4Response.setSslConfig(getSslConfigV4ResponseWithCertificate(Set.of(certificateA)));
when(dbServerConfigurer.getDatabaseServer(dbServerCrn)).thenReturn(databaseServerV4Response);
DatabaseServerV4Response databaseServerV4ResponseB = new DatabaseServerV4Response();
SslConfigV4Response sslConfig = new SslConfigV4Response();
sslConfig.setSslMode(SslMode.DISABLED);
databaseServerV4ResponseB.setSslConfig(sslConfig);
when(dbServerConfigurer.getDatabaseServer(dbServerCrnB)).thenReturn(databaseServerV4ResponseB);
Set<String> actual = underTest.getRelatedSslCerts(stack, cluster);
assertThat(actual).isNotEmpty();
assertThat(actual).contains(certificateA);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response 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);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackAbsentButHostAndPortPresent.
@Test
void testConversionOfSslConfigWhenDbStackAbsentButHostAndPortPresent() {
DatabaseServerConfig server = new DatabaseServerConfig();
server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setHost(HOST);
server.setPort(PORT);
DatabaseServerV4Response response = converter.convert(server);
assertThat(response).isNotNull();
assertThat(response.getSslConfig()).isNotNull();
assertThat(response.getSslConfig().getSslMode()).isEqualTo(SslMode.DISABLED);
assertThat(response.getStatus()).isEqualTo(Status.AVAILABLE);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class DatabaseServerV4ControllerTest method testDeleteByName.
@Test
public void testDeleteByName() {
when(terminationService.terminateByName(ENVIRONMENT_CRN, SERVER_NAME, true)).thenReturn(server);
when(databaseServerConfigToDatabaseServerV4ResponseConverter.convert(server)).thenReturn(serverResponse);
DatabaseServerV4Response response = underTest.deleteByName(ENVIRONMENT_CRN, SERVER_NAME, true);
assertEquals(serverResponse.getId().longValue(), response.getId().longValue());
}
Aggregations