You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/27 22:31:03 UTC
[shardingsphere] branch master updated: Add more test cases for queryWithCipherColumn (#18020)
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 49986ed9699 Add more test cases for queryWithCipherColumn (#18020)
49986ed9699 is described below
commit 49986ed9699804de88919f41b9f0ee0a2dd1d44f
Author: zhaoguhong <zh...@163.com>
AuthorDate: Sat May 28 06:30:55 2022 +0800
Add more test cases for queryWithCipherColumn (#18020)
---
.../EncryptTableRuleConfigurationYamlSwapperTest.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java
index d14fe1fd5ad..577c00441a2 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapperTest.java
@@ -30,6 +30,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -41,8 +42,8 @@ public final class EncryptTableRuleConfigurationYamlSwapperTest {
public void assertSwapToYamlConfiguration() {
Collection<EncryptColumnRuleConfiguration> encryptColumnRuleConfigs = Arrays.asList(
new EncryptColumnRuleConfiguration("encrypt_column_1", "encrypt_cipher_1", "", "", "test_encryptor_1", null),
- new EncryptColumnRuleConfiguration("encrypt_column_2", "encrypt_cipher_2", "", "", "test_encryptor_2", null),
- new EncryptColumnRuleConfiguration("encrypt_column_3", "encrypt_cipher_3", "", "", "test_encryptor_3", null));
+ new EncryptColumnRuleConfiguration("encrypt_column_2", "encrypt_cipher_2", "", "", "test_encryptor_2", true),
+ new EncryptColumnRuleConfiguration("encrypt_column_3", "encrypt_cipher_3", "", "", "test_encryptor_3", false));
EncryptTableRuleConfiguration encryptTableRuleConfig = new EncryptTableRuleConfiguration("test_table", encryptColumnRuleConfigs, true);
YamlEncryptTableRuleConfiguration actualYamlEncryptTableRuleConfig = tableRuleConfigYamlSwapper.swapToYamlConfiguration(encryptTableRuleConfig);
assertThat(actualYamlEncryptTableRuleConfig.getName(), is("test_table"));
@@ -52,12 +53,15 @@ public final class EncryptTableRuleConfigurationYamlSwapperTest {
YamlEncryptColumnRuleConfiguration actualYamlEncryptColumnRuleConfigFirst = actualColumns.get("encrypt_column_1");
assertThat(actualYamlEncryptColumnRuleConfigFirst.getCipherColumn(), is("encrypt_cipher_1"));
assertThat(actualYamlEncryptColumnRuleConfigFirst.getEncryptorName(), is("test_encryptor_1"));
+ assertNull(actualYamlEncryptColumnRuleConfigFirst.getQueryWithCipherColumn());
YamlEncryptColumnRuleConfiguration actualYamlEncryptColumnRuleConfigSecond = actualColumns.get("encrypt_column_2");
assertThat(actualYamlEncryptColumnRuleConfigSecond.getCipherColumn(), is("encrypt_cipher_2"));
assertThat(actualYamlEncryptColumnRuleConfigSecond.getEncryptorName(), is("test_encryptor_2"));
+ assertTrue(actualYamlEncryptColumnRuleConfigSecond.getQueryWithCipherColumn());
YamlEncryptColumnRuleConfiguration actualYamlEncryptColumnRuleConfigThird = actualColumns.get("encrypt_column_3");
assertThat(actualYamlEncryptColumnRuleConfigThird.getCipherColumn(), is("encrypt_cipher_3"));
assertThat(actualYamlEncryptColumnRuleConfigThird.getEncryptorName(), is("test_encryptor_3"));
+ assertFalse(actualYamlEncryptColumnRuleConfigThird.getQueryWithCipherColumn());
}
@Test
@@ -68,15 +72,24 @@ public final class EncryptTableRuleConfigurationYamlSwapperTest {
encryptColumnRuleConfig.setAssistedQueryColumn("encrypt_assisted");
encryptColumnRuleConfig.setPlainColumn("encrypt_plain");
encryptColumnRuleConfig.setEncryptorName("test_encryptor");
+ encryptColumnRuleConfig.setQueryWithCipherColumn(true);
Map<String, YamlEncryptColumnRuleConfiguration> columns = new LinkedHashMap<>(1);
columns.put("test_column", encryptColumnRuleConfig);
YamlEncryptTableRuleConfiguration yamlEncryptTableRuleConfig = new YamlEncryptTableRuleConfiguration();
yamlEncryptTableRuleConfig.setName("test_table");
yamlEncryptTableRuleConfig.setColumns(columns);
+ yamlEncryptTableRuleConfig.setQueryWithCipherColumn(true);
EncryptTableRuleConfiguration actualEncryptTableRuleConfig = tableRuleConfigYamlSwapper.swapToObject(yamlEncryptTableRuleConfig);
assertThat(actualEncryptTableRuleConfig.getName(), is("test_table"));
+ assertTrue(actualEncryptTableRuleConfig.getQueryWithCipherColumn());
Collection<EncryptColumnRuleConfiguration> actualColumns = actualEncryptTableRuleConfig.getColumns();
- assertFalse(actualColumns.isEmpty());
assertThat(actualColumns.size(), is(1));
+ EncryptColumnRuleConfiguration actualEncryptColumnRuleConfig = actualColumns.iterator().next();
+ assertThat(actualEncryptColumnRuleConfig.getLogicColumn(), is("test_column"));
+ assertThat(actualEncryptColumnRuleConfig.getCipherColumn(), is("encrypt_cipher"));
+ assertThat(actualEncryptColumnRuleConfig.getAssistedQueryColumn(), is("encrypt_assisted"));
+ assertThat(actualEncryptColumnRuleConfig.getPlainColumn(), is("encrypt_plain"));
+ assertThat(actualEncryptColumnRuleConfig.getEncryptorName(), is("test_encryptor"));
+ assertTrue(actualEncryptColumnRuleConfig.getQueryWithCipherColumn());
}
}