This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new a7385886dfc Add single mask integration test (#23330)
a7385886dfc is described below
commit a7385886dfc17ccf8a3f5e49d2257bcbae7811b4
Author: gxxiong <[email protected]>
AuthorDate: Thu Jan 5 08:52:11 2023 +0800
Add single mask integration test (#23330)
* add mask scenario
* Add unit test for MaskAlgorithmUtil
* Add single mask integration test
---
.../cases/dql/dql-integration-test-cases.xml | 17 +++++-
.../test/resources/env/scenario/mask/authority.xml | 70 ++++++++++++++++++++++
.../env/scenario/mask/data/actual/databases.xml | 21 +++++++
.../env/scenario/mask/data/actual/dataset.xml | 47 +++++++++++++++
.../data/actual/init-sql/h2/01-actual-init.sql | 19 ++++++
.../data/actual/init-sql/mysql/01-actual-init.sql | 24 ++++++++
.../actual/init-sql/opengauss/01-actual-init.sql | 26 ++++++++
.../data/actual/init-sql/oracle/01-actual-init.sql | 21 +++++++
.../actual/init-sql/postgresql/01-actual-init.sql | 26 ++++++++
.../actual/init-sql/sqlserver/01-actual-init.sql | 21 +++++++
.../env/scenario/mask/data/expected/databases.xml | 21 +++++++
.../env/scenario/mask/data/expected/dataset.xml | 47 +++++++++++++++
.../data/expected/init-sql/h2/01-expected-init.sql | 20 +++++++
.../expected/init-sql/mysql/01-expected-init.sql | 24 ++++++++
.../init-sql/opengauss/01-expected-init.sql | 27 +++++++++
.../expected/init-sql/oracle/01-expected-init.sql | 21 +++++++
.../init-sql/postgresql/01-expected-init.sql | 27 +++++++++
.../init-sql/sqlserver/01-expected-init.sql | 22 +++++++
.../mask/proxy/conf/mysql/config-mask.yaml | 55 +++++++++++++++++
.../mask/proxy/conf/opengauss/config-mask.yaml | 56 +++++++++++++++++
.../mask/proxy/conf/postgresql/config-mask.yaml | 55 +++++++++++++++++
.../test/resources/env/scenario/mask/rules.yaml | 42 +++++++++++++
22 files changed, 708 insertions(+), 1 deletion(-)
diff --git
a/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
b/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
index 2873351928f..249d46f2544 100644
--- a/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
+++ b/test/e2e/suite/src/test/resources/cases/dql/dql-integration-test-cases.xml
@@ -1267,7 +1267,7 @@
<assertion expected-data-source-name="read_dataset" />
</test-case>
- <test-case sql="SELECT country_id, COUNT(1) FROM t_merchant WHERE
business_code LIKE '_1000018' GROUP BY country_id"
db-types="MySQL,PostgreSQL,openGauss" scenario-types="db,encrypt"
+ <test-case sql="SELECT country_id, COUNT(1) FROM t_merchant WHERE
business_code LIKE '_1000018' GROUP BY country_id"
db-types="MySQL,PostgreSQL,openGauss" scenario-types="db,encrypt"
scenario-comments="Test single table's LIKE operator underscore
wildcard in select group by statement when use sharding feature.|Test encrypt
table's LIKE operator underscore wildcard in select group by statement when use
encrypt feature.">
<assertion expected-data-source-name="read_dataset" />
</test-case>
@@ -1291,4 +1291,19 @@
<assertion parameters="foo:String"
expected-data-source-name="expected_dataset" />
</test-case>
+ <test-case sql="SELECT * FROM t_user"
db-types="MySQL,PostgreSQL,openGauss" scenario-types="mask">
+ <assertion expected-data-source-name="expected_dataset" />
+ </test-case>
+
+ <test-case sql="SELECT u1.* FROM t_user u1 INNER JOIN t_user u2 ON
u1.user_id = u2.user_id" db-types="MySQL,PostgreSQL,openGauss"
scenario-types="mask">
+ <assertion expected-data-source-name="expected_dataset" />
+ </test-case>
+
+ <test-case sql="SELECT * FROM (SELECT * FROM t_user) temp"
db-types="MySQL,PostgreSQL,openGauss" scenario-types="mask">
+ <assertion expected-data-source-name="expected_dataset" />
+ </test-case>
+
+ <test-case sql="SELECT * FROM (SELECT u1.* FROM t_user u1 INNER JOIN
t_user u2 ON u1.user_id = u2.user_id) temp"
db-types="MySQL,PostgreSQL,openGauss" scenario-types="mask">
+ <assertion expected-data-source-name="expected_dataset" />
+ </test-case>
</integration-test-cases>
diff --git a/test/e2e/suite/src/test/resources/env/scenario/mask/authority.xml
b/test/e2e/suite/src/test/resources/env/scenario/mask/authority.xml
new file mode 100644
index 00000000000..6b746be38bd
--- /dev/null
+++ b/test/e2e/suite/src/test/resources/env/scenario/mask/authority.xml
@@ -0,0 +1,70 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<authority>
+ <sqlset db-types="Oracle,SQLServer,PostgreSQL,openGauss">
+ <user-create>
+ <sql>CREATE USER default_user</sql>
+ <sql>CREATE ROLE default_role</sql>
+ <sql>CREATE ROLE role2</sql>
+ <sql>CREATE ROLE role3</sql>
+ <sql>CREATE ROLE role4</sql>
+ </user-create>
+ <user-drop>
+ <sql>DROP ROLE IF EXISTS default_role</sql>
+ <sql>DROP ROLE IF EXISTS role_dev</sql>
+ <sql>DROP ROLE IF EXISTS role_dev_new</sql>
+ <sql>DROP ROLE IF EXISTS role2</sql>
+ <sql>DROP ROLE IF EXISTS role3</sql>
+ <sql>DROP ROLE IF EXISTS role4</sql>
+ <sql>DROP USER IF EXISTS user_dev</sql>
+ <sql>DROP USER IF EXISTS user_dev_new</sql>
+ <sql>DROP USER IF EXISTS default_user</sql>
+ </user-drop>
+ </sqlset>
+ <sqlset db-types="SQLServer">
+ <user-create>
+ <sql>CREATE LOGIN login_dev</sql>
+ <sql>CREATE USER user_dev FOR LOGIN login_dev</sql>
+ </user-create>
+ <user-drop>
+ <sql>DROP LOGIN IF EXISTS login_dev</sql>
+ <sql>DROP LOGIN IF EXISTS login_dev_new</sql>
+ </user-drop>
+ </sqlset>
+ <sqlset db-types="MySQL">
+ <user-create>
+ <sql>CREATE ROLE default_role</sql>
+ <sql>CREATE USER user_dev@localhost</sql>
+ <sql>GRANT select,update,insert,delete on encrypt.* to
user_dev@localhost</sql>
+ </user-create>
+ <user-drop>
+ <sql>DROP USER IF EXISTS user_dev@localhost</sql>
+ <sql>DROP USER IF EXISTS user_dev_new@localhost</sql>
+ <sql>DROP USER IF EXISTS [email protected]</sql>
+ <sql>DROP ROLE IF EXISTS default_role</sql>
+ <sql>DROP ROLE IF EXISTS role_dev</sql>
+ <sql>DROP ROLE IF EXISTS role_dev_new</sql>
+ <sql>FLUSH PRIVILEGES</sql>
+ </user-drop>
+ </sqlset>
+ <sqlset db-types="Oracle">
+ <user-create>
+ <sql>CREATE USER user_dev identified by passwd_dev</sql>
+ </user-create>
+ </sqlset>
+</authority>
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/databases.xml
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/databases.xml
new file mode 100644
index 00000000000..24aaf46aae3
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/databases.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<databases>
+ <database>mask</database>
+</databases>
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/dataset.xml
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/dataset.xml
new file mode 100644
index 00000000000..45c670d8296
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/dataset.xml
@@ -0,0 +1,47 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<dataset>
+ <metadata data-nodes="mask.t_user">
+ <column name="user_id" type="numeric" />
+ <column name="user_name" type="varchar" />
+ <column name="password" type="varchar" />
+ <column name="email" type="varchar" />
+ <column name="telephone" type="varchar" />
+ <column name="creation_date" type="datetime" />
+ </metadata>
+ <row data-node="mask.t_user" values="10, zhangsan, 111111,
[email protected], 12345678900, 2017-08-08"/>
+ <row data-node="mask.t_user" values="11, lisi, 222222, [email protected],
12345678901, 2017-08-08"/>
+ <row data-node="mask.t_user" values="12, wangwu, 333333, [email protected],
12345678902, 2017-08-08"/>
+ <row data-node="mask.t_user" values="13, zhaoliu, 444444,
[email protected], 12345678903, 2017-08-08"/>
+ <row data-node="mask.t_user" values="14, zhuqi, 555555, [email protected],
12345678904, 2017-08-08"/>
+ <row data-node="mask.t_user" values="15, liba, 666666, [email protected],
12345678905, 2017-08-08"/>
+ <row data-node="mask.t_user" values="16, wangjiu, 777777,
[email protected], 12345678906, 2017-08-08"/>
+ <row data-node="mask.t_user" values="17, zhuda, 888888, [email protected],
12345678907, 2017-08-08"/>
+ <row data-node="mask.t_user" values="18, suner, 999999, [email protected],
12345678908, 2017-08-08"/>
+ <row data-node="mask.t_user" values="19, zhousan, 123456,
[email protected], 12345678909, 2017-08-08"/>
+ <row data-node="mask.t_user" values="20, tom, 234567, [email protected],
12345678910, 2017-08-08" />
+ <row data-node="mask.t_user" values="21, kobe, 345678, [email protected],
12345678911, 2017-08-08" />
+ <row data-node="mask.t_user" values="22, jerry, 456789, [email protected],
12345678912, 2017-08-08" />
+ <row data-node="mask.t_user" values="23, james, 567890, [email protected],
12345678913, 2017-08-08" />
+ <row data-node="mask.t_user" values="24, wade, 012345, [email protected],
12345678914, 2017-08-08" />
+ <row data-node="mask.t_user" values="25, rose, 000000, [email protected],
12345678915, 2017-08-08" />
+ <row data-node="mask.t_user" values="26, bosh, 111222, [email protected],
12345678916, 2017-08-08" />
+ <row data-node="mask.t_user" values="27, jack, 222333, [email protected],
12345678917, 2017-08-08" />
+ <row data-node="mask.t_user" values="28, jordan, 333444, [email protected],
12345678918, 2017-08-08" />
+ <row data-node="mask.t_user" values="29, julie, 444555, [email protected],
12345678919, 2017-08-08" />
+</dataset>
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/h2/01-actual-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/h2/01-actual-init.sql
new file mode 100644
index 00000000000..a96618c0f3e
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/h2/01-actual-init.sql
@@ -0,0 +1,19 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+DROP TABLE IF EXISTS t_user;
+
+CREATE TABLE t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone CHAR(11)
NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/mysql/01-actual-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/mysql/01-actual-init.sql
new file mode 100644
index 00000000000..7a18c5e8140
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/mysql/01-actual-init.sql
@@ -0,0 +1,24 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+SET character_set_database='utf8';
+SET character_set_server='utf8';
+
+DROP DATABASE IF EXISTS mask;
+CREATE DATABASE mask;
+
+CREATE TABLE mask.t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT
NULL, password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone
CHAR(11) NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/opengauss/01-actual-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/opengauss/01-actual-init.sql
new file mode 100644
index 00000000000..2d87853bc80
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/opengauss/01-actual-init.sql
@@ -0,0 +1,26 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE DATABASE mask;
+
+GRANT ALL PRIVILEGES ON DATABASE mask TO test_user;
+
+\c mask
+
+DROP TABLE IF EXISTS t_user;
+
+CREATE TABLE t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone CHAR(11)
NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/oracle/01-actual-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/oracle/01-actual-init.sql
new file mode 100644
index 00000000000..afc2c2feef5
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/oracle/01-actual-init.sql
@@ -0,0 +1,21 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+DROP SCHEMA mask;
+CREATE SCHEMA mask;
+
+CREATE TABLE mask.t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT
NULL, password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone
CHAR(11) NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/postgresql/01-actual-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/postgresql/01-actual-init.sql
new file mode 100644
index 00000000000..2d87853bc80
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/postgresql/01-actual-init.sql
@@ -0,0 +1,26 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+CREATE DATABASE mask;
+
+GRANT ALL PRIVILEGES ON DATABASE mask TO test_user;
+
+\c mask
+
+DROP TABLE IF EXISTS t_user;
+
+CREATE TABLE t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone CHAR(11)
NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/sqlserver/01-actual-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/sqlserver/01-actual-init.sql
new file mode 100644
index 00000000000..a9597d92c27
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/actual/init-sql/sqlserver/01-actual-init.sql
@@ -0,0 +1,21 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+DROP DATABASE IF EXISTS mask;
+CREATE DATABASE mask;
+
+CREATE TABLE mask.t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT
NULL, password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone
CHAR(11) NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/databases.xml
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/databases.xml
new file mode 100644
index 00000000000..9e98dc8baea
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/databases.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<databases>
+ <database>expected_dataset</database>
+</databases>
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/dataset.xml
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/dataset.xml
new file mode 100644
index 00000000000..1901d4dcb81
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/dataset.xml
@@ -0,0 +1,47 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<dataset>
+ <metadata data-nodes="expected_dataset.t_user">
+ <column name="user_id" type="numeric" />
+ <column name="user_name" type="varchar" />
+ <column name="password" type="varchar" />
+ <column name="email" type="varchar" />
+ <column name="telephone" type="varchar" />
+ <column name="creation_date" type="datetime" />
+ </metadata>
+ <row data-node="expected_dataset.t_user" values="10, zhangsan,
96e79218965eb72c92a549dd5a330112, ********@gmail.com, 123****8900, 2017-08-08"
/>
+ <row data-node="expected_dataset.t_user" values="11, lisi,
e3ceb5881a0a1fdaad01296d7554868d, ****@gmail.com, 123****8901, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="12, wangwu,
1a100d2c0dab19c4430e7d73762b3423, ******@gmail.com, 123****8902, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="13, zhaoliu,
73882ab1fa529d7273da0db6b49cc4f3, *******@gmail.com, 123****8903, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="14, zhuqi,
5b1b68a9abf4d2cd155c81a9225fd158, *****@gmail.com, 123****8904, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="15, liba,
f379eaf3c831b04de153469d1bec345e, ****@gmail.com, 123****8905, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="16, wangjiu,
f63f4fbc9f8c85d409f2f59f2b9e12d5, *******@gmail.com, 123****8906, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="17, zhuda,
21218cca77804d2ba1922c33e0151105, *****@gmail.com, 123****8907, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="18, suner,
52c69e3a57331081823331c4e69d3f2e, *****@gmail.com, 123****8908, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="19, zhousan,
e10adc3949ba59abbe56e057f20f883e, *******@gmail.com, 123****8909, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="20, tom,
508df4cb2f4d8f80519256258cfb975f, ***@gmail.com, 123****8910, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="21, kobe,
5bd2026f128662763c532f2f4b6f2476, ****@gmail.com, 123****8911, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="22, jerry,
e35cf7b66449df565f93c607d5a81d09, *****@gmail.com, 123****8912, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="23, james,
ba00819f263287af1ff0100c5a323355, *****@gmail.com, 123****8913, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="24, wade,
d6a9a933c8aafc51e55ac0662b6e4d4a, ****@gmail.com, 123****8914, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="25, rose,
670b14728ad9902aecba32e22fa4f6bd, ****@gmail.com, 123****8915, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="26, bosh,
00b7691d86d96aebd21dd9e138f90840, ****@gmail.com, 123****8916, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="27, jack,
731982a033a5cc815ac03c8504abb748, ****@gmail.com, 123****8917, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="28, jordan,
abf156f3cf64496f9da2cabca68d95fe, ******@gmail.com, 123****8918, 2017-08-08" />
+ <row data-node="expected_dataset.t_user" values="29, julie,
01c401bb1b2ba502df5a854be02ea4e9, *****@gmail.com, 123****8919, 2017-08-08" />
+</dataset>
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/h2/01-expected-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/h2/01-expected-init.sql
new file mode 100644
index 00000000000..7472146bbf1
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/h2/01-expected-init.sql
@@ -0,0 +1,20 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+DROP TABLE IF EXISTS t_user;
+
+CREATE TABLE t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone CHAR(11)
NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/mysql/01-expected-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/mysql/01-expected-init.sql
new file mode 100644
index 00000000000..94097717509
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/mysql/01-expected-init.sql
@@ -0,0 +1,24 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+SET character_set_database='utf8';
+SET character_set_server='utf8';
+
+DROP DATABASE IF EXISTS expected_dataset;
+CREATE DATABASE expected_dataset;
+
+CREATE TABLE expected_dataset.t_user (user_id INT PRIMARY KEY, user_name
VARCHAR(50) NOT NULL, password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT
NULL, telephone CHAR(11) NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/opengauss/01-expected-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/opengauss/01-expected-init.sql
new file mode 100644
index 00000000000..0ee0a77b33d
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/opengauss/01-expected-init.sql
@@ -0,0 +1,27 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+DROP DATABASE IF EXISTS expected_dataset;
+CREATE DATABASE expected_dataset;
+
+GRANT ALL PRIVILEGES ON DATABASE expected_dataset TO test_user;
+
+\c expected_dataset;
+
+DROP TABLE IF EXISTS t_user;
+
+CREATE TABLE t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone CHAR(11)
NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/oracle/01-expected-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/oracle/01-expected-init.sql
new file mode 100644
index 00000000000..15ffd3ab47a
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/oracle/01-expected-init.sql
@@ -0,0 +1,21 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+DROP SCHEMA expected_dataset;
+CREATE SCHEMA expected_dataset;
+
+CREATE TABLE expected_dataset.t_user (user_id INT PRIMARY KEY, user_name
VARCHAR(50) NOT NULL, password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT
NULL, telephone CHAR(11) NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/postgresql/01-expected-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/postgresql/01-expected-init.sql
new file mode 100644
index 00000000000..0ee0a77b33d
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/postgresql/01-expected-init.sql
@@ -0,0 +1,27 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+DROP DATABASE IF EXISTS expected_dataset;
+CREATE DATABASE expected_dataset;
+
+GRANT ALL PRIVILEGES ON DATABASE expected_dataset TO test_user;
+
+\c expected_dataset;
+
+DROP TABLE IF EXISTS t_user;
+
+CREATE TABLE t_user (user_id INT PRIMARY KEY, user_name VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, telephone CHAR(11)
NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/sqlserver/01-expected-init.sql
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/sqlserver/01-expected-init.sql
new file mode 100644
index 00000000000..8cbad8ae180
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/data/expected/init-sql/sqlserver/01-expected-init.sql
@@ -0,0 +1,22 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+DROP DATABASE IF EXISTS expected_dataset;
+
+CREATE DATABASE expected_dataset;
+
+CREATE TABLE expected_dataset.t_user (user_id INT PRIMARY KEY, user_name
VARCHAR(50) NOT NULL, password VARCHAR(50) NOT NULL, email VARCHAR(50) NOT
NULL, telephone CHAR(11) NOT NULL, creation_date DATE NOT NULL);
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/mysql/config-mask.yaml
b/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/mysql/config-mask.yaml
new file mode 100644
index 00000000000..c285023b9d3
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/mysql/config-mask.yaml
@@ -0,0 +1,55 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+databaseName: mask
+
+dataSources:
+ mask:
+ url:
jdbc:mysql://mysql.mask.host:3306/mask?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 2
+ minPoolSize: 2
+
+rules:
+- !MASK
+ maskAlgorithms:
+ md5_mask:
+ type: MD5
+ mask_before_special_chars_mask:
+ type: MASK_BEFORE_SPECIAL_CHARS
+ props:
+ special-chars: '@'
+ replace-char: '*'
+ keep_first_n_last_m_mask:
+ type: KEEP_FIRST_N_LAST_M
+ props:
+ first-n: 3
+ last-m: 4
+ replace-char: '*'
+ tables:
+ t_user:
+ columns:
+ password:
+ maskAlgorithm: md5_mask
+ email:
+ maskAlgorithm: mask_before_special_chars_mask
+ telephone:
+ maskAlgorithm: keep_first_n_last_m_mask
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/opengauss/config-mask.yaml
b/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/opengauss/config-mask.yaml
new file mode 100644
index 00000000000..2a089efc551
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/opengauss/config-mask.yaml
@@ -0,0 +1,56 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+databaseName: mask
+
+dataSources:
+ encrypt:
+ url: jdbc:opengauss://opengauss.mask.host:5432/mask
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 2
+ minPoolSize: 2
+
+rules:
+- !MASK
+ maskAlgorithms:
+ md5_mask:
+ type: MD5
+ mask_before_special_chars_mask:
+ type: MASK_BEFORE_SPECIAL_CHARS
+ props:
+ special-chars: '@'
+ replace-char: '*'
+ keep_first_n_last_m_mask:
+ type: KEEP_FIRST_N_LAST_M
+ props:
+ first-n: 3
+ last-m: 4
+ replace-char: '*'
+ tables:
+ t_user:
+ columns:
+ password:
+ maskAlgorithm: md5_mask
+ email:
+ maskAlgorithm: mask_before_special_chars_mask
+ telephone:
+ maskAlgorithm: keep_first_n_last_m_mask
+
diff --git
a/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/postgresql/config-mask.yaml
b/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/postgresql/config-mask.yaml
new file mode 100644
index 00000000000..464c9538333
--- /dev/null
+++
b/test/e2e/suite/src/test/resources/env/scenario/mask/proxy/conf/postgresql/config-mask.yaml
@@ -0,0 +1,55 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+databaseName: mask
+
+dataSources:
+ encrypt:
+ url: jdbc:postgresql://postgresql.mask.host:5432/mask
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 2
+ minPoolSize: 2
+
+rules:
+- !MASK
+ maskAlgorithms:
+ md5_mask:
+ type: MD5
+ mask_before_special_chars_mask:
+ type: MASK_BEFORE_SPECIAL_CHARS
+ props:
+ special-chars: '@'
+ replace-char: '*'
+ keep_first_n_last_m_mask:
+ type: KEEP_FIRST_N_LAST_M
+ props:
+ first-n: 3
+ last-m: 4
+ replace-char: '*'
+ tables:
+ t_user:
+ columns:
+ password:
+ maskAlgorithm: md5_mask
+ email:
+ maskAlgorithm: mask_before_special_chars_mask
+ telephone:
+ maskAlgorithm: keep_first_n_last_m_mask
diff --git a/test/e2e/suite/src/test/resources/env/scenario/mask/rules.yaml
b/test/e2e/suite/src/test/resources/env/scenario/mask/rules.yaml
new file mode 100644
index 00000000000..ed6967daab8
--- /dev/null
+++ b/test/e2e/suite/src/test/resources/env/scenario/mask/rules.yaml
@@ -0,0 +1,42 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+rules:
+- !MASK
+ maskAlgorithms:
+ md5_mask:
+ type: MD5
+ mask_before_special_chars_mask:
+ type: MASK_BEFORE_SPECIAL_CHARS
+ props:
+ special-chars: '@'
+ replace-char: '*'
+ keep_first_n_last_m_mask:
+ type: KEEP_FIRST_N_LAST_M
+ props:
+ first-n: 3
+ last-m: 4
+ replace-char: '*'
+ tables:
+ t_user:
+ columns:
+ password:
+ maskAlgorithm: md5_mask
+ email:
+ maskAlgorithm: mask_before_special_chars_mask
+ telephone:
+ maskAlgorithm: keep_first_n_last_m_mask