use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverterTest method createSslConfigV4Request.
private static SslConfigV4Request createSslConfigV4Request(SslMode sslMode) {
SslConfigV4Request sslConfigV4Request = new SslConfigV4Request();
sslConfigV4Request.setSslMode(sslMode);
return sslConfigV4Request;
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request in project cloudbreak by hortonworks.
the class DatabaseService method getDatabaseRequest.
private AllocateDatabaseServerV4Request getDatabaseRequest(SdxCluster sdxCluster, DetailedEnvironmentResponse env) {
AllocateDatabaseServerV4Request req = new AllocateDatabaseServerV4Request();
String environmentCrn = env.getCrn();
req.setEnvironmentCrn(environmentCrn);
CloudPlatform cloudPlatform = CloudPlatform.valueOf(env.getCloudPlatform().toUpperCase(Locale.US));
req.setDatabaseServer(getDatabaseServerRequest(cloudPlatform, sdxCluster));
req.setTags(getTags(sdxCluster.getTags()));
req.setClusterCrn(sdxCluster.getCrn());
String runtime = sdxCluster.getRuntime();
if (platformConfig.isExternalDatabaseSslEnforcementSupportedFor(cloudPlatform) && isSslEnforcementSupportedForRuntime(runtime) && entitlementService.databaseWireEncryptionEnabled(Crn.safeFromString(environmentCrn).getAccountId())) {
LOGGER.info("Applying external DB SSL enforcement for cloud platform {} and runtime version {}", cloudPlatform, runtime);
SslConfigV4Request sslConfigV4Request = new SslConfigV4Request();
sslConfigV4Request.setSslMode(SslMode.ENABLED);
req.setSslConfig(sslConfigV4Request);
} else {
LOGGER.info("Skipping external DB SSL enforcement for cloud platform {} and runtime version {}", cloudPlatform, runtime);
}
return req;
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request in project cloudbreak by hortonworks.
the class DatabaseServiceTest method shouldSetDbConfigBasedOnClusterShape.
@ParameterizedTest(name = "{0}")
@MethodSource("sslEnforcementDataProvider")
public void shouldSetDbConfigBasedOnClusterShape(String testCaseName, boolean supportedPlatform, String runtime, Boolean entitled, boolean sslEnforcementAppliedExpected) {
SdxCluster cluster = new SdxCluster();
cluster.setClusterName("NAME");
cluster.setClusterShape(SdxClusterShape.LIGHT_DUTY);
cluster.setCrn(CLUSTER_CRN);
cluster.setRuntime(runtime);
DetailedEnvironmentResponse env = new DetailedEnvironmentResponse();
env.setName("ENV");
env.setCloudPlatform("aws");
env.setCrn(ENV_CRN);
DatabaseConfig databaseConfig = getDatabaseConfig();
when(databaseServerV4Endpoint.createInternal(any(), any())).thenThrow(BadRequestException.class);
DatabaseConfigKey dbConfigKey = new DatabaseConfigKey(CloudPlatform.AWS, SdxClusterShape.LIGHT_DUTY);
when(dbConfigs.get(dbConfigKey)).thenReturn(databaseConfig);
when(databaseParameterSetterMap.get(CloudPlatform.AWS)).thenReturn(getDatabaseParameterSetter());
when(platformConfig.isExternalDatabaseSslEnforcementSupportedFor(CloudPlatform.AWS)).thenReturn(supportedPlatform);
if (entitled != null) {
when(entitlementService.databaseWireEncryptionEnabled(ACCOUNT_ID)).thenReturn(entitled);
}
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
SdxStatusEntity status = new SdxStatusEntity();
status.setStatus(DatalakeStatusEnum.REQUESTED);
when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(status);
assertThatCode(() -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.create(cluster, env))).isInstanceOf(BadRequestException.class);
verify(databaseServerV4Endpoint).createInternal(allocateDatabaseServerV4RequestCaptor.capture(), anyString());
AllocateDatabaseServerV4Request dbRequest = allocateDatabaseServerV4RequestCaptor.getValue();
assertThat(dbRequest).isNotNull();
DatabaseServerV4StackRequest databaseServer = dbRequest.getDatabaseServer();
assertThat(databaseServer).isNotNull();
assertThat(databaseServer.getInstanceType()).isEqualTo("instanceType");
assertThat(databaseServer.getDatabaseVendor()).isEqualTo("vendor");
assertThat(databaseServer.getStorageSize()).isEqualTo(100L);
assertThat(dbRequest.getClusterCrn()).isEqualTo(CLUSTER_CRN);
assertThat(databaseServer.getAws()).isNotNull();
SslConfigV4Request sslConfig = dbRequest.getSslConfig();
if (sslEnforcementAppliedExpected) {
assertThat(sslConfig).isNotNull();
assertThat(sslConfig.getSslMode()).isEqualTo(SslMode.ENABLED);
} else {
assertThat(sslConfig).isNull();
}
verifyNoInteractions(sdxClusterRepository);
verifyNoInteractions(notificationService);
}
Aggregations