use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates in project cloudbreak by hortonworks.
the class AwsPlatformResourcesTest method databaseServerGeneralSslRootCertificatesTestWhenSuccess.
@Test
void databaseServerGeneralSslRootCertificatesTestWhenSuccess() {
Certificate certificate1 = mock(Certificate.class);
when(certificate1.getCertificateIdentifier()).thenReturn("cert1");
Certificate certificate2 = mock(Certificate.class);
when(certificate2.getCertificateIdentifier()).thenReturn("cert2");
AmazonRdsClient amazonRdsClient = mock(AmazonRdsClient.class);
when(amazonRdsClient.describeCertificates(any(DescribeCertificatesRequest.class))).thenReturn(List.of(certificate1, certificate2));
when(awsClient.createRdsClient(any(AwsCredentialView.class), eq(REGION_NAME))).thenReturn(amazonRdsClient);
CloudDatabaseServerSslCertificates cloudDatabaseServerSslCertificates = underTest.databaseServerGeneralSslRootCertificates(cloudCredential, region);
assertThat(cloudDatabaseServerSslCertificates).isNotNull();
Set<CloudDatabaseServerSslCertificate> sslCertificates = cloudDatabaseServerSslCertificates.getSslCertificates();
assertThat(sslCertificates).isNotNull();
assertThat(sslCertificates).hasSize(2);
verifySslRootCertificate(sslCertificates, "cert1");
verifySslRootCertificate(sslCertificates, "cert2");
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificatePrescriptionServiceTest method prescribeSslCertificateIfNeededTestWhenSslAwsCloudProviderOwnedCertIdPrescribed.
@Test
void prescribeSslCertificateIfNeededTestWhenSslAwsCloudProviderOwnedCertIdPrescribed() {
initDBStack(CloudPlatform.AWS.name(), createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, CERT_ID_1));
when(cloudPlatformConnectors.get(cloudPlatformVariant)).thenReturn(cloudConnector);
when(cloudConnector.platformResources()).thenReturn(platformResources);
Set<CloudDatabaseServerSslCertificate> sslCertificates = Set.of(new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_1), new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_2));
when(platformResources.databaseServerGeneralSslRootCertificates(cloudCredential, region)).thenReturn(new CloudDatabaseServerSslCertificates(sslCertificates));
when(cloudContext.getPlatformVariant()).thenReturn(cloudPlatformVariant);
when(cloudContext.getLocation()).thenReturn(location);
underTest.prescribeSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
assertThat(databaseServer.getStringParameter(DatabaseServer.SSL_CERTIFICATE_IDENTIFIER)).isEqualTo(CERT_ID_1);
verify(cloudConnector).platformResources();
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificatePrescriptionServiceTest method prescribeSslCertificateIfNeededTestWhenSslAwsCloudProviderOwnedDefaultCertId.
@Test
void prescribeSslCertificateIfNeededTestWhenSslAwsCloudProviderOwnedDefaultCertId() {
initDBStack(CloudPlatform.AWS.name(), createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, CERT_ID_1));
when(cloudPlatformConnectors.get(cloudPlatformVariant)).thenReturn(cloudConnector);
when(cloudConnector.platformResources()).thenReturn(platformResources);
Set<CloudDatabaseServerSslCertificate> sslCertificates = Set.of(new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_1));
when(platformResources.databaseServerGeneralSslRootCertificates(cloudCredential, region)).thenReturn(new CloudDatabaseServerSslCertificates(sslCertificates));
when(cloudContext.getPlatformVariant()).thenReturn(cloudPlatformVariant);
when(cloudContext.getLocation()).thenReturn(location);
underTest.prescribeSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
assertThat(databaseServer.getStringParameter(DatabaseServer.SSL_CERTIFICATE_IDENTIFIER)).isNull();
verify(cloudConnector).platformResources();
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificatePrescriptionServiceTest method prescribeSslCertificateIfNeededTestWhenSslAwsCloudProviderOwnedUnsupportedCertId.
@ParameterizedTest(name = "{0}")
@MethodSource("prescribeSslCertificateIfNeededTestWhenSslAwsCloudProviderOwnedUnsupportedCertIdDataProvider")
void prescribeSslCertificateIfNeededTestWhenSslAwsCloudProviderOwnedUnsupportedCertId(String testCaseName, Set<CloudDatabaseServerSslCertificate> sslCertificates) {
initDBStack(CloudPlatform.AWS.name(), createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, CERT_ID_1));
when(cloudPlatformConnectors.get(cloudPlatformVariant)).thenReturn(cloudConnector);
when(cloudConnector.platformResources()).thenReturn(platformResources);
when(platformResources.databaseServerGeneralSslRootCertificates(cloudCredential, region)).thenReturn(new CloudDatabaseServerSslCertificates(sslCertificates));
when(cloudContext.getPlatformVariant()).thenReturn(cloudPlatformVariant);
when(cloudContext.getLocation()).thenReturn(location);
underTest.prescribeSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
assertThat(databaseServer.getStringParameter(DatabaseServer.SSL_CERTIFICATE_IDENTIFIER)).isNull();
verify(cloudConnector).platformResources();
}
use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificatePrescriptionService method getAvailableSslCertificateIdentifiers.
private Set<String> getAvailableSslCertificateIdentifiers(CloudContext cloudContext, CloudCredential cloudCredential, String cloudPlatform) {
CloudConnector<Object> connector = cloudPlatformConnectors.get(cloudContext.getPlatformVariant());
CloudDatabaseServerSslCertificates availableSslCertificates = connector.platformResources().databaseServerGeneralSslRootCertificates(cloudCredential, cloudContext.getLocation().getRegion());
Set<String> availableSslCertificateIdentifiers = availableSslCertificates.getSslCertificates().stream().map(CloudDatabaseServerSslCertificate::getCertificateIdentifier).collect(Collectors.toSet());
LOGGER.info("Available SSL certificate CloudProviderIdentifiers for cloud platform \"{}\": \"{}\", database stack {}", cloudPlatform, availableSslCertificateIdentifiers, cloudContext);
return availableSslCertificateIdentifiers;
}
Aggregations