Search in sources :

Example 11 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class RedbeamsDbCertificateProviderTest method getRelatedSslCertsWhenTheClusterSdxAndRdsConfiguredWithSSL.

@Test
void getRelatedSslCertsWhenTheClusterSdxAndRdsConfiguredWithSSL() {
    String dbServerCrn = "adbservercrn";
    String certificateA = "certificate-A";
    Cluster cluster = TestUtil.cluster();
    cluster.setDatabaseServerCrn(dbServerCrn);
    Stack stack = cluster.getStack();
    stack.setCluster(cluster);
    stack.setType(StackType.DATALAKE);
    when(dbServerConfigurer.isRemoteDatabaseNeeded(cluster)).thenReturn(Boolean.TRUE);
    DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
    SslConfigV4Response sslConfig = getSslConfigV4ResponseWithCertificate(Set.of(certificateA));
    databaseServerV4Response.setSslConfig(sslConfig);
    when(dbServerConfigurer.getDatabaseServer(dbServerCrn)).thenReturn(databaseServerV4Response);
    Set<String> actual = underTest.getRelatedSslCerts(stack, cluster);
    assertThat(actual).isNotEmpty();
    assertThat(actual).contains(certificateA);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 12 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class RedbeamsDbCertificateProviderTest method getSslConfigV4ResponseWithCertificate.

private SslConfigV4Response getSslConfigV4ResponseWithCertificate(Set<String> certs) {
    SslConfigV4Response sslConfig = new SslConfigV4Response();
    sslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
    sslConfig.setSslMode(SslMode.ENABLED);
    sslConfig.setSslCertificates(certs);
    return sslConfig;
}
Also used : SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response)

Example 13 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeNone.

@Test
void testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeNone() {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    DBStack dbStack = new DBStack();
    dbStack.setSslConfig(new SslConfig());
    initDBStackStatus(dbStack);
    server.setDbStack(dbStack);
    DatabaseServerV4Response response = converter.convert(server);
    assertThat(response).isNotNull();
    SslConfigV4Response sslConfigV4Response = response.getSslConfig();
    assertThat(sslConfigV4Response).isNotNull();
    assertThat(sslConfigV4Response.getSslMode()).isEqualTo(SslMode.DISABLED);
    assertThat(sslConfigV4Response.getSslCertificateType()).isEqualTo(SslCertificateType.NONE);
    assertThat(response.getStatus()).isEqualTo(dbStack.getStatus());
}
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)

Example 14 with SslConfigV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeCloudProviderOwned.

@ParameterizedTest(name = "{0}")
@MethodSource("testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeCloudProviderOwnedDataProvider")
void testConversionOfSslConfigWhenDbStackPresentAndCertificateTypeCloudProviderOwned(String testCaseName, Integer certActiveVersionInput, String certActiveCloudProviderIdentifierInput, int certActiveVersionExpected, String certActiveCloudProviderIdentifierExpected) {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    DBStack dbStack = new DBStack();
    dbStack.setCloudPlatform(CLOUD_PLATFORM);
    dbStack.setRegion(REGION);
    SslConfig sslConfig = new SslConfig();
    sslConfig.setSslCertificateType(SslCertificateType.CLOUD_PROVIDER_OWNED);
    sslConfig.setSslCertificates(CERTS);
    sslConfig.setSslCertificateActiveVersion(certActiveVersionInput);
    sslConfig.setSslCertificateActiveCloudProviderIdentifier(certActiveCloudProviderIdentifierInput);
    dbStack.setSslConfig(sslConfig);
    server.setDbStack(dbStack);
    when(databaseServerSslCertificateConfig.getMaxVersionByCloudPlatformAndRegion(CLOUD_PLATFORM, REGION)).thenReturn(CERT_MAX_VERSION);
    when(databaseServerSslCertificateConfig.getLegacyMaxVersionByCloudPlatformAndRegion(CLOUD_PLATFORM, REGION)).thenReturn(CERT_LEGACY_MAX_VERSION);
    when(databaseServerSslCertificateConfig.getLegacyCloudProviderIdentifierByCloudPlatformAndRegion(CLOUD_PLATFORM, REGION)).thenReturn(CERT_LEGACY_CLOUD_PROVIDER_IDENTIFIER);
    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.CLOUD_PROVIDER_OWNED);
    assertThat(sslConfigV4Response.getSslCertificates()).isSameAs(CERTS);
    assertThat(sslConfigV4Response.getSslCertificateHighestAvailableVersion()).isEqualTo(CERT_MAX_VERSION);
    assertThat(sslConfigV4Response.getSslCertificateActiveVersion()).isEqualTo(certActiveVersionExpected);
    assertThat(sslConfigV4Response.getSslCertificateActiveCloudProviderIdentifier()).isEqualTo(certActiveCloudProviderIdentifierExpected);
}
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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

SslConfigV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response)14 DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)11 Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 DatabaseServerSslConfig (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)4 StackDatabaseServerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse)4 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)4 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)3 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)3 Date (java.util.Date)2 HashSet (java.util.HashSet)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1