Search in sources :

Example 16 with PluginModel

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

the class OTelMetricsSource method createAuthenticationProvider.

private GrpcAuthenticationProvider createAuthenticationProvider(final PluginFactory pluginFactory) {
    final PluginModel authenticationConfiguration = oTelMetricsSourceConfig.getAuthentication();
    if (authenticationConfiguration == null || authenticationConfiguration.getPluginName().equals(GrpcAuthenticationProvider.UNAUTHENTICATED_PLUGIN_NAME)) {
        LOG.warn("Creating otel-metrics-source without authentication. This is not secure.");
        LOG.warn("In order to set up Http Basic authentication for the otel-metrics-source, go here: https://github.com/opensearch-project/data-prepper/tree/main/data-prepper-plugins/otel-metrics-source#authentication-configurations");
    }
    final PluginSetting authenticationPluginSetting;
    if (authenticationConfiguration != null) {
        authenticationPluginSetting = new PluginSetting(authenticationConfiguration.getPluginName(), authenticationConfiguration.getPluginSettings());
    } else {
        authenticationPluginSetting = new PluginSetting(GrpcAuthenticationProvider.UNAUTHENTICATED_PLUGIN_NAME, Collections.emptyMap());
    }
    return pluginFactory.loadPlugin(GrpcAuthenticationProvider.class, authenticationPluginSetting);
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 17 with PluginModel

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

the class OTelTraceSource method createAuthenticationProvider.

private GrpcAuthenticationProvider createAuthenticationProvider(final PluginFactory pluginFactory) {
    final PluginModel authenticationConfiguration = oTelTraceSourceConfig.getAuthentication();
    if (authenticationConfiguration == null || authenticationConfiguration.getPluginName().equals(GrpcAuthenticationProvider.UNAUTHENTICATED_PLUGIN_NAME)) {
        LOG.warn("Creating otel-trace-source without authentication. This is not secure.");
        LOG.warn("In order to set up Http Basic authentication for the otel-trace-source, go here: https://github.com/opensearch-project/data-prepper/tree/main/data-prepper-plugins/otel-trace-source#authentication-configurations");
    }
    final PluginSetting authenticationPluginSetting;
    if (authenticationConfiguration != null) {
        authenticationPluginSetting = new PluginSetting(authenticationConfiguration.getPluginName(), authenticationConfiguration.getPluginSettings());
    } else {
        authenticationPluginSetting = new PluginSetting(GrpcAuthenticationProvider.UNAUTHENTICATED_PLUGIN_NAME, Collections.emptyMap());
    }
    return pluginFactory.loadPlugin(GrpcAuthenticationProvider.class, authenticationPluginSetting);
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting)

Example 18 with PluginModel

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

the class DataPrepperServerConfigurationTest method testGivingSecureConfigThenCreateInsecureSettings.

@Test
public void testGivingSecureConfigThenCreateInsecureSettings() {
    final PluginModel pluginModel = mock(PluginModel.class);
    final Map<String, Object> settings = new HashMap<>();
    when(pluginModel.getPluginName()).thenReturn("super secure plugin");
    when(pluginModel.getPluginSettings()).thenReturn(settings);
    final PluginSetting pluginSetting = serverConfiguration.pluginSetting(pluginModel);
    assertThat(pluginSetting.getName(), is("super secure plugin"));
    assertThat(pluginSetting.getSettings(), is(settings));
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) HashMap(java.util.HashMap) PluginSetting(com.amazon.dataprepper.model.configuration.PluginSetting) Test(org.junit.jupiter.api.Test)

Example 19 with PluginModel

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

the class DataPrepperAppConfigurationTest method testPluginModelFromDataPrepperConfigurationAuthentication.

@Test
public void testPluginModelFromDataPrepperConfigurationAuthentication() {
    final DataPrepperConfiguration configuration = mock(DataPrepperConfiguration.class);
    final PluginModel pluginModel = appConfiguration.authentication(configuration);
    assertThat(pluginModel, is(nullValue()));
    verify(configuration).getAuthentication();
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) Test(org.junit.jupiter.api.Test)

Example 20 with PluginModel

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

the class DataPrepperAppConfigurationTest method testGivenReturnAuthenticationThenBeanShouldEqualAuthentication.

@Test
public void testGivenReturnAuthenticationThenBeanShouldEqualAuthentication() {
    final DataPrepperConfiguration configuration = mock(DataPrepperConfiguration.class);
    final PluginModel expected = mock(PluginModel.class);
    when(configuration.getAuthentication()).thenReturn(expected);
    final PluginModel pluginModel = appConfiguration.authentication(configuration);
    assertThat(pluginModel, is(expected));
    verify(configuration).getAuthentication();
}
Also used : PluginModel(com.amazon.dataprepper.model.configuration.PluginModel) DataPrepperConfiguration(com.amazon.dataprepper.parser.model.DataPrepperConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

PluginModel (com.amazon.dataprepper.model.configuration.PluginModel)31 Test (org.junit.jupiter.api.Test)21 LogstashAttribute (org.opensearch.dataprepper.logstash.model.LogstashAttribute)17 List (java.util.List)8 ArrayList (java.util.ArrayList)6 PluginSetting (com.amazon.dataprepper.model.configuration.PluginSetting)5 DateProcessorConfig (com.amazon.dataprepper.plugins.processor.date.DateProcessorConfig)5 HashMap (java.util.HashMap)5 LogstashAttributeValue (org.opensearch.dataprepper.logstash.model.LogstashAttributeValue)5 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 LogstashPlugin (org.opensearch.dataprepper.logstash.model.LogstashPlugin)3 DataPrepperConfiguration (com.amazon.dataprepper.parser.model.DataPrepperConfiguration)2 Objects (java.util.Objects)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 LogstashMappingException (org.opensearch.dataprepper.logstash.exception.LogstashMappingException)2 PipelineModel (com.amazon.dataprepper.model.configuration.PipelineModel)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Collection (java.util.Collection)1