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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations