use of com.amazonaws.services.rds.model.Certificate 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.amazonaws.services.rds.model.Certificate in project cloudbreak by hortonworks.
the class AmazonRdsClientTest method describeCertificatesTestSimple.
@Test
void describeCertificatesTestSimple() {
DescribeCertificatesRequest describeCertificatesRequest = mock(DescribeCertificatesRequest.class);
DescribeCertificatesResult describeCertificatesResult = mock(DescribeCertificatesResult.class);
Certificate cert1 = mock(Certificate.class);
Certificate cert2 = mock(Certificate.class);
when(describeCertificatesResult.getMarker()).thenReturn(null);
when(describeCertificatesResult.getCertificates()).thenReturn(List.of(cert1, cert2));
when(client.describeCertificates(describeCertificatesRequest)).thenReturn(describeCertificatesResult);
List<Certificate> certificates = underTest.describeCertificates(describeCertificatesRequest);
assertThat(certificates).isNotNull();
assertThat(certificates).isEqualTo(List.of(cert1, cert2));
}
use of com.amazonaws.services.rds.model.Certificate in project cloudbreak by hortonworks.
the class AmazonRdsClientTest method describeCertificatesTestWithPaging.
@Test
void describeCertificatesTestWithPaging() {
DescribeCertificatesRequest describeCertificatesRequest = mock(DescribeCertificatesRequest.class);
DescribeCertificatesResult describeCertificatesResult1 = mock(DescribeCertificatesResult.class);
Certificate cert1 = mock(Certificate.class);
when(describeCertificatesResult1.getMarker()).thenReturn(MARKER);
when(describeCertificatesResult1.getCertificates()).thenReturn(List.of(cert1));
DescribeCertificatesResult describeCertificatesResult2 = mock(DescribeCertificatesResult.class);
Certificate cert2 = mock(Certificate.class);
when(describeCertificatesResult2.getMarker()).thenReturn(null);
when(describeCertificatesResult2.getCertificates()).thenReturn(List.of(cert2));
when(client.describeCertificates(describeCertificatesRequest)).thenReturn(describeCertificatesResult1, describeCertificatesResult2);
List<Certificate> certificates = underTest.describeCertificates(describeCertificatesRequest);
assertThat(certificates).isNotNull();
assertThat(certificates).isEqualTo(List.of(cert1, cert2));
}
use of com.amazonaws.services.rds.model.Certificate 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);
}
Aggregations