diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-25 10:09:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-25 10:09:56 +0100 |
commit | a8ed49768138129c1d4f92e1adae5803219b21cb (patch) | |
tree | 03d086ee62148ff8cd6105d2f8e618bb0ab96a6f /test/lua | |
parent | 123cc06dc7d18a7afa37bbcd37fa0019941fee8a (diff) | |
download | rspamd-a8ed49768138129c1d4f92e1adae5803219b21cb.tar.gz rspamd-a8ed49768138129c1d4f92e1adae5803219b21cb.zip |
[Test] Add more tests for smtp address
Diffstat (limited to 'test/lua')
-rw-r--r-- | test/lua/unit/smtp_addr.lua | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/test/lua/unit/smtp_addr.lua b/test/lua/unit/smtp_addr.lua index c221950c5..32b67afe1 100644 --- a/test/lua/unit/smtp_addr.lua +++ b/test/lua/unit/smtp_addr.lua @@ -31,12 +31,17 @@ context("SMTP address check functions", function() {'a+b@example.com', {user = 'a+b', domain = 'example.com', addr = 'a+b@example.com'}}, {'"a"@example.com', {user = 'a', domain = 'example.com', addr = 'a@example.com'}}, {'"a+b"@example.com', {user = 'a+b', domain = 'example.com', addr = 'a+b@example.com'}}, + {'"<>"@example.com', {user = '<>', domain = 'example.com', addr = '<>@example.com'}}, + {'<"<>"@example.com>', {user = '<>', domain = 'example.com', addr = '<>@example.com'}}, + {'"\\""@example.com', {user = '"', domain = 'example.com', addr = '"@example.com'}}, + {'"\\"abc"@example.com', {user = '"abc', domain = 'example.com', addr = '"abc@example.com'}}, + } each(function(case) local st = ffi.C.rspamd_email_address_from_smtp(case[1], #case[1]) - assert_not_nil(st, "cannot parse " .. case[1]) + assert_not_nil(st, "should be able to parse " .. case[1]) each(function(k, ex) if k == 'user' then @@ -52,5 +57,24 @@ context("SMTP address check functions", function() end, case[2]) ffi.C.rspamd_email_address_unref(st) end, cases_valid) + + local cases_invalid = { + 'a', + 'a"b"@example.com', + 'a"@example.com', + '"a@example.com', + '<a@example.com', + 'a@example.com>', + '<a@.example.com>', + '<a@example.com.>', + '<a@example.com>>', + '<a@example.com><>', + } + + each(function(case) + local st = ffi.C.rspamd_email_address_from_smtp(case, #case) + + assert_nil(st, "should not be able to parse " .. case) + end, cases_invalid) end) end) |