use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.
the class WallStatTest_blackList_syntaxError method testMySql.
public void testMySql() throws Exception {
WallProvider provider = new MySqlWallProvider();
String sql = "select xx * x *";
Assert.assertFalse(provider.checkValid(sql));
{
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(0, tableStat.getSelectCount());
Assert.assertEquals(0, provider.getBlackListHitCount());
Assert.assertEquals(0, provider.getWhiteListHitCount());
Assert.assertEquals(0, provider.getWhiteList().size());
Assert.assertEquals(1, provider.getBlackList().size());
Assert.assertEquals(1, provider.getCheckCount());
Assert.assertEquals(1, provider.getSyntaxErrorCount());
Assert.assertEquals(1, provider.getHardCheckCount());
}
Assert.assertFalse(provider.checkValid(sql));
{
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(0, tableStat.getSelectCount());
Assert.assertEquals(1, provider.getBlackListHitCount());
Assert.assertEquals(0, provider.getWhiteListHitCount());
Assert.assertEquals(0, provider.getWhiteList().size());
Assert.assertEquals(1, provider.getBlackList().size());
Assert.assertEquals(2, provider.getCheckCount());
Assert.assertEquals(2, provider.getSyntaxErrorCount());
Assert.assertEquals(1, provider.getHardCheckCount());
}
}
use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.
the class WallStatTest_blacklist method testMySql.
public void testMySql() throws Exception {
WallProvider provider = new MySqlWallProvider();
for (int i = 0; i < 10; ++i) {
Assert.assertFalse(provider.checkValid(sql));
}
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(10, tableStat.getSelectCount());
Assert.assertEquals(0, provider.getWhiteListHitCount());
Assert.assertEquals(9, provider.getBlackListHitCount());
}
use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.
the class WallStatTest_create_table method testPG.
public void testPG() throws Exception {
WallProvider provider = new PGWallProvider();
provider.getConfig().setCreateTableAllow(true);
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getCreateCount());
}
use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.
the class WallStatTest_create_table method testSQLServer.
public void testSQLServer() throws Exception {
WallProvider provider = new SQLServerWallProvider();
provider.getConfig().setCreateTableAllow(true);
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getCreateCount());
}
use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.
the class WallStatTest_delete method testPG.
public void testPG() throws Exception {
WallProvider provider = new PGWallProvider();
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getDeleteCount());
}
Aggregations