Package com.alibaba.druid.wall.spi

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


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

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

        provider.getConfig().setCommentAllow(true);

        Assert.assertTrue(provider.checkValid(//
        "SELECT * FROM T WHERE FID = ? OR FID LIKE 1 --"));

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


* @see
*/
public class MySqlWallTest67 extends TestCase {

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

        Assert.assertTrue(provider.checkValid(//
        "SELECT c.table_name, column_name, column_type, is_nullable, column_key" + //
                "   , column_default, extra, collation_name, character_set_name, column_comment " + //
                "FROM information_schema.columns c " + //
                "INNER JOIN (" + //
                "   SELECT table_schema, table_name " + //
                "   FROM information_schema.tables " + //
                "   WHERE LOWER(table_schema) = LOWER('sp5035d3d0b2d4a')" + //
                ") t ON t.table_name COLLATE utf8_bin = c.table_name COLLATE utf8_bin " + //
                "WHERE LOWER(c.table_schema) = LOWER('sp5035d3d0b2d4a') " + //
                "   AND ('Y' = '' OR LOWER(c.table_name) IN ('leader01_weibo')) " + //
                "ORDER BY t.table_name"));

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

* @see
*/
public class MySqlWallTest72 extends TestCase {

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

        Assert.assertFalse(provider.checkValid(//
        "select * from t /**/ where fid = 123 AND 1=1"));

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

        config_callback.setTenantCallBack(new TenantTestCallBack());
    }

    public void testMySql() throws Exception {
        WallProvider.setTenantValue(123);
        MySqlWallProvider provider = new MySqlWallProvider(config);
        WallCheckResult checkResult = provider.check(sql);
        Assert.assertEquals(0, checkResult.getViolations().size());

        String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
        Assert.assertEquals(expect_sql, resultSql);
    }
View Full Code Here

        Assert.assertEquals(expect_sql, resultSql);
    }

    public void testMySql2() throws Exception {
        WallProvider.setTenantValue(123);
        MySqlWallProvider provider = new MySqlWallProvider(config_callback);
        WallCheckResult checkResult = provider.check(sql);
        Assert.assertEquals(0, checkResult.getViolations().size());

        String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
        Assert.assertEquals(expect_sql, resultSql);
    }
View Full Code Here

    private String insert_sql = "INSERT INTO members (FID, FNAME) VALUES (?, ?)";
    private String update_sql = "UPDATE members SET FNAME = ? WHERe FID = ?";
    private String delete_sql = "DELETE members WHERE FID = ?";

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

        Assert.assertFalse(provider.checkValid(insert_sql));
        Assert.assertFalse(provider.checkValid(update_sql));
        Assert.assertFalse(provider.checkValid(delete_sql));

    }
View Full Code Here

* @see
*/
public class MySqlWallTest48 extends TestCase {

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

        Assert.assertTrue(provider.checkValid(//
        "select sum(size) as total " + //
                "from file " + //
                "join file_to_post on file_to_post.file_id = file.id " + //
                "join notice on file_to_post.post_id = notice.id " + //
                "where profile_id = 18544 and file.url like '%/notice/%/file' AND EXTRACT(month FROM file.modified) = EXTRACT(month FROM now()) and EXTRACT(year FROM file.modified) = EXTRACT(year FROM now())"));

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

* @see
*/
public class MySqlWallTest83 extends TestCase {

    public void test_false() throws Exception {
        WallProvider provider = new MySqlWallProvider();
       
        Assert.assertTrue(provider.checkValid(//
        "alter table rms.rms_Person_Event drop foreign key FKA382487726D72F65"));

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

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

public class MySqlWallTest136 extends TestCase {

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

        Assert.assertFalse(provider.checkValid("SELECT * FROM Users WHERE id = '1' AND MID(@@VERSION,1,1) = '5';"));
    }
View Full Code Here

* @see
*/
public class MySqlWallTest68 extends TestCase {

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

        Assert.assertTrue(provider.checkValid(//
        "SELECT * FROM `information_schema`.`ROUTINES` " + //
                "WHERE `information_schema`.`ROUTINES`.`ROUTINE_SCHEMA` = 'mzsg_g001'"));

        Assert.assertEquals(1, provider.getTableStats().size());
    }
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.