use of com.sequenceiq.redbeams.domain.stack.DBStack 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));
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenSuccessSslBadSslCertificateTypeOrBadCloudPlatformInternal.
void syncSslCertificateIfNeededTestWhenSuccessSslBadSslCertificateTypeOrBadCloudPlatformInternal(SslCertificateType sslCertificateType, String cloudPlatform) throws Exception {
DBStack dbStack = getDBStack(createSslConfig(sslCertificateType, CERT_ID_1));
dbStack.setCloudPlatform(cloudPlatform);
underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
verify(cloudPlatformConnectors, never()).get(any(CloudPlatformVariant.class));
verify(databaseServerSslCertificateConfig, never()).getCertByCloudPlatformAndRegionAndCloudProviderIdentifier(anyString(), anyString(), anyString());
verify(dbStackService, never()).save(any(DBStack.class));
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenFailureSslAwsCloudProviderOwnedActiveSslRootCertificateQueryError.
@Test
void syncSslCertificateIfNeededTestWhenFailureSslAwsCloudProviderOwnedActiveSslRootCertificateQueryError() throws Exception {
DBStack dbStack = getDBStack(createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, CERT_ID_1));
dbStack.setCloudPlatform(CloudPlatform.AWS.name());
setupCloudConnectorMock();
Exception e = new Exception();
when(resourceConnector.getDatabaseServerActiveSslRootCertificate(authenticatedContext, databaseStack)).thenThrow(e);
Exception exceptionResult = assertThrows(Exception.class, () -> underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack));
assertThat(exceptionResult).isSameAs(e);
verify(databaseServerSslCertificateConfig, never()).getCertByCloudPlatformAndRegionAndCloudProviderIdentifier(anyString(), anyString(), anyString());
verify(dbStackService, never()).save(any(DBStack.class));
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificateSyncServiceTest method verifyDbStackCaptured.
private void verifyDbStackCaptured(Integer sslCertificateVersionExpected, Set<Object> sslCertificatesExpected) {
DBStack dbStackCaptured = dbStackArgumentCaptor.getValue();
assertThat(dbStackCaptured).isNotNull();
SslConfig sslConfigCaptured = dbStackCaptured.getSslConfig();
assertThat(sslConfigCaptured).isNotNull();
assertThat(sslConfigCaptured.getSslCertificateType()).isEqualTo(SslCertificateType.CLOUD_PROVIDER_OWNED);
assertThat(sslConfigCaptured.getSslCertificateActiveCloudProviderIdentifier()).isEqualTo(CERT_ID_2);
assertThat(sslConfigCaptured.getSslCertificateActiveVersion()).isEqualTo(sslCertificateVersionExpected);
assertThat(sslConfigCaptured.getSslCertificates()).isEqualTo(sslCertificatesExpected);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack 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));
}
Aggregations