diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-07-27 16:24:54 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-07-27 16:24:54 +0100 |
commit | 42f020ce8678983ed0f77f408235d082a9a76cbd (patch) | |
tree | ecb3799529493c4ad484d0d39e90c3db00661f71 /test/lua | |
parent | f042f98099e3f53dcabf30f03507a71de6f07bdf (diff) | |
download | rspamd-42f020ce8678983ed0f77f408235d082a9a76cbd.tar.gz rspamd-42f020ce8678983ed0f77f408235d082a9a76cbd.zip |
[Test] Fix received tests
Diffstat (limited to 'test/lua')
-rw-r--r-- | test/lua/unit/received.lua | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/test/lua/unit/received.lua b/test/lua/unit/received.lua index 908c1904e..606424363 100644 --- a/test/lua/unit/received.lua +++ b/test/lua/unit/received.lua @@ -6,18 +6,18 @@ context("Received headers parser", function() ffi.cdef[[ struct received_header { - char *from_hostname; - char *from_ip; - char *real_hostname; - char *real_ip; - char *by_hostname; - char *for_mbox; - char *comment_ip; + const char *from_hostname; + const char *from_ip; + const char *real_hostname; + const char *real_ip; + const char *by_hostname; + const char *for_mbox; + void *for_addr; void *addr; void *hdr; long timestamp; - int type; - int flags; + int flags; /* See enum rspamd_received_type */ + struct received_header *prev, *next; }; struct rspamd_task * rspamd_task_new(struct rspamd_worker *worker, struct rspamd_config *cfg); int rspamd_smtp_received_parse (struct rspamd_task *task, @@ -115,6 +115,7 @@ context("Received headers parser", function() from_ip = '65.19.167.131', real_ip = '65.19.167.131', by_hostname = 'mail01.someotherdomain.org', + ['for'] = 'user2@somedomain.com', } }, {[[from example.com ([]) by example.com with ESMTP id 2019091111 ; Thu, 26 Sep 2019 11:19:07 +0200]], @@ -122,7 +123,7 @@ context("Received headers parser", function() by_hostname = 'example.com', }, }, - {[[from 171-29.br (1-1-1-1.z.com.br [1.1.1.1]) by x.com.br (Postfix) with;ESMTP id 44QShF6xj4z1X for <y.br>; Thu, 21 Mar 2019 23:45:46 -0300 : <g @yi.br>]], + {[[from 171-29.br (1-1-1-1.z.com.br [1.1.1.1]) by x.com.br (Postfix) with;ESMTP id 44QShF6xj4z1X for <hey@y.br>; Thu, 21 Mar 2019 23:45:46 -0300 : <g @yi.br>]], { from_hostname = '171-29.br', real_ip = '1.1.1.1', @@ -199,6 +200,16 @@ context("Received headers parser", function() string.format('%s: by_hostname: %s, expected: nil', c[1], ffi_string(hdr.by_hostname))) end + elseif k == 'for' then + if #v > 0 then + assert_equal(v, ffi_string(hdr['for_mbox']), + string.format('%s: for: %s, expected: %s', + c[1], ffi_string(hdr['for_mbox']), v)) + else + assert_nil(hdr['for_mbox'], + string.format('%s: for: %s, expected: nil', + c[1], ffi_string(hdr['for_mbox']))) + end end end end) |