Search in sources :

Example 1 with CloudDatabaseServerSslCertificates

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");
}
Also used : DescribeCertificatesRequest(com.amazonaws.services.rds.model.DescribeCertificatesRequest) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) AmazonRdsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient) CloudDatabaseServerSslCertificates(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) Certificate(com.amazonaws.services.rds.model.Certificate) Test(org.junit.jupiter.api.Test)

Example 2 with CloudDatabaseServerSslCertificates

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();
}
Also used : CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) CloudDatabaseServerSslCertificates(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with CloudDatabaseServerSslCertificates

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();
}
Also used : CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) CloudDatabaseServerSslCertificates(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with CloudDatabaseServerSslCertificates

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();
}
Also used : CloudDatabaseServerSslCertificates(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with CloudDatabaseServerSslCertificates

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;
}
Also used : CloudDatabaseServerSslCertificates(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates)

Aggregations

CloudDatabaseServerSslCertificates (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates)5 CloudDatabaseServerSslCertificate (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 AmazonServiceException (com.amazonaws.AmazonServiceException)1 SdkClientException (com.amazonaws.SdkClientException)1 ListTablesRequest (com.amazonaws.services.dynamodbv2.model.ListTablesRequest)1 ListTablesResult (com.amazonaws.services.dynamodbv2.model.ListTablesResult)1 AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)1 DescribeAvailabilityZonesRequest (com.amazonaws.services.ec2.model.DescribeAvailabilityZonesRequest)1 DescribeInstanceTypeOfferingsRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypeOfferingsRequest)1 DescribeInstanceTypesRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest)1 DescribeInstanceTypesResult (com.amazonaws.services.ec2.model.DescribeInstanceTypesResult)1 DescribeInternetGatewaysRequest (com.amazonaws.services.ec2.model.DescribeInternetGatewaysRequest)1 DescribeInternetGatewaysResult (com.amazonaws.services.ec2.model.DescribeInternetGatewaysResult)1 DescribeKeyPairsRequest (com.amazonaws.services.ec2.model.DescribeKeyPairsRequest)1 DescribeRegionsRequest (com.amazonaws.services.ec2.model.DescribeRegionsRequest)1 DescribeRegionsResult (com.amazonaws.services.ec2.model.DescribeRegionsResult)1 DescribeRouteTablesRequest (com.amazonaws.services.ec2.model.DescribeRouteTablesRequest)1 DescribeSecurityGroupsRequest (com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest)1