Search in sources :

Example 11 with SslCertificateEntry

use of com.sequenceiq.redbeams.configuration.SslCertificateEntry in project cloudbreak by hortonworks.

the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenFailureSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateInvalidCertificateEntryCloudProviderIdMismatch.

@Test
void syncSslCertificateIfNeededTestWhenFailureSslAwsCloudProviderOwnedMismatchingActiveSslRootCertificateInvalidCertificateEntryCloudProviderIdMismatch() throws Exception {
    DBStack dbStack = getDBStack(createSslConfig(SslCertificateType.CLOUD_PROVIDER_OWNED, CERT_ID_1));
    dbStack.setCloudPlatform(CloudPlatform.AWS.name());
    setupCloudConnectorMock();
    when(resourceConnector.getDatabaseServerActiveSslRootCertificate(authenticatedContext, databaseStack)).thenReturn(new CloudDatabaseServerSslCertificate(CloudDatabaseServerSslCertificateType.ROOT, CERT_ID_2));
    SslCertificateEntry cert = new SslCertificateEntry(CERT_VERSION, CERT_ID_3, CERT_PEM, x509Cert);
    when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndCloudProviderIdentifier(CloudPlatform.AWS.name(), REGION, CERT_ID_2)).thenReturn(cert);
    IllegalStateException illegalStateException = assertThrows(IllegalStateException.class, () -> underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack));
    assertThat(illegalStateException).hasMessage(String.format("SSL certificate CloudProviderIdentifier mismatch for cloud platform \"%s\": expected=\"%s\", actual=\"%s\"", CloudPlatform.AWS.name(), CERT_ID_2, CERT_ID_3));
    verify(dbStackService, never()).save(any(DBStack.class));
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CloudDatabaseServerSslCertificate(com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate) SslCertificateEntry(com.sequenceiq.redbeams.configuration.SslCertificateEntry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SslCertificateEntry (com.sequenceiq.redbeams.configuration.SslCertificateEntry)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 Test (org.junit.jupiter.api.Test)6 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)4 CloudDatabaseServerSslCertificate (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate)3 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)2 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)1 DatabaseServerV4StackRequest (com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest)1 NetworkV4StackRequest (com.sequenceiq.redbeams.api.endpoint.v4.stacks.NetworkV4StackRequest)1 SecurityGroupV4StackRequest (com.sequenceiq.redbeams.api.endpoint.v4.stacks.SecurityGroupV4StackRequest)1 Objects (java.util.Objects)1 Set (java.util.Set)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1