Search in sources :

Example 11 with DatabaseServer

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

the class DBStackToDatabaseStackConverterTest method testConversionWithNullSslConfig.

@Test
void testConversionWithNullSslConfig() {
    DatabaseServer server = new DatabaseServer();
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    dbStack.setDatabaseServer(server);
    DatabaseStack convertedStack = underTest.convert(dbStack);
    assertThat(convertedStack.getDatabaseServer().isUseSslEnforcement()).isFalse();
}
Also used : DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Test(org.junit.jupiter.api.Test)

Example 12 with DatabaseServer

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

the class DBStackToDatabaseStackConverterTest method testConversionWithSslCertificateNone.

@Test
void testConversionWithSslCertificateNone() {
    DatabaseServer server = new DatabaseServer();
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    dbStack.setDatabaseServer(server);
    dbStack.setSslConfig(new SslConfig());
    DatabaseStack convertedStack = underTest.convert(dbStack);
    assertThat(convertedStack.getDatabaseServer().isUseSslEnforcement()).isFalse();
}
Also used : SslConfig(com.sequenceiq.redbeams.domain.stack.SslConfig) DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Test(org.junit.jupiter.api.Test)

Example 13 with DatabaseServer

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

the class DBStackToDatabaseStackConverterTest method testConversionAzureWithAzureEncryptionResourcesPresent.

@Test
public void testConversionAzureWithAzureEncryptionResourcesPresent() {
    Network network = new Network();
    network.setAttributes(new Json(NETWORK_ATTRIBUTES));
    dbStack.setNetwork(network);
    dbStack.setCloudPlatform(CLOUD_PLATFORM);
    dbStack.setParameters(new HashMap<>());
    DatabaseServer server = new DatabaseServer();
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
    dbStack.setDatabaseServer(server);
    dbStack.setTags(new Json(STACK_TAGS));
    dbStack.setTemplate("template");
    DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
    environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
    environmentResponse.setAzure(AzureEnvironmentParameters.builder().withResourceEncryptionParameters(AzureResourceEncryptionParameters.builder().withEncryptionKeyUrl(KEY_URL).withEncryptionKeyResourceGroupName(RESOURCE_GROUP).build()).build());
    when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
    DatabaseStack convertedStack = underTest.convert(dbStack);
    Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
    assertThat(parameters.get(ENCRYPTION_KEY_URL).toString()).isEqualTo(KEY_URL);
    assertThat(parameters.get(ENCRYPTION_KEY_RESOURCE_GROUP_NAME).toString()).isEqualTo(RESOURCE_GROUP);
    assertThat(parameters.size()).isEqualTo(4);
}
Also used : Network(com.sequenceiq.redbeams.domain.stack.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Json(com.sequenceiq.cloudbreak.common.json.Json) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 14 with DatabaseServer

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

the class DBStackToDatabaseStackConverterTest method testConversionWithSslCertificateBringYourOwn.

@Test
void testConversionWithSslCertificateBringYourOwn() {
    DatabaseServer server = new DatabaseServer();
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    dbStack.setDatabaseServer(server);
    SslConfig sslConfig = new SslConfig();
    sslConfig.setSslCertificateType(SslCertificateType.BRING_YOUR_OWN);
    dbStack.setSslConfig(sslConfig);
    DatabaseStack convertedStack = underTest.convert(dbStack);
    assertThat(convertedStack.getDatabaseServer().isUseSslEnforcement()).isTrue();
}
Also used : SslConfig(com.sequenceiq.redbeams.domain.stack.SslConfig) DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Test(org.junit.jupiter.api.Test)

Example 15 with DatabaseServer

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

the class RedbeamsCreationService method registerDatabaseServerConfig.

private void registerDatabaseServerConfig(DBStack dbStack, String clusterCrn) {
    DatabaseServer databaseServer = dbStack.getDatabaseServer();
    DatabaseServerConfig dbServerConfig = new DatabaseServerConfig();
    dbServerConfig.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
    dbServerConfig.setAccountId(databaseServer.getAccountId());
    dbServerConfig.setName(dbStack.getName());
    dbServerConfig.setDescription(dbStack.getDescription());
    dbServerConfig.setEnvironmentId(dbStack.getEnvironmentId());
    dbServerConfig.setConnectionDriver(databaseServer.getConnectionDriver());
    // username and password are set during conversion to DBStack
    dbServerConfig.setConnectionUserName(databaseServer.getRootUserName());
    dbServerConfig.setConnectionPassword(databaseServer.getRootPassword());
    dbServerConfig.setDatabaseVendor(databaseServer.getDatabaseVendor());
    dbServerConfig.setDbStack(dbStack);
    // host and port are set after allocation is complete, so leave as null
    dbServerConfig.setResourceCrn(Crn.safeFromString(dbStack.getResourceCrn()));
    dbServerConfig.setClusterCrn(clusterCrn);
    databaseServerConfigService.create(dbServerConfig, DEFAULT_WORKSPACE, false);
}
Also used : DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer)

Aggregations

DatabaseServer (com.sequenceiq.redbeams.domain.stack.DatabaseServer)16 DatabaseStack (com.sequenceiq.cloudbreak.cloud.model.DatabaseStack)11 Test (org.junit.jupiter.api.Test)11 Json (com.sequenceiq.cloudbreak.common.json.Json)8 Network (com.sequenceiq.redbeams.domain.stack.Network)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)6 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)3 DatabaseVendor (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor)1 TemplatingNotSupportedException (com.sequenceiq.cloudbreak.cloud.exception.TemplatingNotSupportedException)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)1 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)1 SecurityGroup (com.sequenceiq.redbeams.domain.stack.SecurityGroup)1 RedbeamsException (com.sequenceiq.redbeams.exception.RedbeamsException)1 HashSet (java.util.HashSet)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1