use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class RedbeamsDbCertificateProvider method getDatabaseRootCerts.
private Set<String> getDatabaseRootCerts(Cluster cluster) {
Set<String> result = new HashSet<>();
if (dbServerConfigurer.isRemoteDatabaseNeeded(cluster)) {
String stackResourceCrn = cluster.getStack().getResourceCrn();
String clusterName = cluster.getName();
LOGGER.info("Gathering cluster's(crn:'{}', name: '{}') remote database root certificates", stackResourceCrn, clusterName);
String databaseServerCrn = cluster.getDatabaseServerCrn();
DatabaseServerV4Response databaseServer = dbServerConfigurer.getDatabaseServer(databaseServerCrn);
SslConfigV4Response sslConfig = databaseServer.getSslConfig();
if (sslConfig != null) {
if (SslMode.isEnabled(sslConfig.getSslMode())) {
Set<String> sslCertificates = sslConfig.getSslCertificates();
result.addAll(sslCertificates);
LOGGER.info("Number of certificates found:'{}' for cluster(crn:'{}', name: '{}')", sslCertificates.size(), stackResourceCrn, clusterName);
}
} else {
LOGGER.info("There no SSL config could be found for the remote database('{}').", databaseServerCrn);
}
}
return result;
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class RedbeamsDbCertificateProviderTest method getRelatedSslCertsWhenTheClusterDistroXAndRdsConfiguredAndRelatedSdxHasRdsConfigured.
@Test
void getRelatedSslCertsWhenTheClusterDistroXAndRdsConfiguredAndRelatedSdxHasRdsConfigured() {
String dbServerCrn = "dbservercrn-A";
String dbServerCrnB = "dbservercrn-B";
String certificateA = "certificate-A";
String certificateB = "certificate-B";
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();
databaseServerV4ResponseB.setSslConfig(getSslConfigV4ResponseWithCertificate(Set.of(certificateB)));
when(dbServerConfigurer.getDatabaseServer(dbServerCrnB)).thenReturn(databaseServerV4ResponseB);
Set<String> actual = underTest.getRelatedSslCerts(stack, cluster);
assertThat(actual).isNotEmpty();
assertThat(actual).contains(certificateA, certificateB);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class RedbeamsDbCertificateProviderTest method getRelatedSslCertsWhenTheClusterDistroXAndNoRdsConfiguredAndThereIsNoRelatedSdx.
@Test
void getRelatedSslCertsWhenTheClusterDistroXAndNoRdsConfiguredAndThereIsNoRelatedSdx() {
String dbServerCrn = "adbservercrn";
String certificateA = "certificate-A";
Cluster cluster = TestUtil.cluster();
cluster.setDatabaseServerCrn(dbServerCrn);
Stack stack = cluster.getStack();
stack.setCluster(cluster);
stack.setType(StackType.WORKLOAD);
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 getRelatedSslCertsWhenTheClusterDistroXAndNoRdsConfiguredButRelatedSdxHasRdsConfigured.
@Test
void getRelatedSslCertsWhenTheClusterDistroXAndNoRdsConfiguredButRelatedSdxHasRdsConfigured() {
String dbServerCrnB = "dbservercrn-B";
String certificateB = "certificate-B";
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(null);
Stack stack = cluster.getStack();
stack.setCluster(cluster);
stack.setType(StackType.WORKLOAD);
when(datalakeService.getDatalakeStackByDatahubStack(any())).thenReturn(Optional.of(sdxStack));
when(dbServerConfigurer.isRemoteDatabaseNeeded(cluster)).thenReturn(Boolean.FALSE);
when(dbServerConfigurer.isRemoteDatabaseNeeded(sdxCluster)).thenReturn(Boolean.TRUE);
DatabaseServerV4Response databaseServerV4ResponseB = new DatabaseServerV4Response();
databaseServerV4ResponseB.setSslConfig(getSslConfigV4ResponseWithCertificate(Set.of(certificateB)));
when(dbServerConfigurer.getDatabaseServer(dbServerCrnB)).thenReturn(databaseServerV4ResponseB);
Set<String> actual = underTest.getRelatedSslCerts(stack, cluster);
assertThat(actual).isNotEmpty();
assertThat(actual).contains(certificateB);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response 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);
}
Aggregations