add wall test

This commit is contained in:
温少
2012-03-15 23:34:22 +08:00
2 changed files with 59 additions and 0 deletions
@@ -0,0 +1,36 @@
package com.alibaba.druid.bvt.filter.wall;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallUtils;
import junit.framework.TestCase;
/**
* 这个场景测试访问Oracle系统表
*
* @author admin
*/
public class OracleWallPermitTableTest extends TestCase {
public void test_permitTable() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle("select * from TAB"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from tab"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from SYS.TAB"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from SYS.\"TAB\""));
}
public void test_permitTable_subquery() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from TAB) a"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from tab) a"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from SYS.TAB) a"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from(select * from SYS.\"TAB\") a"));
}
public void test_permitTable_join() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, TAB"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, tab"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, SYS.TAB"));
Assert.assertFalse(WallUtils.isValidateOracle("select * from t1, SYS.\"TAB\""));
}
}
@@ -0,0 +1,23 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景,被攻击者用于测试当前SQL拥有多少字段
* @author wenshao
*
*/
public class WallUnionTest extends TestCase {
public void testMySql() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from t union select 1, 2"));
}
public void testOracle() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle("select f1, f2 from t union select 1, 2"));
}
}