aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-07-09 20:45:19 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-07-09 20:45:19 +0100
commit1335e6359797e4e3fa1a6590b407d92281686c8e (patch)
tree24a118ff605dc658798bab52261feb8e83dbf4a7 /test
parent41d4dbca113d696d5628f071869d18834d419733 (diff)
downloadrspamd-1335e6359797e4e3fa1a6590b407d92281686c8e.tar.gz
rspamd-1335e6359797e4e3fa1a6590b407d92281686c8e.zip
[Test] Add unit test for keepalive timeout parsing
Diffstat (limited to 'test')
-rw-r--r--test/rspamd_cxx_unit_utils.hxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/rspamd_cxx_unit_utils.hxx b/test/rspamd_cxx_unit_utils.hxx
index c85315379..602b32a7e 100644
--- a/test/rspamd_cxx_unit_utils.hxx
+++ b/test/rspamd_cxx_unit_utils.hxx
@@ -28,6 +28,8 @@
#include <utility>
#include <string>
+extern "C" long rspamd_http_parse_keepalive_timeout (const rspamd_ftok_t *tok);
+
TEST_SUITE("rspamd_utils") {
TEST_CASE("rspamd_strip_smtp_comments_inplace")
@@ -58,6 +60,30 @@ TEST_CASE("rspamd_strip_smtp_comments_inplace")
}
}
+TEST_CASE("rspamd_http_parse_keepalive_timeout")
+{
+ std::vector<std::pair<std::string, long>> cases {
+ {"timeout=5, max=1000", 5},
+ {"max=1000, timeout=5", 5},
+ {"max=1000, timeout=", -1},
+ {"max=1000, timeout=0", 0},
+ {"max=1000, timeout=-5", -1},
+ {"timeout=5", 5},
+ {" timeout=5; ", 5},
+ {"timeout = 5", 5},
+ };
+
+ for (const auto &c : cases) {
+ SUBCASE (("parse http keepalive header " + c.first).c_str()) {
+ rspamd_ftok_t t;
+ t.begin = c.first.data();
+ t.len = c.first.size();
+ auto res = rspamd_http_parse_keepalive_timeout(&t);
+ CHECK(res == c.second);
+ }
+ }
+}
+
}
#endif