use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.
the class AwsPlatformResourcesTest method verifySslRootCertificate.
private void verifySslRootCertificate(Set<CloudDatabaseServerSslCertificate> sslCertificates, String certificateIdentifier) {
Optional<CloudDatabaseServerSslCertificate> match = sslCertificates.stream().filter(c -> certificateIdentifier.equals(c.getCertificateIdentifier())).findFirst();
assertThat(match).overridingErrorMessage("No cert found for certificateIdentifier %s", certificateIdentifier).isNotEmpty();
CloudDatabaseServerSslCertificate sslCertificate = match.get();
assertThat(sslCertificate.getCertificateType()).isEqualTo(CloudDatabaseServerSslCertificateType.ROOT);
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.
the class AwsPlatformResources method databaseServerGeneralSslRootCertificates.
@Override
public CloudDatabaseServerSslCertificates databaseServerGeneralSslRootCertificates(CloudCredential cloudCredential, Region region) {
requireNonNull(cloudCredential);
requireNonNull(region);
AmazonRdsClient rdsClient = getAmazonRdsClient(cloudCredential, region);
List<Certificate> certificates = rdsClient.describeCertificates(new DescribeCertificatesRequest());
Set<CloudDatabaseServerSslCertificate> sslCertificates = certificates.stream().map(Certificate::getCertificateIdentifier).map(id -> new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, id)).collect(Collectors.toSet());
return new CloudDatabaseServerSslCertificates(sslCertificates);
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.
the class AwsRdsStatusLookupServiceTest method getActiveSslRootCertificateTestWhenSuccess.
@Test
void getActiveSslRootCertificateTestWhenSuccess() {
when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult);
when(describeDBInstancesResult.getDBInstances()).thenReturn(List.of(dbInstance));
when(dbInstance.getCACertificateIdentifier()).thenReturn(CA_CERTIFICATE_IDENTIFIER);
CloudDatabaseServerSslCertificate result = victim.getActiveSslRootCertificate(authenticatedContext, dbStack);
assertThat(result).isNotNull();
assertThat(result.getCertificateType()).isEqualTo(CloudDatabaseServerSslCertificateType.ROOT);
assertThat(result.getCertificateIdentifier()).isEqualTo(CA_CERTIFICATE_IDENTIFIER);
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.
the class AwsRdsStatusLookupServiceTest method getActiveSslRootCertificateTestWhenDBInstanceNotFoundException.
@Test
void getActiveSslRootCertificateTestWhenDBInstanceNotFoundException() {
when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenThrow(DBInstanceNotFoundException.class);
CloudDatabaseServerSslCertificate result = victim.getActiveSslRootCertificate(authenticatedContext, dbStack);
assertThat(result).isNull();
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.
the class AwsResourceConnectorTest method getDatabaseServerActiveSslRootCertificateTest.
@Test
void getDatabaseServerActiveSslRootCertificateTest() {
CloudDatabaseServerSslCertificate sslCertificate = mock(CloudDatabaseServerSslCertificate.class);
when(awsRdsStatusLookupService.getActiveSslRootCertificate(authenticatedContext, dbStack)).thenReturn(sslCertificate);
CloudDatabaseServerSslCertificate result = underTest.getDatabaseServerActiveSslRootCertificate(authenticatedContext, dbStack);
assertThat(result).isSameAs(sslCertificate);
}
Aggregations