/** * @param config the configuration; may not be null */ public Filters(PostgresConnectorConfig config) { // we always want to exclude PG system schemas as they are never part of logical decoding events String schemaBlacklist = config.schemaBlacklist(); if (schemaBlacklist != null) { schemaBlacklist = schemaBlacklist + "," + SYSTEM_SCHEMA_BLACKLIST; } else { schemaBlacklist = SYSTEM_SCHEMA_BLACKLIST; } String tableBlacklist = config.tableBlacklist(); if (tableBlacklist != null) { tableBlacklist = tableBlacklist + "," + TEMP_TABLE_BLACKLIST; } else { tableBlacklist = TEMP_TABLE_BLACKLIST; } // Define the filter using the whitelists and blacklists for table names ... this.tableFilter = TableFilter.fromPredicate(Selectors.tableSelector() .includeTables(config.tableWhitelist()) .excludeTables(tableBlacklist) .includeSchemas(config.schemaWhitelist()) .excludeSchemas(schemaBlacklist) .build()); // Define the filter that excludes blacklisted columns, truncated columns, and masked columns ... this.columnFilter = Selectors.excludeColumns(config.columnBlacklist()); }
/** * @param config the configuration; may not be null */ public Filters(PostgresConnectorConfig config) { // we always want to exclude PG system schemas as they are never part of logical decoding events String schemaBlacklist = config.schemaBlacklist(); if (schemaBlacklist != null) { schemaBlacklist = schemaBlacklist + "," + SYSTEM_SCHEMA_BLACKLIST; } else { schemaBlacklist = SYSTEM_SCHEMA_BLACKLIST; } String tableBlacklist = config.tableBlacklist(); if (tableBlacklist != null) { tableBlacklist = tableBlacklist + "," + TEMP_TABLE_BLACKLIST; } else { tableBlacklist = TEMP_TABLE_BLACKLIST; } // Define the filter using the whitelists and blacklists for table names ... this.tableFilter = TableFilter.fromPredicate(Selectors.tableSelector() .includeTables(config.tableWhitelist()) .excludeTables(tableBlacklist) .includeSchemas(config.schemaWhitelist()) .excludeSchemas(schemaBlacklist) .build()); // Define the filter that excludes blacklisted columns, truncated columns, and masked columns ... this.columnFilter = Selectors.excludeColumns(config.columnBlacklist()); }
@Test public void shouldCreateFilterWithSchemaWhitelistAndTableWhitelist() { filter = Selectors.tableSelector() .includeSchemas("sc1,sc2") .includeTables("db\\.sc1\\.A,db\\.sc2\\.B") .build(); assertAllowed(filter, "db", "sc1", "A"); assertNotAllowed(filter, "db", "sc1", "B"); assertAllowed(filter, "db", "sc2", "B"); assertNotAllowed(filter, "db", "sc2", "A"); assertNotAllowed(filter, "db", "sc1", "C"); assertNotAllowed(filter, "db2", "sc2", "D"); assertNotAllowed(filter, "db", "sc3", "A"); assertNotAllowed(filter, "db2", "sc4", "B"); }
@Test public void shouldCreateFilterWithSchemaWhitelistAndNoTableFilter() { filter = Selectors.tableSelector() .includeSchemas("sc1,sc2") .build(); assertAllowed(filter, "db1", "sc1", "A"); assertAllowed(filter, "db2", "sc2", "A"); assertNotAllowed(filter, "db1", "sc3", "A"); assertNotAllowed(filter, "db2", "sc4", "A"); }