[ISSUE#11695] fix PreviousConfigHistory encryption (#11707)
* fix PreviousConfigHistory encryption * UT fix
This commit is contained in:
parent
bd5caa64a6
commit
817eb58597
@ -87,6 +87,12 @@ public class HistoryService {
|
||||
}
|
||||
// check if history config match the input
|
||||
checkHistoryInfoPermission(configHistoryInfo, dataId, group, namespaceId);
|
||||
|
||||
String encryptedDataKey = configHistoryInfo.getEncryptedDataKey();
|
||||
Pair<String, String> pair = EncryptionHandler
|
||||
.decryptHandler(dataId, encryptedDataKey, configHistoryInfo.getContent());
|
||||
configHistoryInfo.setContent(pair.getSecond());
|
||||
|
||||
return configHistoryInfo;
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ public interface HistoryConfigInfoMapper extends Mapper {
|
||||
*/
|
||||
default MapperResult detailPreviousConfigHistory(MapperContext context) {
|
||||
return new MapperResult(
|
||||
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified "
|
||||
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified,encrypted_data_key "
|
||||
+ "FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)",
|
||||
Collections.singletonList(context.getWhereParameter(FieldConstant.ID)));
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class HistoryConfigInfoMapperByDerbyTest {
|
||||
MapperResult mapperResult = historyConfigInfoMapperByDerby.detailPreviousConfigHistory(context);
|
||||
Assert.assertEquals(mapperResult.getSql(),
|
||||
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,"
|
||||
+ "gmt_modified FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
|
||||
+ "gmt_modified,encrypted_data_key FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
|
||||
Assert.assertArrayEquals(mapperResult.getParamList().toArray(), new Object[] {id});
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class HistoryConfigInfoMapperByMySqlTest {
|
||||
MapperResult mapperResult = historyConfigInfoMapperByMySql.detailPreviousConfigHistory(context);
|
||||
Assert.assertEquals(mapperResult.getSql(),
|
||||
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,"
|
||||
+ "gmt_modified FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
|
||||
+ "gmt_modified,encrypted_data_key FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
|
||||
Assert.assertArrayEquals(mapperResult.getParamList().toArray(), new Object[] {id});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user