use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class SubnetChooserServiceTest method testChooseSubnetsWhenSubnetChooserReturnsErrorThenThrows.
@Test
public void testChooseSubnetsWhenSubnetChooserReturnsErrorThenThrows() {
List<CloudSubnet> subnets = List.of();
setupConnector("my error message");
DBStack dbStack = mock(DBStack.class);
when(dbStack.isHa()).thenReturn(true);
thrown.expect(BadRequestException.class);
thrown.expectMessage("my error message");
underTest.chooseSubnets(subnets, CloudPlatform.AWS, dbStack);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class SubnetChooserServiceTest method testChooseSubnetsWhenAwsNoHaThenHaIsFalse.
@Test
public void testChooseSubnetsWhenAwsNoHaThenHaIsFalse() {
List<CloudSubnet> subnets = List.of();
NetworkConnector networkConnector = setupConnector();
DBStack dbStack = mock(DBStack.class);
when(dbStack.isHa()).thenReturn(false);
underTest.chooseSubnets(subnets, CloudPlatform.AWS, dbStack);
ArgumentCaptor<SubnetSelectionParameters> subnetSelectionParametersCaptor = ArgumentCaptor.forClass(SubnetSelectionParameters.class);
verify(networkConnector).chooseSubnets(eq(subnets), subnetSelectionParametersCaptor.capture());
assertTrue(subnetSelectionParametersCaptor.getValue().isPreferPrivateIfExist());
assertFalse(subnetSelectionParametersCaptor.getValue().isHa());
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedNullActiveSslRootCertificate.
@Test
void syncSslCertificateIfNeededTestWhenSuccessSslAwsCloudProviderOwnedNullActiveSslRootCertificate() 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(null);
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 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());
}
use of com.sequenceiq.redbeams.domain.stack.DBStack 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));
}
Aggregations