summaryrefslogtreecommitdiff
path: root/test/src/gtest_master.cpp
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2023-06-06 17:07:59 +0800
committerliuxueli <[email protected]>2023-06-06 17:07:59 +0800
commit78f9aa6601f8f09979b8001397526d0f33b7a36b (patch)
treeb5757bf48b07bf78471de3aaf0ce659903eedc1e /test/src/gtest_master.cpp
parent4c8eecdb414b6fb2897cd628acb7bbcfc19c1556 (diff)
增加L7 protocol识别结果通知更新的测试用例
Diffstat (limited to 'test/src/gtest_master.cpp')
-rw-r--r--test/src/gtest_master.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/src/gtest_master.cpp b/test/src/gtest_master.cpp
index 90febc9..cd95e95 100644
--- a/test/src/gtest_master.cpp
+++ b/test/src/gtest_master.cpp
@@ -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();