This commit is contained in:
温少
2012-03-17 11:48:14 +08:00
parent cd632cd8f1
commit 6de22b54df
17 changed files with 339 additions and 58 deletions
@@ -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 WallDeleteTest extends TestCase {
private String sql = "DELETE FROM T WHERE F1 = ?";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setDeleteAllow(false);
}
public void testMySql() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
}
}
@@ -7,7 +7,7 @@ import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景,检测可疑的Having条件
*
* @author wenshao
*
*/
@@ -0,0 +1,24 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景,检测可疑的Having条件
* @author wenshao
*
*/
public class WallDeleteWhereTest1 extends TestCase {
private String sql = "DELETE FROM T";
public void testMySql() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql(sql));
}
public void testORACLE() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle(sql));
}
}
@@ -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 WallInsertTest extends TestCase {
private String sql = "INSERT INTO T (F1, F2) VALUES (1, 2)";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setInsertAllow(false);
}
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 WallInsertTest2 extends TestCase {
private String sql = "INSERT INTO T (F1, F2) VALUES (1, 2)";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setInsertAllow(true);
}
public void testMySql() throws Exception {
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertTrue(WallUtils.isValidateOracle(sql, config));
}
}
@@ -7,7 +7,7 @@ import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallUtils;
/**
* 这个场景,检测可疑的Having条件
* 这个场景,检测可疑的Where条件
* @author wenshao
*
*/
@@ -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 WallUpdateTest extends TestCase {
private String sql = "UPDATE T_USER SET FNAME = ? WHERE FID = ?";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setDeleteAllow(false);
}
public void testMySql() throws Exception {
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertTrue(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 WallUpdateTest1 extends TestCase {
private String sql = "UPDATE T_USER SET FNAME = ? WHERE FID = ?";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setUpdateAllow(false);
}
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 WallUpdateTest2 extends TestCase {
private String sql = "UPDATE T_USER SET FNAME = ?";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setUpdateAllow(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 WallUpdateTest3 extends TestCase {
private String sql = "UPDATE T_USER SET FNAME = ? WHERE 1 = 1";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setUpdateAllow(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 WallUpdateTest4 extends TestCase {
private String sql = "UPDATE T_USER SET FNAME = ? WHERE FID = ? OR 1 = 1";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setUpdateAllow(true);
}
public void testMySql() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertFalse(WallUtils.isValidateOracle(sql, config));
}
}