use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testSuccessOnlyValidPropertyMariaDb.
@Test
public void testSuccessOnlyValidPropertyMariaDb() {
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", "password", "keyonly", "etc"));
new MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testSuccessWhenAllowlistAndNoProperty.
@Test
public void testSuccessWhenAllowlistAndNoProperty() {
MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return "jdbc:mysql://localhost:3306/test";
}
};
JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of("user"));
new MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testFailValidAndInvalidProperty.
@Test
public void testFailValidAndInvalidProperty() {
MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return "jdbc:mysql://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);
}
use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testFailOnlyInvalidProperty.
@Test
public void testFailOnlyInvalidProperty() {
MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return "jdbc:mysql://localhost:3306/test?user=maytas&password=secret&keyonly";
}
};
JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of("none", "nonenone"));
expectedException.expectMessage("The property [password] is not in the allowed list");
expectedException.expect(IllegalArgumentException.class);
new MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
use of org.apache.druid.server.initialization.JdbcAccessSecurityConfig in project druid by druid-io.
the class JdbcExtractionNamespaceTest method testMappingWithFilter.
@Test(timeout = 60_000L)
public void testMappingWithFilter() throws InterruptedException {
final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace(derbyConnectorRule.getMetadataConnectorConfig(), TABLE_NAME, KEY_NAME, VAL_NAME, tsColumn, FILTER_COLUMN + "='1'", 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];
String filterVal = val[1];
if ("1".equals(filterVal)) {
Assert.assertEquals("non-null check", NullHandling.emptyToNullIfNeeded(field), NullHandling.emptyToNullIfNeeded(map.get(key)));
} else {
Assert.assertEquals("non-null check", null, NullHandling.emptyToNullIfNeeded(map.get(key)));
}
}
}
}
Aggregations