Search in sources :

Example 16 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 17 with WallCheckResult

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

the class TenantSelectTest3 method testMySql.

public void testMySql() throws Exception {
    WallConfig config = new WallConfig();
    WallConfig config_callback = new WallConfig();
    config.setTenantTablePattern("*");
    config.setTenantColumn("tenant");
    config_callback.setTenantCallBack(new TenantTestCallBack());
    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) WallConfig(com.alibaba.druid.wall.WallConfig) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Example 18 with WallCheckResult

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

the class TenantSelectTest3 method testMySql2.

public void testMySql2() throws Exception {
    WallConfig config = new WallConfig();
    WallConfig config_callback = new WallConfig();
    config.setTenantTablePattern("*");
    config.setTenantColumn("tenant");
    config_callback.setTenantCallBack(new TenantTestCallBack());
    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) WallConfig(com.alibaba.druid.wall.WallConfig) WallCheckResult(com.alibaba.druid.wall.WallCheckResult)

Example 19 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)

Aggregations

WallCheckResult (com.alibaba.druid.wall.WallCheckResult)19 MySqlWallProvider (com.alibaba.druid.wall.spi.MySqlWallProvider)17 WallConfig (com.alibaba.druid.wall.WallConfig)3 WallProvider (com.alibaba.druid.wall.WallProvider)3 Violation (com.alibaba.druid.wall.Violation)2 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLShowTablesStatement (com.alibaba.druid.sql.ast.statement.SQLShowTablesStatement)1 PGWallProvider (com.alibaba.druid.wall.spi.PGWallProvider)1 FirewallConfig (io.mycat.config.model.FirewallConfig)1 Test (org.junit.Test)1