Search in sources :

Example 41 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class OtelTraceSourceConfigTests method testInvalidConfigWithNullKeyCert.

@Test
public void testInvalidConfigWithNullKeyCert() {
    // Prepare
    final PluginSetting sslNullKeyCertPluginSetting = completePluginSettingForOtelTraceSource(DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_PORT, false, false, false, true, null, TEST_KEY, RecordType.OTLP.toString(), DEFAULT_THREAD_COUNT, DEFAULT_MAX_CONNECTION_COUNT);
    final OTelTraceSourceConfig otelTraceSourceConfig = OBJECT_MAPPER.convertValue(sslNullKeyCertPluginSetting.getSettings(), OTelTraceSourceConfig.class);
    // When/Then
    assertThrows(IllegalArgumentException.class, otelTraceSourceConfig::validateAndInitializeCertAndKeyFileInS3);
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 42 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class OtelTraceSourceConfigTests method testConfigWithInValidRecordType.

@Test
public void testConfigWithInValidRecordType() {
    final String invalidRecordType = "unknown";
    final PluginSetting pluginSetting = completePluginSettingForOtelTraceSource(TEST_REQUEST_TIMEOUT_MS, TEST_PORT, false, false, false, false, null, null, invalidRecordType, TEST_THREAD_COUNT, TEST_MAX_CONNECTION_COUNT);
    assertThrows(IllegalArgumentException.class, () -> OBJECT_MAPPER.convertValue(pluginSetting.getSettings(), OTelTraceSourceConfig.class));
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 43 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class OtelTraceSourceConfigTests method testValidConfigWithS3CertAndKey.

@Test
public void testValidConfigWithS3CertAndKey() {
    // Prepare
    final PluginSetting validPluginSettingWithS3CertAndKey = completePluginSettingForOtelTraceSource(TEST_REQUEST_TIMEOUT_MS, TEST_PORT, false, false, false, true, TEST_KEY_CERT_S3, TEST_KEY_S3, RecordType.OTLP.toString(), TEST_THREAD_COUNT, TEST_MAX_CONNECTION_COUNT);
    validPluginSettingWithS3CertAndKey.getSettings().put(OTelTraceSourceConfig.AWS_REGION, TEST_REGION);
    final OTelTraceSourceConfig otelTraceSourceConfig = OBJECT_MAPPER.convertValue(validPluginSettingWithS3CertAndKey.getSettings(), OTelTraceSourceConfig.class);
    otelTraceSourceConfig.validateAndInitializeCertAndKeyFileInS3();
    // Then
    assertEquals(TEST_REQUEST_TIMEOUT_MS, otelTraceSourceConfig.getRequestTimeoutInMillis());
    assertEquals(TEST_PORT, otelTraceSourceConfig.getPort());
    assertEquals(TEST_THREAD_COUNT, otelTraceSourceConfig.getThreadCount());
    assertEquals(TEST_MAX_CONNECTION_COUNT, otelTraceSourceConfig.getMaxConnectionCount());
    assertFalse(otelTraceSourceConfig.hasHealthCheck());
    assertFalse(otelTraceSourceConfig.hasProtoReflectionService());
    assertTrue(otelTraceSourceConfig.isSsl());
    assertTrue(otelTraceSourceConfig.isSslCertAndKeyFileInS3());
    assertEquals(TEST_KEY_CERT_S3, otelTraceSourceConfig.getSslKeyCertChainFile());
    assertEquals(TEST_KEY_S3, otelTraceSourceConfig.getSslKeyFile());
}
Also used : PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 44 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class CertificateProviderFactoryTest method getCertificateProviderS3ProviderSuccess.

@Test
public void getCertificateProviderS3ProviderSuccess() {
    final Map<String, Object> settingsMap = new HashMap<>();
    settingsMap.put("ssl", true);
    settingsMap.put("awsRegion", "us-east-1");
    settingsMap.put("sslKeyCertChainFile", "s3://data/certificate/test_cert.crt");
    settingsMap.put("sslKeyFile", "s3://data/certificate/test_decrypted_key.key");
    final PluginSetting pluginSetting = new PluginSetting(null, settingsMap);
    pluginSetting.setPipelineName("pipeline");
    oTelTraceSourceConfig = OBJECT_MAPPER.convertValue(pluginSetting.getSettings(), OTelTraceSourceConfig.class);
    oTelTraceSourceConfig.validateAndInitializeCertAndKeyFileInS3();
    certificateProviderFactory = new CertificateProviderFactory(oTelTraceSourceConfig);
    final CertificateProvider certificateProvider = certificateProviderFactory.getCertificateProvider();
    assertThat(certificateProvider, IsInstanceOf.instanceOf(S3CertificateProvider.class));
}
Also used : OTelTraceSourceConfig(com.amazon.dataprepper.plugins.source.oteltrace.OTelTraceSourceConfig) HashMap(java.util.HashMap) CertificateProvider(com.amazon.dataprepper.plugins.certificate.CertificateProvider) ACMCertificateProvider(com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider) FileCertificateProvider(com.amazon.dataprepper.plugins.certificate.file.FileCertificateProvider) S3CertificateProvider(com.amazon.dataprepper.plugins.certificate.s3.S3CertificateProvider) S3CertificateProvider(com.amazon.dataprepper.plugins.certificate.s3.S3CertificateProvider) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 45 with PluginSetting

use of com.amazon.dataprepper.model.configuration.PluginSetting in project data-prepper by opensearch-project.

the class CertificateProviderFactoryTest method getCertificateProviderFileProviderSuccess.

@Test
public void getCertificateProviderFileProviderSuccess() {
    final Map<String, Object> settingsMap = new HashMap<>();
    settingsMap.put("ssl", true);
    settingsMap.put("sslKeyCertChainFile", "data/certificate/test_cert.crt");
    settingsMap.put("sslKeyFile", "data/certificate/test_decrypted_key.key");
    final PluginSetting pluginSetting = new PluginSetting(null, settingsMap);
    pluginSetting.setPipelineName("pipeline");
    oTelTraceSourceConfig = OBJECT_MAPPER.convertValue(pluginSetting.getSettings(), OTelTraceSourceConfig.class);
    certificateProviderFactory = new CertificateProviderFactory(oTelTraceSourceConfig);
    final CertificateProvider certificateProvider = certificateProviderFactory.getCertificateProvider();
    assertThat(certificateProvider, IsInstanceOf.instanceOf(FileCertificateProvider.class));
}
Also used : OTelTraceSourceConfig(com.amazon.dataprepper.plugins.source.oteltrace.OTelTraceSourceConfig) FileCertificateProvider(com.amazon.dataprepper.plugins.certificate.file.FileCertificateProvider) HashMap(java.util.HashMap) CertificateProvider(com.amazon.dataprepper.plugins.certificate.CertificateProvider) ACMCertificateProvider(com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider) FileCertificateProvider(com.amazon.dataprepper.plugins.certificate.file.FileCertificateProvider) S3CertificateProvider(com.amazon.dataprepper.plugins.certificate.s3.S3CertificateProvider) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Aggregations

PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)150 Test (org.junit.jupiter.api.Test)58 HashMap (java.util.HashMap)55 Test (org.junit.Test)43 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 Record (com.amazon.dataprepper.model.record.Record)22 AsciiString (io.netty.util.AsciiString)16 Measurement (io.micrometer.core.instrument.Measurement)12 StringJoiner (java.util.StringJoiner)12 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)12 Map (java.util.Map)11 Path (java.nio.file.Path)9 Server (com.linecorp.armeria.server.Server)8 Before (org.junit.Before)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 BlockingBuffer (com.amazon.dataprepper.plugins.buffer.blockingbuffer.BlockingBuffer)7 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)7 PluginMetrics (com.amazon.dataprepper.metrics.PluginMetrics)6 CertificateProvider (com.amazon.dataprepper.plugins.certificate.CertificateProvider)6 ACMCertificateProvider (com.amazon.dataprepper.plugins.certificate.acm.ACMCertificateProvider)6