Search in sources :

Example 16 with JdbcAccessSecurityConfig

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

the class MySQLFirehoseDatabaseConnectorTest method testSuccessWhenNoPropertyInUriAndNoAllowlist.

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

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

Example 17 with JdbcAccessSecurityConfig

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

the class MySQLFirehoseDatabaseConnectorTest method testFailValidAndInvalidPropertyMariadb.

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

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

Example 18 with JdbcAccessSecurityConfig

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

the class MySQLFirehoseDatabaseConnectorTest method testIgnoreInvalidPropertyWhenNotEnforcingAllowList.

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

        @Override
        public String getConnectURI() {
            return "jdbc:mysql://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 MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
Also used : MetadataStorageConnectorConfig(org.apache.druid.metadata.MetadataStorageConnectorConfig) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Test(org.junit.Test)

Example 19 with JdbcAccessSecurityConfig

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

the class MySQLFirehoseDatabaseConnectorTest method testFailWhenNoAllowlistAndHaveProperty.

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

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

Example 20 with JdbcAccessSecurityConfig

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

the class MySQLFirehoseDatabaseConnectorTest method testFindPropertyKeysFromInvalidConnectUrl.

@Test
public void testFindPropertyKeysFromInvalidConnectUrl() {
    final String url = "jdbc:mysql:/invalid-url::3006";
    MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return url;
        }
    };
    expectedException.expect(RuntimeException.class);
    expectedException.expectMessage(StringUtils.format("Invalid URL format for MySQL: [%s]", url));
    new MySQLFirehoseDatabaseConnector(connectorConfig, null, new JdbcAccessSecurityConfig(), mySQLConnectorDriverConfig);
}
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