子分组功能单元测试通过。
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name": "IP_group",
|
||||
"group_name": "123_IP_group",
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "IP_CONFIG",
|
||||
@@ -77,7 +77,7 @@
|
||||
"is_valid": "yes",
|
||||
"groups": [
|
||||
{
|
||||
"group_name": "IP_group"
|
||||
"group_name": "123_IP_group"
|
||||
},
|
||||
{
|
||||
"group_name": "Untitled",
|
||||
@@ -144,7 +144,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"group_name": "Untitled",
|
||||
"group_name": "126_interval_group",
|
||||
"regions": [
|
||||
{
|
||||
"table_name": "CONTENT_SIZE",
|
||||
@@ -595,7 +595,7 @@
|
||||
"match_method": "sub",
|
||||
"format": "uncase plain"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -682,7 +682,7 @@
|
||||
},
|
||||
{
|
||||
"not_flag":1,
|
||||
"group_name": "IP_group"
|
||||
"group_name": "123_IP_group"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -879,9 +879,25 @@
|
||||
"format": "uncase plain",
|
||||
"match_method": "prefix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"table_type": "expr",
|
||||
"table_name": "MAIL_ADDR",
|
||||
"table_content": {
|
||||
"keywords": "ceshi6@mailhost.cn",
|
||||
"expr_type": "none",
|
||||
"format": "uncase plain",
|
||||
"match_method": "prefix"
|
||||
}
|
||||
}
|
||||
],
|
||||
"group_name": "152_mail_addr"
|
||||
},
|
||||
{
|
||||
"group_name": "interval_group_refered",
|
||||
"sub_groups": [
|
||||
{"group_name": "126_interval_group"}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -917,7 +933,7 @@
|
||||
{
|
||||
"group_name": "IP_group_refered",
|
||||
"sub_groups": [
|
||||
{"group_name": "IP_group"}
|
||||
{"group_name": "123_IP_group"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -308,31 +308,37 @@ TEST(StringScan, BugReport20190325)
|
||||
TEST(StringScan, PrefixAndSuffix)
|
||||
{
|
||||
int ret=0;
|
||||
int table_id=0;
|
||||
int mail_addr_table=0, cont_sz_table=0;
|
||||
struct Maat_rule_t result[4];
|
||||
int found_pos[4];
|
||||
const char* table_name="MAIL_ADDR";
|
||||
scan_status_t mid=NULL;
|
||||
const char* hit_twice="ceshi3@mailhost.cn";
|
||||
const char* hit_suffix="11111111111ceshi3@mailhost.cn";
|
||||
const char* hit_prefix="ceshi3@mailhost.cn11111111111";
|
||||
table_id=Maat_table_register(g_feather,table_name);
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
|
||||
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, hit_twice, strlen(hit_twice),
|
||||
cont_sz_table=Maat_table_register(g_feather, "CONTENT_SIZE");
|
||||
ret=Maat_scan_intval(g_feather, cont_sz_table, 2015,
|
||||
result, 4, &mid, 0);
|
||||
mail_addr_table=Maat_table_register(g_feather, "MAIL_ADDR");
|
||||
ASSERT_GT(mail_addr_table, 0);
|
||||
ret=Maat_full_scan_string(g_feather, mail_addr_table,CHARSET_GBK, hit_twice, strlen(hit_twice),
|
||||
result,found_pos, 4, &mid, 0);
|
||||
EXPECT_EQ(ret, 2);
|
||||
EXPECT_EQ(result[0].config_id, 152);
|
||||
EXPECT_EQ(result[1].config_id, 151);
|
||||
Maat_clean_status(&mid);
|
||||
|
||||
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, hit_suffix, strlen(hit_suffix),
|
||||
ret=Maat_full_scan_string(g_feather, mail_addr_table,CHARSET_GBK, hit_suffix, strlen(hit_suffix),
|
||||
result,found_pos, 4, &mid, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
EXPECT_EQ(result[0].config_id, 151);
|
||||
Maat_clean_status(&mid);
|
||||
|
||||
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, hit_prefix, strlen(hit_prefix),
|
||||
ret=Maat_scan_intval(g_feather, cont_sz_table, 2015,
|
||||
result, 4, &mid, 0);
|
||||
|
||||
ret=Maat_full_scan_string(g_feather, mail_addr_table,CHARSET_GBK, hit_prefix, strlen(hit_prefix),
|
||||
result,found_pos, 4, &mid, 0);
|
||||
EXPECT_EQ(ret, 1);
|
||||
EXPECT_EQ(result[0].config_id, 152);
|
||||
@@ -489,15 +495,15 @@ TEST(NOTLogic, OneRegion)
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_LAST_REGION, NULL, 0);
|
||||
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, string_should_hit, strlen(string_should_hit),
|
||||
result,found_pos, 4, &mid, 0);
|
||||
ret=Maat_full_scan_string(g_feather, table_id, CHARSET_GBK, string_should_hit, strlen(string_should_hit),
|
||||
result, found_pos, 4, &mid, 0);
|
||||
|
||||
EXPECT_GE(ret, 1);
|
||||
Maat_clean_status(&mid);
|
||||
|
||||
Maat_set_scan_status(g_feather, &mid, MAAT_SET_SCAN_LAST_REGION, NULL, 0);
|
||||
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, string_should_not_hit, strlen(string_should_not_hit),
|
||||
result,found_pos, 4, &mid, 0);
|
||||
ret=Maat_full_scan_string(g_feather, table_id, CHARSET_GBK, string_should_not_hit, strlen(string_should_not_hit),
|
||||
result, found_pos, 4, &mid, 0);
|
||||
|
||||
EXPECT_EQ(ret, -2);
|
||||
Maat_clean_status(&mid);
|
||||
@@ -1124,7 +1130,7 @@ TEST(Policy, SubGroup)
|
||||
{
|
||||
#define TestSubGroup
|
||||
int ret=0, table_id=0;
|
||||
const char* scan_string="ceshi3@mailhost.cn";
|
||||
const char* scan_string="ceshi6@mailhost.cn";
|
||||
struct Maat_rule_t result[4];
|
||||
memset(result, 0, sizeof(result));
|
||||
|
||||
@@ -1141,14 +1147,14 @@ TEST(Policy, SubGroup)
|
||||
table_id=Maat_table_register(g_feather,"MAIL_ADDR");
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
ret=Maat_full_scan_string(g_feather, table_id,CHARSET_GBK, scan_string, strlen(scan_string),
|
||||
ret=Maat_full_scan_string(g_feather, table_id, CHARSET_GBK, scan_string, strlen(scan_string),
|
||||
result,NULL, 4, &mid, 0);
|
||||
EXPECT_EQ(ret, -2);
|
||||
|
||||
table_id=Maat_table_register(g_feather, "IP_CONFIG");
|
||||
ASSERT_GT(table_id, 0);
|
||||
|
||||
ret=Maat_scan_proto_addr(g_feather,table_id,&ipv4_addr,6,result,4, &mid,0);
|
||||
ret=Maat_scan_proto_addr(g_feather, table_id, &ipv4_addr, 6, result, 4, &mid,0);
|
||||
|
||||
EXPECT_EQ(ret, 1);
|
||||
EXPECT_EQ(result[0].config_id, 153);
|
||||
|
||||
Reference in New Issue
Block a user