use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.
the class WallStatTest_select_1 method testPG.
public void testPG() throws Exception {
WallProvider provider = new PGWallProvider();
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.WallProvider in project druid by alibaba.
the class WallStatTest_select_1 method testSQLServer.
public void testSQLServer() throws Exception {
WallProvider provider = new SQLServerWallProvider();
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.WallProvider 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.WallProvider in project druid by alibaba.
the class WallStatTest_WhiteList_disable method testMySql.
public void testMySql() throws Exception {
WallProvider provider = new MySqlWallProvider();
provider.setBlackListEnable(false);
provider.setWhiteListEnable(false);
for (int i = 0; i < 301; ++i) {
String sql = "select * from t where id = " + i;
Assert.assertTrue(provider.checkValid(sql));
}
for (int i = 0; i < 301; ++i) {
String sql = "select * from t where id = " + i + " OR 1 = 1";
Assert.assertFalse(provider.checkValid(sql));
}
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(602, tableStat.getSelectCount());
Assert.assertEquals(0, provider.getBlackListHitCount());
Assert.assertEquals(0, provider.getWhiteListHitCount());
Assert.assertEquals(0, provider.getWhiteList().size());
Assert.assertEquals(602, provider.getCheckCount());
}
use of com.alibaba.druid.wall.WallProvider in project druid by alibaba.
the class WallStatTest_alter_table method testMySql.
public void testMySql() throws Exception {
String sql = "alter table t add column fname varchar(50)";
WallProvider provider = new MySqlWallProvider();
provider.getConfig().setAlterTableAllow(true);
Assert.assertTrue(provider.checkValid(sql));
WallTableStat tableStat = provider.getTableStat("t");
Assert.assertEquals(1, tableStat.getAlterCount());
}
Aggregations