Search in sources :

Example 1 with SslConfigV4Request

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;
}
Also used : SslConfigV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request)

Example 2 with 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;
}
Also used : CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) AllocateDatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request) SslConfigV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request)

Example 3 with SslConfigV4Request

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);
}
Also used : DatabaseServerV4StackRequest(com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) AllocateDatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SslConfigV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

SslConfigV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request)3 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 DatabaseServerV4StackRequest (com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1