Search in sources :

Example 46 with DatabaseServerV4Response

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

the class RedbeamsDbCertificateProviderTest method getRelatedSslCertsWhenTheClusterSdxAndRdsConfiguredButItsSslConfigIsNullShouldReturnWithEmptyResult.

@Test
void getRelatedSslCertsWhenTheClusterSdxAndRdsConfiguredButItsSslConfigIsNullShouldReturnWithEmptyResult() {
    String dbServerCrn = "adbservercrn";
    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);
    when(dbServerConfigurer.getDatabaseServer(dbServerCrn)).thenReturn(new DatabaseServerV4Response());
    Set<String> actual = underTest.getRelatedSslCerts(stack, cluster);
    assertThat(actual).isEmpty();
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 47 with DatabaseServerV4Response

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

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackAbsentAndNoHostOrPort.

@Test
void testConversionOfSslConfigWhenDbStackAbsentAndNoHostOrPort() {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    DatabaseServerV4Response response = converter.convert(server);
    assertThat(response).isNotNull();
    assertThat(response.getSslConfig()).isNotNull();
    assertThat(response.getSslConfig().getSslMode()).isEqualTo(SslMode.DISABLED);
    assertThat(response.getStatus()).isEqualTo(Status.UNKNOWN);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 48 with DatabaseServerV4Response

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

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionWhenUserManaged.

@Test
public void testConversionWhenUserManaged() {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setId(1L);
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setName(RESOURCE_ID);
    server.setDescription("mine not yours");
    server.setHost(HOST);
    server.setPort(PORT);
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    initializeSecrets(server);
    server.setCreationDate(System.currentTimeMillis());
    server.setEnvironmentId(ENVIRONMENT_ID);
    server.setResourceStatus(ResourceStatus.USER_MANAGED);
    when(stringToSecretResponseConverter.convert(anyString())).thenReturn(new SecretResponse());
    DatabaseServerV4Response response = converter.convert(server);
    verify(stringToSecretResponseConverter, times(2)).convert(anyString());
    assertThat(response).isNotNull();
    assertThat(response.getResourceStatus()).isEqualTo(server.getResourceStatus());
    assertThat(response.getStatus()).isEqualTo(Status.AVAILABLE);
    assertThat(response.getStatusReason()).isNull();
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 49 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response 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 50 with DatabaseServerV4Response

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

the class DatabaseServerConfigToDatabaseServerV4ResponseConverterTest method testConversionOfSslConfigWhenDbStackPresentButSslConfigAbsent.

@Test
void testConversionOfSslConfigWhenDbStackPresentButSslConfigAbsent() {
    DatabaseServerConfig server = new DatabaseServerConfig();
    server.setResourceCrn(TestData.getTestCrn(RESOURCE_TYPE_DATABASE_SERVER, RESOURCE_ID));
    server.setDatabaseVendor(DatabaseVendor.POSTGRES);
    DBStack dbStack = new DBStack();
    initDBStackStatus(dbStack);
    server.setDbStack(dbStack);
    DatabaseServerV4Response response = converter.convert(server);
    assertThat(response).isNotNull();
    assertThat(response.getSslConfig()).isNotNull();
    assertThat(response.getSslConfig().getSslMode()).isEqualTo(SslMode.DISABLED);
    assertThat(response.getStatus()).isEqualTo(dbStack.getStatus());
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)54 Test (org.junit.jupiter.api.Test)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)16 SslConfigV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)12 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)9 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)7 Test (org.junit.Test)6 StackDatabaseServerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse)5 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)5 DatabaseServerSslConfig (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)4 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)4 DatabaseServerStatusV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerStatusV4Response)4 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)4 Date (java.util.Date)4 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)3 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)3 NotFoundException (javax.ws.rs.NotFoundException)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3