Browse Source

[Test] Add unit test

pull/4887/head
Vsevolod Stakhov 1 month ago
parent
commit
417cdf6aa3
No account linked to committer's email address
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      test/lua/unit/url.lua

+ 11
- 0
test/lua/unit/url.lua View File

@@ -250,4 +250,15 @@ context("URL check functions", function()
assert_equal(v[2], res, 'expected ' .. v[2] .. ' but got ' .. res .. ' in url ' .. v[1])
end)
end

test("URL regexp issue", function()
local rspamd_regexp = require "rspamd_regexp"
local u = url.create(pool,
'https://cls21.bullhornstaffing.com/MailerUnsubscribe.cfm?privateLabelID=3D26028&email=xpto&updKey=3D%3B%28U%2B%2F%200T%3EI%3B%2FQEI%5E%29%25XR%3FZ%40%5B%2EGJY%3CF%23%3F%25%22%29%5D%2D%0A')
assert_not_nil(u, "we are able to parse url")
local re = rspamd_regexp.create_cached("^$|^[?].*|^[#].*|[^#?]+")
assert_not_nil(re, "regexp is valid")
local res = re:search('/' .. u:get_path() .. '?' .. u:get_query())
assert_equal(res[#res], '')
end)
end)

Loading…
Cancel
Save