Search in sources :

Example 16 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class DBStackToDatabaseStackConverterTest method setUp.

@BeforeEach
public void setUp() {
    dbStack = new DBStack();
    dbStack.setId(1L);
    dbStack.setName("mystack");
    dbStack.setDisplayName("My Stack");
    dbStack.setDescription("my stack");
    dbStack.setEnvironmentId("myenv");
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 17 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenSslDisabled.

@ParameterizedTest(name = "{0}")
@MethodSource("conversionTestWhenSslDisabledDataProvider")
void conversionTestWhenSslDisabled(String testCaseName, boolean fieldSslEnabled, SslConfigV4Request sslConfigV4Request) {
    setupMinimalValid(sslConfigV4Request, AWS_CLOUD_PLATFORM);
    ReflectionTestUtils.setField(underTest, FIELD_SSL_ENABLED, fieldSslEnabled);
    DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
    SslConfig sslConfig = dbStack.getSslConfig();
    assertThat(sslConfig).isNotNull();
    Set<String> sslCertificates = sslConfig.getSslCertificates();
    assertThat(sslCertificates).isNotNull();
    assertThat(sslCertificates).isEmpty();
    assertThat(sslConfig.getSslCertificateType()).isEqualTo(SslCertificateType.NONE);
}
Also used : SslConfig(com.sequenceiq.redbeams.domain.stack.SslConfig) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 18 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenSslEnabledAndAwsAndNoCerts.

@Test
void conversionTestWhenSslEnabledAndAwsAndNoCerts() {
    setupMinimalValid(createSslConfigV4Request(SslMode.ENABLED), AWS_CLOUD_PLATFORM);
    when(databaseServerSslCertificateConfig.getNumberOfCertsByCloudPlatformAndRegion(AWS_CLOUD_PLATFORM.name(), REGION)).thenReturn(NO_CERTS);
    DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
    verifySsl(dbStack, Set.of(), null);
    verify(databaseServerSslCertificateConfig, never()).getCertByCloudPlatformAndRegionAndVersion(anyString(), anyString(), anyInt());
    verify(databaseServerSslCertificateConfig, never()).getCertsByCloudPlatformAndRegionAndVersions(anyString(), anyString(), any());
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenSslEnabledAndSingleCertReturnedInternal.

private void conversionTestWhenSslEnabledAndSingleCertReturnedInternal(String cloudPlatform, int numOfCerts) {
    when(databaseServerSslCertificateConfig.getNumberOfCertsByCloudPlatformAndRegion(cloudPlatform, REGION)).thenReturn(numOfCerts);
    when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndVersion(cloudPlatform, REGION, VERSION_3)).thenReturn(sslCertificateEntryV3);
    DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
    verifySsl(dbStack, Set.of(CERT_PEM_V3), CLOUD_PROVIDER_IDENTIFIER_V3);
    verify(databaseServerSslCertificateConfig, never()).getCertsByCloudPlatformAndRegionAndVersions(anyString(), anyString(), any());
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack)

Example 20 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeBringYourOwn.

@Test
void testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeBringYourOwn() {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    DBStack dbStack = new DBStack();
    SslConfig sslConfig = new SslConfig();
    sslConfig.setSslCertificateType(SslCertificateType.BRING_YOUR_OWN);
    dbStack.setSslConfig(sslConfig);
    server.setDbStack(dbStack);
    DatabaseServerV4Response response = converter.convert(server);
    assertThat(response).isNotNull();
    SslConfigV4Response sslConfigV4Response = response.getSslConfig();
    assertThat(sslConfigV4Response).isNotNull();
    assertThat(sslConfigV4Response.getSslMode()).isEqualTo(SslMode.ENABLED);
    assertThat(sslConfigV4Response.getSslCertificateType()).isEqualTo(SslCertificateType.BRING_YOUR_OWN);
}
Also used : SslConfig(com.sequenceiq.redbeams.domain.stack.SslConfig) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)83 Test (org.junit.jupiter.api.Test)28 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 Test (org.junit.Test)13 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)8 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)7 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)7 DatabaseStack (com.sequenceiq.cloudbreak.cloud.model.DatabaseStack)7 DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)6 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)6 Credential (com.sequenceiq.redbeams.dto.Credential)6 RedbeamsFailureEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent)6 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)5 CloudDatabaseServerSslCertificate (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate)5 RedbeamsEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Location (com.sequenceiq.cloudbreak.cloud.model.Location)4