From: Vsevolod Stakhov Date: Mon, 25 Apr 2016 09:09:56 +0000 (+0100) Subject: [Test] Add more tests for smtp address X-Git-Tag: 1.3.0~639 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a8ed49768138129c1d4f92e1adae5803219b21cb;p=rspamd.git [Test] Add more tests for smtp address --- 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', + '', + '', + '', + '>', + '<>', + } + + 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)