Search in sources :

Example 1 with JdbcAccessSecurityConfig

use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.

the class PostgresqlFirehoseDatabaseConnectorTest method testSuccessWhenAllowlistAndNoProperty.

@Test
public void testSuccessWhenAllowlistAndNoProperty() {
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return "jdbc:postgresql://localhost:3306/test";
        }
    };
    JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of("user"));
    new PostgresqlFirehoseDatabaseConnector(connectorConfig, securityConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 2 with JdbcAccessSecurityConfig

use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.

the class PostgresqlFirehoseDatabaseConnectorTest method testFailValidAndInvalidProperty.

@Test
public void testFailValidAndInvalidProperty() {
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return "jdbc:postgresql://localhost:3306/test?user=maytas&password=secret&keyonly";
        }
    };
    JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of("user", "nonenone"));
    expectedException.expectMessage("is not in the allowed list");
    expectedException.expect(IllegalArgumentException.class);
    new PostgresqlFirehoseDatabaseConnector(connectorConfig, securityConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 3 with JdbcAccessSecurityConfig

use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.

the class PostgresqlFirehoseDatabaseConnectorTest method testSuccessWhenNoPropertyInUriAndNoAllowlist.

@Test
public void testSuccessWhenNoPropertyInUriAndNoAllowlist() {
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return "jdbc:postgresql://localhost:3306/test";
        }
    };
    JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of());
    new PostgresqlFirehoseDatabaseConnector(connectorConfig, securityConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 4 with JdbcAccessSecurityConfig

use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.

the class JdbcExtractionNamespaceTest method ensureEntry.

private CacheScheduler.Entry ensureEntry() throws InterruptedException {
    final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace(derbyConnectorRule.getMetadataConnectorConfig(), TABLE_NAME, KEY_NAME, VAL_NAME, tsColumn, null, new Period(10), null, new JdbcAccessSecurityConfig());
    CacheScheduler.Entry entry = scheduler.schedule(extractionNamespace);
    waitForUpdates(1_000L, 2L);
    Assert.assertEquals("sanity check not correct", "bar", entry.getCache().get("foo"));
    return entry;
}
Also used : JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Period(org.joda.time.Period) JdbcExtractionNamespace(org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace)

Example 5 with JdbcAccessSecurityConfig

use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.

the class JdbcExtractionNamespaceTest method testSerde.

@Test
public void testSerde() throws IOException {
    final JdbcAccessSecurityConfig securityConfig = new JdbcAccessSecurityConfig();
    final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace(derbyConnectorRule.getMetadataConnectorConfig(), TABLE_NAME, KEY_NAME, VAL_NAME, tsColumn, "some filter", new Period(10), null, securityConfig);
    final ObjectMapper mapper = new DefaultObjectMapper();
    mapper.setInjectableValues(new Std().addValue(JdbcAccessSecurityConfig.class, securityConfig));
    final ExtractionNamespace extractionNamespace2 = mapper.readValue(mapper.writeValueAsBytes(extractionNamespace), ExtractionNamespace.class);
    Assert.assertEquals(extractionNamespace, extractionNamespace2);
}
Also used : Std(com.fasterxml.jackson.databind.InjectableValues.Std) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Period(org.joda.time.Period) ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) JdbcExtractionNamespace(org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) JdbcExtractionNamespace(org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Aggregations

JdbcAccessSecurityConfig (org.apache.druid.server.initialization.JdbcAccessSecurityConfig)21 Test (org.junit.Test)20 MetadataStorageConnectorConfig (org.apache.druid.metadata.MetadataStorageConnectorConfig)17 JdbcExtractionNamespace (org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace)4 Period (org.joda.time.Period)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 Std (com.fasterxml.jackson.databind.InjectableValues.Std)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)1 ExtractionNamespace (org.apache.druid.query.lookup.namespace.ExtractionNamespace)1