use of com.alibaba.druid.wall.spi.MySqlWallProvider 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.spi.MySqlWallProvider in project druid by alibaba.
the class WallStatTest_drop_table method testMySql.
public void testMySql() throws Exception {
WallProvider provider = new MySqlWallProvider();
provider.getConfig().setDropTableAllow(true);
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getDropCount());
}
use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class WallStatTest_insert method testMySql.
public void testMySql() throws Exception {
WallProvider provider = new MySqlWallProvider();
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getInsertCount());
}
use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class WallStatTest_select_1 method testMySql.
public void testMySql() throws Exception {
WallProvider provider = new MySqlWallProvider();
Assert.assertTrue(provider.checkValid(sql));
{
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts_reply");
Assert.assertEquals(1, tableStat.getSelectCount());
}
{
WallTableStat tableStat = provider.getTableStat("lhwbbs_posts");
Assert.assertEquals(1, tableStat.getSelectCount());
}
}
use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class WallStatTest_update method testMySql.
public void testMySql() throws Exception {
WallProvider provider = new MySqlWallProvider();
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getUpdateCount());
}
Aggregations