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();
}
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();
}
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);
}
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();
}
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);
}
Aggregations