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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations