From d24e9fbc3570eec721d9e0c678c28352197f7484 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 9 Jun 2019 09:51:58 +0100 Subject: [PATCH] [Test] Improve address parsing unit tests --- test/lua/unit/addr.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/lua/unit/addr.lua b/test/lua/unit/addr.lua index 03ceb2dbd..a021b1cba 100644 --- a/test/lua/unit/addr.lua +++ b/test/lua/unit/addr.lua @@ -18,10 +18,22 @@ context("Inet addr check functions", function() {'./socket', true}, {'[fe80::f919:8b26:ff93:3092%5]', true}, {'[fe80::f919:8b26:ff93:3092]', true}, + {'IPv6:::1', true}, + {'IPv6:[::1]', true}, + {'IPv6[:::1]', false}, + {'[::]', true}, + {'[1::]', true}, + {'[000:01:02:003:004:5:6:007]', true}, -- leading zeros + {'[A:b:c:DE:fF:0:1:aC]', true}, -- mixed case + {'[::192.168.0.1]', true}, -- embedded ipv4 + {'[1:2:192.168.0.1:5:6]', false}, -- poor octets + {'[::ffff:192.1.2]', false}, -- ipv4 without last octet (maybe should be true?) + {'[0:0::0:0:8]', true}, -- bogus zeros + {'[::192.168.0.0.1]', false}, -- invalid mapping } for i,c in ipairs(cases) do - test("Create inet addr from string " .. i, function() + test("Create inet addr from string " .. c[1] .. '; expect ' .. tostring(c[2]), function() local ip = ffi.new("rspamd_inet_addr_t* [1]"); local res = ffi.C.rspamd_parse_inet_address(ip, c[1]) assert_equal(res, c[2], "Expect " .. tostring(c[2]) .. " while parsing " .. c[1]) -- 2.39.5