This commit is contained in:
温少
2012-03-17 16:49:58 +08:00
13 changed files with 169 additions and 18 deletions
@@ -0,0 +1,26 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallConfig;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景测试访问Oracle系统对象
*
* @author admin
*/
public class OracleWallPermitVariantTest extends TestCase {
public void test_permitTable() throws Exception {
WallConfig config = new WallConfig();
config.setVariantCheck(false);
Assert.assertTrue(WallUtils.isValidateOracle("select UID from dual"));
Assert.assertTrue(WallUtils.isValidateOracle("select USER from dual"));
Assert.assertTrue(WallUtils.isValidateOracle("select user from dual"));
}
}
@@ -0,0 +1,21 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景测试访问Oracle系统对象
*
* @author admin
*/
public class OracleWallPermitVariantTest2 extends TestCase {
public void test_permitTable() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle("select UID from dual"));
Assert.assertFalse(WallUtils.isValidateOracle("select USER from dual"));
}
}
@@ -0,0 +1,32 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallConfig;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景,检测
* @author wenshao
*
*/
public class WallTruncateTest extends TestCase {
private String sql = "TRUNCATE TABLE T1";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
//config.setTruncateAllow(true);
}
public void testMySql() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
}
}
@@ -0,0 +1,32 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallConfig;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景,检测
* @author wenshao
*
*/
public class WallTruncateTest1 extends TestCase {
private String sql = "TRUNCATE TABLE T1";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setTruncateAllow(true);
}
public void testMySql() throws Exception {
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertTrue(WallUtils.isValidateOracle(sql, config));
}
}
@@ -34,7 +34,7 @@ public class OnlineOracleTest3 extends TestCase {
}
public void test_connect() throws Exception {
executeQuery("select * from all_users");
executeQuery("select UID, USER FROM DUAL");
}
public void executeQuery(String sql) throws SQLException {