use of org.apache.druid.metadata.MetadataStorageConnectorConfig 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);
}
use of org.apache.druid.metadata.MetadataStorageConnectorConfig 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.metadata.MetadataStorageConnectorConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerModules(new MySQLMetadataStorageModule().getJacksonModules());
mapper.setInjectableValues(new InjectableValues.Std().addValue(JdbcAccessSecurityConfig.class, INJECTED_CONF).addValue(MySQLConnectorDriverConfig.class, mySQLConnectorDriverConfig));
MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return "jdbc:mysql://localhost:3306/test";
}
};
MySQLFirehoseDatabaseConnector connector = new MySQLFirehoseDatabaseConnector(connectorConfig, null, INJECTED_CONF, mySQLConnectorDriverConfig);
MySQLFirehoseDatabaseConnector andBack = mapper.readValue(mapper.writeValueAsString(connector), MySQLFirehoseDatabaseConnector.class);
Assert.assertEquals(connector, andBack);
// test again with classname
connector = new MySQLFirehoseDatabaseConnector(connectorConfig, "some.class.name.Driver", INJECTED_CONF, mySQLConnectorDriverConfig);
andBack = mapper.readValue(mapper.writeValueAsString(connector), MySQLFirehoseDatabaseConnector.class);
Assert.assertEquals(connector, andBack);
}
use of org.apache.druid.metadata.MetadataStorageConnectorConfig 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.metadata.MetadataStorageConnectorConfig 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);
}
Aggregations