增加L7 protocol识别结果通知更新的测试用例
This commit is contained in:
@@ -250,9 +250,20 @@ extern "C" int ftp_control_identify(struct streaminfo *a_tcp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int g_gtest_ftp_data_flag=0;
|
||||
void gtest_set_ftp_data_flag(void)
|
||||
{
|
||||
g_gtest_ftp_data_flag=1;
|
||||
}
|
||||
|
||||
void gtest_clean_ftp_data_flag(void)
|
||||
{
|
||||
g_gtest_ftp_data_flag=0;
|
||||
}
|
||||
|
||||
extern "C" int ftp_data_identify(struct streaminfo *a_tcp)
|
||||
{
|
||||
return 0;
|
||||
return g_gtest_ftp_data_flag;
|
||||
}
|
||||
|
||||
extern "C" int mail_protocol_identify_by_first_payload(struct streaminfo *a_tcp, char *payload, int payload_len, int thread_seq)
|
||||
|
||||
@@ -9,4 +9,8 @@ int TLD_convert_json(struct TLD_handle_t *_handle, char *buff, unsigned int buff
|
||||
int set_app_id(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, const struct streaminfo *a_stream);
|
||||
int set_shaping_rule_ids(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, const struct streaminfo *a_stream);
|
||||
|
||||
void gtest_set_ftp_data_flag(void);
|
||||
void gtest_clean_ftp_data_flag(void);
|
||||
extern "C" int ftp_data_identify(struct streaminfo *a_tcp);
|
||||
|
||||
|
||||
|
||||
@@ -968,6 +968,40 @@ TEST(TSGMaster, ShapingPolicySendLog)
|
||||
EXPECT_EQ(nullptr, hited_shaping);
|
||||
}
|
||||
|
||||
extern size_t session_pending_state_deal(const struct streaminfo *a_stream, struct session_runtime_process_context *srt_process_context, struct maat_rule *results, int n_results, void *a_packet);
|
||||
|
||||
TEST(TSGMaster, SessionDealStatePending)
|
||||
{
|
||||
struct streaminfo a_stream={0};
|
||||
struct tcpdetail pdetail={0};
|
||||
a_stream.type=STREAM_TYPE_TCP;
|
||||
a_stream.ptcpdetail=&pdetail;
|
||||
|
||||
struct maat_rule matched_rules[MAX_RESULT_NUM]={0};
|
||||
struct session_runtime_process_context srt_process_context={0};
|
||||
|
||||
gtest_set_ftp_data_flag();
|
||||
|
||||
size_t n_matched_rules=session_pending_state_deal((const struct streaminfo *)&a_stream, &srt_process_context, matched_rules, MAX_RESULT_NUM, NULL);
|
||||
EXPECT_EQ(0, n_matched_rules);
|
||||
EXPECT_EQ(PROTO_FTP, srt_process_context.proto);
|
||||
|
||||
struct gather_app_result *gather_result=(struct gather_app_result *)session_gather_app_results_get(&a_stream);
|
||||
EXPECT_NE(nullptr, gather_result);
|
||||
|
||||
EXPECT_EQ(1, gather_result[ORIGIN_BASIC_PROTOCOL].app_num);
|
||||
EXPECT_EQ(45, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id);
|
||||
EXPECT_EQ(0, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].surrogate_id);
|
||||
|
||||
free(gather_result);
|
||||
session_gather_app_results_async(&a_stream, NULL);
|
||||
EXPECT_EQ(nullptr, session_gather_app_results_get(&a_stream));
|
||||
|
||||
gtest_clean_ftp_data_flag();
|
||||
EXPECT_EQ(0, ftp_data_identify(&a_stream));
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
TSG_MASTER_INIT();
|
||||
|
||||
@@ -19,9 +19,20 @@ extern "C" int ftp_control_identify(struct streaminfo *a_tcp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int g_gtest_ftp_data_flag=0;
|
||||
void gtest_set_ftp_data_flag(void)
|
||||
{
|
||||
g_gtest_ftp_data_flag=1;
|
||||
}
|
||||
|
||||
void gtest_clean_ftp_data_flag(void)
|
||||
{
|
||||
g_gtest_ftp_data_flag=0;
|
||||
}
|
||||
|
||||
extern "C" int ftp_data_identify(struct streaminfo *a_tcp)
|
||||
{
|
||||
return 0;
|
||||
return g_gtest_ftp_data_flag;
|
||||
}
|
||||
|
||||
extern "C" int mail_protocol_identify_by_first_payload(struct streaminfo *a_tcp, char *payload, int payload_len, int thread_seq)
|
||||
|
||||
Reference in New Issue
Block a user