Search in sources :

Example 11 with JdbcAccessSecurityConfig

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

the class JdbcExtractionNamespaceTest method testMappingWithoutFilter.

@Test(timeout = 60_000L)
public void testMappingWithoutFilter() throws InterruptedException {
    final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace(derbyConnectorRule.getMetadataConnectorConfig(), TABLE_NAME, KEY_NAME, VAL_NAME, tsColumn, null, new Period(0), null, new JdbcAccessSecurityConfig());
    try (CacheScheduler.Entry entry = scheduler.schedule(extractionNamespace)) {
        CacheSchedulerTest.waitFor(entry);
        final Map<String, String> map = entry.getCache();
        for (Map.Entry<String, String[]> e : RENAMES.entrySet()) {
            String key = e.getKey();
            String[] val = e.getValue();
            String field = val[0];
            Assert.assertEquals("non-null check", NullHandling.emptyToNullIfNeeded(field), NullHandling.emptyToNullIfNeeded(map.get(key)));
        }
        Assert.assertEquals("null check", null, map.get("baz"));
    }
}
Also used : JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Period(org.joda.time.Period) JdbcExtractionNamespace(org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 12 with JdbcAccessSecurityConfig

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

the class PostgresqlFirehoseDatabaseConnectorTest method testFailWhenNoAllowlistAndHaveProperty.

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

        @Override
        public String getConnectURI() {
            return "jdbc:postgresql://localhost:3306/test?user=maytas&password=secret&keyonly";
        }
    };
    JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of(""));
    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 13 with JdbcAccessSecurityConfig

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

the class PostgresqlFirehoseDatabaseConnectorTest method testSuccessOnlyValidProperty.

@Test
public void testSuccessOnlyValidProperty() {
    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", "password", "keyonly", "etc"));
    new PostgresqlFirehoseDatabaseConnector(connectorConfig, securityConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 14 with JdbcAccessSecurityConfig

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

the class PostgresqlFirehoseDatabaseConnectorTest method testFailOnlyInvalidProperty.

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

        @Override
        public String getConnectURI() {
            return "jdbc:postgresql://localhost:3306/test?user=maytas&password=secret&keyonly";
        }
    };
    JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of("none", "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 15 with JdbcAccessSecurityConfig

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

the class PostgresqlFirehoseDatabaseConnectorTest method testIgnoreInvalidPropertyWhenNotEnforcingAllowList.

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

        @Override
        public String getConnectURI() {
            return "jdbc:postgresql://localhost:3306/test?user=maytas&password=secret&keyonly";
        }
    };
    JdbcAccessSecurityConfig securityConfig = new JdbcAccessSecurityConfig() {

        @Override
        public Set<String> getAllowedProperties() {
            return ImmutableSet.of("user", "nonenone");
        }

        @Override
        public boolean isEnforceAllowedProperties() {
            return false;
        }
    };
    new PostgresqlFirehoseDatabaseConnector(connectorConfig, securityConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) 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