Package com.alibaba.druid.wall.spi

Examples of com.alibaba.druid.wall.spi.MySqlWallProvider


        Assert.assertEquals(0, provider.getTableStats().size());
    }

    public void test_true() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        Assert.assertTrue(provider.checkValid(//
        "use huaianapp")); //

        Assert.assertEquals(0, provider.getTableStats().size());
    }
View Full Code Here


    protected void tearDown() throws Exception {
        WallContext.clearContext();
    }

    public void testMySql() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        for (int i = 0; i < 1001; ++i) {
            String sql = "select * from t where id = " + i + " OR 1 = 1";
            Assert.assertFalse(provider.checkValid(sql));
        }

        WallTableStat tableStat = provider.getTableStat("t");
        Assert.assertEquals(1001, tableStat.getSelectCount());
        Assert.assertEquals(0, provider.getBlackListHitCount());
        Assert.assertEquals(0, provider.getWhiteListHitCount());
        Assert.assertEquals(0, provider.getWhiteList().size());
        Assert.assertEquals(200, provider.getBlackList().size());
        Assert.assertEquals(1001, provider.getCheckCount());
    }
View Full Code Here

* @see
*/
public class MySqlWallTest53 extends TestCase {

    public void test_true() throws Exception {
        WallProvider provider = new MySqlWallProvider();
        provider.getConfig().setLimitZeroAllow(true);

        Assert.assertTrue(provider.checkValid(//
        "select * from t limit 0,0"));

        Assert.assertEquals(1, provider.getTableStats().size());
    }
View Full Code Here

        Assert.assertEquals(1, provider.getTableStats().size());
    }
   
    public void test_false() throws Exception {
        WallProvider provider = new MySqlWallProvider();
       
        Assert.assertFalse(provider.checkValid(//
                "select * from t limit 0,0"));
       
        Assert.assertEquals(1, provider.getTableStats().size());
    }
View Full Code Here

* @see
*/
public class MySqlWallTest54 extends TestCase {

    public void test_true() throws Exception {
        WallProvider provider = new MySqlWallProvider();
        provider.getConfig().setSchemaCheck(false);

        Assert.assertTrue(provider.checkValid(//
        "SELECT *FROM T UNION select `ENGINE`, `SUPPORT` from information_schema.Engines"));

        Assert.assertEquals(2, provider.getTableStats().size());
    }
View Full Code Here

        Assert.assertEquals(2, provider.getTableStats().size());
    }
   
    public void test_false() throws Exception {
        WallProvider provider = new MySqlWallProvider();
       
        Assert.assertFalse(provider.checkValid(//
                "SELECT *FROM T UNION select `ENGINE`, `SUPPORT` from information_schema.Engines"));
       
        Assert.assertEquals(2, provider.getTableStats().size());
    }
View Full Code Here

    protected void tearDown() throws Exception {
        WallContext.clearContext();
    }

    public void testMySql() throws Exception {
        WallProvider provider = new MySqlWallProvider();
        Assert.assertTrue(provider.checkValid(sql));

        {
            WallTableStat tableStat = provider.getTableStat("t");
            Assert.assertEquals(1, tableStat.getSelectCount());
            Assert.assertEquals(0, tableStat.getSelectIntoCount());
        }
        {
            WallTableStat tableStat = provider.getTableStat("x");
            Assert.assertEquals(0, tableStat.getSelectCount());
            Assert.assertEquals(1, tableStat.getSelectIntoCount());
        }
    }
View Full Code Here

import com.alibaba.druid.wall.spi.MySqlWallProvider;

public class MySqlWallTest138 extends TestCase {

    public void test_false() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        String sql = "INSERT INTO T01_CHECKIN_CUSTOMER" //
                     + "(WEB_USER_ID,NAME,COUNTRY,PROVINCE,CITY" //
                     + ",POSTCODE,PHONE,FAX,EMAIL,ADDRESS,FIRST_NAME,LAST_NAME,sex) " //
                     + "select 2,null,'4225',null,'beijing','','1','','1223@123.com','beijing','booking','test',null "//
                     + "from dual " //
                     + "where not exists   ("//
                     + "    select EMAIL" //
                     + "    from T01_CHECKIN_CUSTOMER" //
                     + "    where WEB_USER_ID=2 and EMAIL='1223@123.com'" //
                     + ")";
        Assert.assertTrue(provider.checkValid(sql));
    }
View Full Code Here

* @see
*/
public class MySqlWallTest_comment extends TestCase {

    public void test_true() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        provider.getConfig().setCommentAllow(true);

        Assert.assertTrue(provider.checkValid(//
        "SELECT * FROM T WHERE FID = ? #AND 1"));

        Assert.assertEquals(1, provider.getTableStats().size());
    }
View Full Code Here

        Assert.assertEquals(1, provider.getTableStats().size());
    }

    public void test_false() throws Exception {
        WallProvider provider = new MySqlWallProvider();

        provider.getConfig().setCommentAllow(false);

        Assert.assertTrue(provider.checkValid("/* this is comment */ SELECT id FROM t "));
        Assert.assertTrue(provider.checkValid("-- this is comment \n SELECT * FROM t"));
        Assert.assertTrue(provider.checkValid("#this is comment \n SELECT * FROM t"));
       
        Assert.assertFalse(provider.checkValid("/*!40101fff*/ select * from t"));

        Assert.assertTrue(provider.checkValid("SELECT * FROM t where a=1 #this is comment \n and b=1"));
        Assert.assertTrue(provider.checkValid("SELECT * FROM t where a=1 -- this is comment \n and c=1"));
        Assert.assertTrue(provider.checkValid("SELECT * FROM t where a=1 /* this is comment */ and d=1"));

        Assert.assertFalse(provider.checkValid("SELECT * FROM t where a=1 #and c=1 \n and e=1"));
        Assert.assertFalse(provider.checkValid("SELECT * FROM t where a=1 -- AND c=1 \n and f=1"));
        Assert.assertFalse(provider.checkValid("SELECT * FROM t where a=1 /* and c=1 */ and g=1"));

        Assert.assertFalse(provider.checkValid("SELECT * FROM t where a=1 #and c=1 "));
        Assert.assertFalse(provider.checkValid("SELECT * FROM t where a=1 -- and c=1"));
        Assert.assertFalse(provider.checkValid("SELECT * FROM t where a=1 /* and c=1 */"));
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.wall.spi.MySqlWallProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.