支持加载使用gzip命令压缩的maat JSON文件。允许先压缩、后加密,不支持先加密后压缩。
This commit is contained in:
@@ -33,6 +33,8 @@ extern int my_scandir(const char *dir, struct dirent ***namelist,
|
||||
extern char* md5_file(const char* filename, char* md5string);
|
||||
extern int system_cmd_cp(const char* src_file,const char*dst_file);
|
||||
extern int system_cmd_encrypt(const char* src_file, const char* dst_file, const char* password);
|
||||
int system_cmd_gzip(const char* src_file, const char* dst_file);
|
||||
|
||||
Maat_feather_t g_feather=NULL;
|
||||
void *g_logger=NULL;
|
||||
int g_iThreadNum=4;
|
||||
@@ -117,6 +119,7 @@ const char* old_json="./json_update/old.json";
|
||||
const char* new_json="./json_update/new.json";
|
||||
const char* corrupted_json="./json_update/corrupted.json";
|
||||
const char* json_decrypt_key="himaat!";
|
||||
const char* tmp_gzipped_file_name="./json_update/tmp_gzipped_json.gz";
|
||||
|
||||
class JSONUpdate : public testing::Test
|
||||
{
|
||||
@@ -124,10 +127,13 @@ class JSONUpdate : public testing::Test
|
||||
protected:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
int tmp=0;
|
||||
system_cmd_gzip(old_json, tmp_gzipped_file_name);
|
||||
system_cmd_encrypt(tmp_gzipped_file_name, watched_json, json_decrypt_key);
|
||||
|
||||
system_cmd_encrypt(old_json, watched_json, json_decrypt_key);
|
||||
|
||||
_shared_feather_j=Maat_feather(g_iThreadNum, table_info_path, g_logger);
|
||||
_shared_feather_j=Maat_feather(g_iThreadNum, table_info_path, g_logger);
|
||||
tmp=1;
|
||||
Maat_set_feather_opt(_shared_feather_j, MAAT_OPT_JSON_IS_GZIPPED, &tmp, sizeof(tmp));
|
||||
Maat_set_feather_opt(_shared_feather_j, MAAT_OPT_DECRYPT_KEY, json_decrypt_key, strlen(json_decrypt_key)+1);
|
||||
Maat_set_feather_opt(_shared_feather_j, MAAT_OPT_JSON_FILE_PATH, watched_json, strlen(watched_json)+1);
|
||||
Maat_set_feather_opt(_shared_feather_j, MAAT_OPT_SCANDIR_INTERVAL_MS, &scan_interval_ms, sizeof(scan_interval_ms));
|
||||
@@ -152,11 +158,13 @@ TEST_F(JSONUpdate, OldCfg)
|
||||
}
|
||||
TEST_F(JSONUpdate, NewCfg)
|
||||
{
|
||||
system_cmd_encrypt(corrupted_json, watched_json, json_decrypt_key);
|
||||
system_cmd_gzip(corrupted_json, tmp_gzipped_file_name);
|
||||
system_cmd_encrypt(tmp_gzipped_file_name, watched_json, json_decrypt_key);
|
||||
sleep(2);
|
||||
scan_with_old_or_new_cfg(JSONUpdate::_shared_feather_j, 1);
|
||||
|
||||
system_cmd_encrypt(new_json, watched_json, json_decrypt_key);
|
||||
system_cmd_gzip(new_json, tmp_gzipped_file_name);
|
||||
system_cmd_encrypt(tmp_gzipped_file_name, watched_json, json_decrypt_key);
|
||||
sleep(5);
|
||||
scan_with_old_or_new_cfg(JSONUpdate::_shared_feather_j, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user