Search in sources :

Example 26 with WallCheckResult

use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.

the class TenantInsertTest method testMySql6.

public void testMySql6() throws Exception {
    String insert_sql = "INSERT INTO orders (ID, NAME) SELECT ID, NAME FROM temp1 WHERE age = 18 UNION SELECT ID, NAME FROM temp2 UNION ALL SELECT ID, NAME FROM temp3";
    String expect_sql = "INSERT INTO orders (ID, NAME, tenant)\n" + "SELECT ID, NAME, 123\n" + "FROM temp1\n" + "WHERE age = 18\n" + "UNION\n" + "SELECT ID, NAME, 123\n" + "FROM temp2\n" + "UNION ALL\n" + "SELECT ID, NAME, 123\n" + "FROM temp3";
    {
        MySqlWallProvider provider = new MySqlWallProvider(config_callback);
        WallCheckResult checkResult = provider.check(insert_sql);
        Assert.assertEquals(0, checkResult.getViolations().size());
        String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
        Assert.assertEquals(expect_sql, resultSql);
    }
    {
        WallProvider.setTenantValue(123);
        MySqlWallProvider provider = new MySqlWallProvider(config);
        WallCheckResult checkResult = provider.check(insert_sql);
        Assert.assertEquals(0, checkResult.getViolations().size());
        String resultSql = SQLUtils.toSQLString(checkResult.getStatementList(), JdbcConstants.MYSQL);
        Assert.assertEquals(expect_sql, resultSql);
    }
}
Also used : MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Example 27 with WallCheckResult

use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.

the class TenantSelectTest2 method testMySql2.

public void testMySql2() throws Exception {
    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);
}
Also used : MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Example 28 with WallCheckResult

use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.

the class TenantSelectTest2 method testMySql.

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);
}
Also used : MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Example 29 with WallCheckResult

use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.

the class TenantSelectTest4 method testMySql.

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);
}
Also used : MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Example 30 with WallCheckResult

use of com.alibaba.druid.wall.WallCheckResult in project druid by alibaba.

the class TenantSelectTest method testMySql.

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);
}
Also used : MySqlWallProvider(com.alibaba.druid.wall.spi.MySqlWallProvider) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Aggregations

WallCheckResult (com.alibaba.druid.wall.WallCheckResult)38 MySqlWallProvider (com.alibaba.druid.wall.spi.MySqlWallProvider)21 WallProvider (com.alibaba.druid.wall.WallProvider)18 Violation (com.alibaba.druid.wall.Violation)3 WallConfig (com.alibaba.druid.wall.WallConfig)3 FirewallConfig (io.mycat.config.model.FirewallConfig)2 Test (org.junit.Test)2 FirewallConfig (com.actiontech.dble.config.model.FirewallConfig)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 OracleStatementParser (com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser)1 WallUpdateCheckHandler (com.alibaba.druid.wall.WallUpdateCheckHandler)1 OracleWallProvider (com.alibaba.druid.wall.spi.OracleWallProvider)1 PGWallProvider (com.alibaba.druid.wall.spi.PGWallProvider)1