Package com.alibaba.druid.wall

Examples of com.alibaba.druid.wall.WallConfig$TenantCallBack


import com.alibaba.druid.wall.WallUtils;

public class MySqlWallTest_hint extends TestCase {

    public void test_false() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(false);
        String sql = "select * from person where id = '3'/**/union select 0,1,v from (select 1,2,user/*!() as v*/) a where '1'<>''";
        Assert.assertFalse(WallUtils.isValidateMySql(sql, config)); //
    }
View Full Code Here


        String sql = "select * from person where id = '3'/**/union select 0,1,v from (select 1,2,user/*!() as v*/) a where '1'<>''";
        Assert.assertFalse(WallUtils.isValidateMySql(sql, config)); //
    }

    public void test_false_1() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(true);
        config.setMultiStatementAllow(true);
        String sql = "select * from person where id = '3'/**/union select 0,1,v from (select 1,2,user/*!() as v*/) a where '1'<>''";
        Assert.assertFalse(WallUtils.isValidateMySql(sql, config)); //
    }
View Full Code Here

        String sql = "/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */";
        Assert.assertTrue(WallUtils.isValidateMySql(sql)); //
    }
   
    public void test_true_3() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(true);
        config.setMultiStatementAllow(true);
        String sql = " /*!50003 CREATE*/ /*!50020  /*!50003 PROCEDURE `top_calculate_customer_update`(in update_time DATETIME)"
                     + " DETERMINISTIC"
                     + " BEGIN"
                     + " DECLARE done INT DEFAULT FALSE;"
                     + " DECLARE c_receiver_city,c_receiver_district,c_receiver_address VARCHAR(200);"
View Full Code Here

                     + " END */";
        Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
    }
   
    public void test_true_4() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(true);
        config.setMultiStatementAllow(true);
        String sql = "LOCK TABLES `m_rpt_adgroupeffect` READ /*!32311 LOCAL */";
        Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
    }
View Full Code Here

        String sql = "LOCK TABLES `m_rpt_adgroupeffect` READ /*!32311 LOCAL */";
        Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
    }
   
    public void test_true_5() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(true);
        config.setMultiStatementAllow(true);
        String sql = "DROP TABLE IF EXISTS `item_similarity`;"//
                     + "\n/*!40101 SET @saved_cs_client     = @@character_set_client */;"//
                     + "\n/*!40101 SET character_set_client = utf8 */;" //
                     + "\nCREATE TABLE `item_similarity` ("//
                     + " `id` bigint(20) unsigned NOT NULL, "//
View Full Code Here

        String sql = "SET SQL_QUOTE_SHOW_CREATE=1/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */";
        Assert.assertTrue(WallUtils.isValidateMySql(sql)); //
    }
   
    public void test_true_9() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(true);
        config.setMultiStatementAllow(true);
        String sql = "CREATE TABLE `session` ("//
                     + " `sess_id` varchar(128) NOT NULL,"//
                     + " `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',"//
                     + " `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',"//
                     + " `ip` varchar(40) NOT NULL,"//
View Full Code Here

                     + ") /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */ ";
        Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
    }
   
    public void test_true_10() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(true);
        config.setMultiStatementAllow(true);
        config.setNoneBaseStatementAllow(true);
        String sql = "CREATE DATABASE `newsfocus` /*!40100 COLLATE 'big5_chinese_ci' */ ";
        Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
    }
View Full Code Here

        String sql = "CREATE DATABASE `newsfocus` /*!40100 COLLATE 'big5_chinese_ci' */ ";
        Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
    }

    public void test_true_11() throws Exception {
        WallConfig config = new WallConfig();
        config.setHintAllow(true);
        config.setMultiStatementAllow(true);
        config.setNoneBaseStatementAllow(true);
        String sql = "EXPLAIN /*!40100 EXTENDED */ SELECT * FROM trade_order_header WHERE id = ?";
        Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
    }
View Full Code Here

* @author wenshao
*/
public class WallUnionTest2 extends TestCase {

    public void testMySql() throws Exception {
        WallConfig config = new WallConfig();
        config.setSelectUnionCheck(true);
        Assert.assertTrue(WallUtils.isValidateMySql("select f1, f2 from t where f1 = 1 union select 1, 2 where 1 = 1",
                                                    config));
        Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from t where f1 = 1 union select 1, 2 where 1 = 1 --",
                                                     config));
    }
View Full Code Here

        Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from t where f1 = 1 union select 1, 2 where 1 = 1 --",
                                                     config));
    }

    public void testOracle() throws Exception {
        WallConfig config = new WallConfig();
        config.setSelectUnionCheck(true);
        Assert.assertTrue(WallUtils.isValidateOracle("select f1, f2 from t where f1 = 1 union select 1, 2 where 1 = 1",
                                                     config));
        Assert.assertFalse(WallUtils.isValidateOracle("select f1, f2 from t where f1 = 1 union select 1, 2 where 1 = 1 --",
                                                      config));
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.wall.WallConfig$TenantCallBack

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.