Search in sources :

Example 11 with CloudDatabaseServerSslCertificate

use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.

the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateUnknown.

@ParameterizedTest(name = "{0}")
@MethodSource("syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateDataProvider")
void syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateUnknown(String testCaseName, String sslCertificateActiveCloudProviderIdentifier) throws Exception {
    DBStack dbStack = getDBStack(createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, sslCertificateActiveCloudProviderIdentifier));
    dbStack.setCloudPlatform(CloudPlatform.AWS.name());
    setupCloudConnectorMock();
    when(resourceConnector.getDatabaseServerActiveSslRootCertificate(authenticatedContext, databaseStack)).thenReturn(new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_2));
    when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndCloudProviderIdentifier(CloudPlatform.AWS.name(), REGION, CERT_ID_2)).thenReturn(null);
    underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
    verify(dbStackService).save(dbStackArgumentCaptor.capture());
    verifyDbStackCaptured(null, Set.of());
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with CloudDatabaseServerSslCertificate

use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.

the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateFound.

@ParameterizedTest(name = "{0}")
@MethodSource("syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateDataProvider")
void syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateFound(String testCaseName, String sslCertificateActiveCloudProviderIdentifier) throws Exception {
    DBStack dbStack = getDBStack(createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, sslCertificateActiveCloudProviderIdentifier));
    dbStack.setCloudPlatform(CloudPlatform.AWS.name());
    setupCloudConnectorMock();
    when(resourceConnector.getDatabaseServerActiveSslRootCertificate(authenticatedContext, databaseStack)).thenReturn(new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_2));
    SslCertificateEntry cert = new SslCertificateEntry(CERT_VERSION, CERT_ID_2, CERT_PEM, x509Cert);
    when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndCloudProviderIdentifier(CloudPlatform.AWS.name(), REGION, CERT_ID_2)).thenReturn(cert);
    underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
    verify(dbStackService).save(dbStackArgumentCaptor.capture());
    verifyDbStackCaptured(CERT_VERSION, Set.of(CERT_PEM));
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) SslCertificateEntry(com.sequenceiq.redbeams.configuration.SslCertificateEntry) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 13 with CloudDatabaseServerSslCertificate

use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.

the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMatchingActiveSslRootCertificate.

@Test
void syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedMatchingActiveSslRootCertificate() throws Exception {
    DBStack dbStack = getDBStack(createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, CERT_ID_1));
    dbStack.setCloudPlatform(CloudPlatform.AWS.name());
    setupCloudConnectorMock();
    when(resourceConnector.getDatabaseServerActiveSslRootCertificate(authenticatedContext, databaseStack)).thenReturn(new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_1));
    underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
    verify(databaseServerSslCertificateConfig, never()).getCertByCloudPlatformAndRegionAndCloudProviderIdentifier(anyString(), anyString(), anyString());
    verify(dbStackService, never()).save(any(DBStack.class));
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with CloudDatabaseServerSslCertificate

use of com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate in project cloudbreak by hortonworks.

the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenFailureSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateInvalidCertificateEntryCloudProviderIdMismatch.

@Test
void syncSslCertificateIfNeededTestWhenFailureSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateInvalidCertificateEntryCloudProviderIdMismatch() throws Exception {
    DBStack dbStack = getDBStack(createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, CERT_ID_1));
    dbStack.setCloudPlatform(CloudPlatform.AWS.name());
    setupCloudConnectorMock();
    when(resourceConnector.getDatabaseServerActiveSslRootCertificate(authenticatedContext, databaseStack)).thenReturn(new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_2));
    SslCertificateEntry cert = new SslCertificateEntry(CERT_VERSION, CERT_ID_3, CERT_PEM, x509Cert);
    when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndCloudProviderIdentifier(CloudPlatform.AWS.name(), REGION, CERT_ID_2)).thenReturn(cert);
    IllegalStateException illegalStateException = assertThrows(IllegalStateException.class, () -> underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack));
    assertThat(illegalStateException).hasMessage(String.format("SSL certificate CloudProviderIdentifier mismatch for cloud platform \"%s\": expected=\"%s\", actual=\"%s\"", CloudPlatform.AWS.name(), CERT_ID_2, CERT_ID_3));
    verify(dbStackService, never()).save(any(DBStack.class));
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) SslCertificateEntry(com.sequenceiq.redbeams.configuration.SslCertificateEntry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CloudDatabaseServerSslCertificate (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate)14 Test (org.junit.jupiter.api.Test)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)5 Certificate (com.amazonaws.services.rds.model.Certificate)3 DescribeCertificatesRequest (com.amazonaws.services.rds.model.DescribeCertificatesRequest)3 AmazonRdsClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonRdsClient)3 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)3 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)3 CloudDatabaseServerSslCertificates (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificates)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2 ListTablesRequest (com.amazonaws.services.dynamodbv2.model.ListTablesRequest)2 ListTablesResult (com.amazonaws.services.dynamodbv2.model.ListTablesResult)2 DescribeInstanceTypeOfferingsRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypeOfferingsRequest)2 DescribeInstanceTypesRequest (com.amazonaws.services.ec2.model.DescribeInstanceTypesRequest)2 DescribeInstanceTypesResult (com.amazonaws.services.ec2.model.DescribeInstanceTypesResult)2 DescribeRegionsRequest (com.amazonaws.services.ec2.model.DescribeRegionsRequest)2 DescribeRegionsResult (com.amazonaws.services.ec2.model.DescribeRegionsResult)2 DescribeSubnetsResult (com.amazonaws.services.ec2.model.DescribeSubnetsResult)2 DescribeVpcsResult (com.amazonaws.services.ec2.model.DescribeVpcsResult)2