]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add test for recipient parsing sanity 809/head
authorAndrew Lewis <nerf@judo.za.org>
Thu, 4 Aug 2016 15:18:19 +0000 (16:18 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Thu, 4 Aug 2016 16:10:39 +0000 (17:10 +0100)
test/functional/cases/101_lua.robot
test/functional/lua/recipients.lua [new file with mode: 0644]

index 81c08ceee04d53e7bf84c41235c45dd5a865ffc2..9c03456884e3e61c6bf0d61bb49e0d3181526ef6 100644 (file)
@@ -28,6 +28,12 @@ Pre and Post Filters
   Check Rspamc  ${result}  TEST_PRE
   Should Contain  ${result.stdout}  TEST_POST
 
+Recipient Parsing Sanity
+  [Setup]  Lua Setup  ${TESTDIR}/lua/recipients.lua
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  -r  rcpt1@foobar  -r  rcpt2@foobar
+  ...  -r  rcpt3@foobar  -r  rcpt4@foobar
+  Check Rspamc  ${result}  TEST_RCPT[rcpt1@foobar,rcpt2@foobar,rcpt3@foobar,rcpt4@foobar]
+
 *** Keywords ***
 Lua Setup
   [Arguments]  ${LUA_SCRIPT}
diff --git a/test/functional/lua/recipients.lua b/test/functional/lua/recipients.lua
new file mode 100644 (file)
index 0000000..f11c1a8
--- /dev/null
@@ -0,0 +1,14 @@
+rspamd_config:register_symbol({
+  name = 'TEST_RCPT',
+  score = 1.0,
+  callback = function(task)
+    local l = {}
+    local rcpts = task:get_recipients(1)
+    for _, r in ipairs(rcpts) do
+      table.insert(l, r['addr'])
+    end
+    table.sort(l)
+    local t = table.concat(l, ",")
+    return true, t
+  end
+})