diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-20 17:14:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-20 17:14:40 +0100 |
commit | 094548aeed552bc3b07fd68d9d5f934da120c399 (patch) | |
tree | dc457131ad2e4100c829c81ed86c3f4063745297 /test | |
parent | 08cac423a07cb10ba57c4aaf9e3796a5a4115ef9 (diff) | |
parent | 68be6b0567d582b7f1818cccada4a0623b3e0844 (diff) | |
download | rspamd-094548aeed552bc3b07fd68d9d5f934da120c399.tar.gz rspamd-094548aeed552bc3b07fd68d9d5f934da120c399.zip |
Merge pull request #2510 from negram/more-test
[Test] more tests
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/unit/selectors.lua | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/test/lua/unit/selectors.lua b/test/lua/unit/selectors.lua index 2205bbc3f..5454f35d4 100644 --- a/test/lua/unit/selectors.lua +++ b/test/lua/unit/selectors.lua @@ -24,6 +24,7 @@ context("Selectors test", function() task:set_from_ip("198.172.22.91") task:set_user("cool user name") task:set_helo("hello mail") + task:set_request_header("hdr1", "value1") task:process_message() task:get_mempool():set_variable("int_var", 1) task:get_mempool():set_variable("str_var", "str 1") @@ -65,7 +66,7 @@ context("Selectors test", function() ["digest"] = { selector = "digest", - expect = {"843186d5d1f518fd7de17c13c114bb26"}}, + expect = {"2216397bc061bb6968e1836f3680fed0"}}, ["user"] = { selector = "user", @@ -80,45 +81,54 @@ context("Selectors test", function() expect = {{"nobody@example.com", "no-one@example.com"}}}, ["1st rcpts"] = { - selector = "rcpts.nth(1)", + selector = "rcpts.nth(1)", + expect = {"nobody@example.com"}}, + + ["lower rcpts"] = { + selector = "rcpts.lower.first", expect = {"nobody@example.com"}}, ["first rcpts"] = { selector = "rcpts.first", expect = {"nobody@example.com"}}, + ["first addr rcpts"] = { + selector = "rcpts:addr.first", + expect = {"nobody@example.com"}}, + ["to"] = { selector = "to", expect = {"nobody@example.com"}}, ["attachments"] = { - selector = "attachments", + selector = "attachments", expect = {{"ce112d07c52ae649f9646f3d0b5aaab5d4834836d771c032d1a75059d31fed84f38e00c0b205918f6d354934c2055d33d19d045f783a62561f467728ebcf0160", "ce112d07c52ae649f9646f3d0b5aaab5d4834836d771c032d1a75059d31fed84f38e00c0b205918f6d354934c2055d33d19d045f783a62561f467728ebcf0160" }}}, ["attachments id"] = { - selector = "attachments.id", + selector = "attachments.id", expect = {""}}, ["files"] = { - selector = "files", + selector = "files", expect = {{"f.zip", "f2.zip"}}}, ["helo"] = { selector = "helo", expect = {"hello mail"}}, ---[[ - Received is a complicated structure: should be tested separately - ["received"] = { - selector = "received", - expect = {}, --- ]] + + ["received by hostname"] = { + selector = "received:by_hostname", + expect = {{"server.chat-met-vreemden.nl"}}}, ["urls"] = { selector = "urls", expect = {{"http://example.net"}}}, + ["emails"] = { + selector = "emails", + expect = {{"mailto://test@example.net"}}}, ["pool_var str, default type"] = { selector = [[pool_var("str_var")]], @@ -136,6 +146,9 @@ context("Selectors test", function() selector = "time", expect = {"1537364211"}}, + ["request_header"] = { + selector = "request_header(hdr1)", + expect = {"value1"}}, } for case_name, case in pairs(cases) do @@ -174,6 +187,7 @@ Content-Type: text/html; charset="utf-8" <html><body> <a href="http://example.net">http://example.net</a> +<a href="mailto:test@example.net">mail me</a> </html> |