From: Tomas Krizek Date: Fri, 2 Oct 2020 08:07:07 +0000 (+0200) Subject: luacheck: comment out unused code and variables X-Git-Tag: v5.2.0~15^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c25717a93a0c53a6200a3d10d141535a75e304a;p=thirdparty%2Fknot-resolver.git luacheck: comment out unused code and variables --- diff --git a/tests/config/doh2.test.lua b/tests/config/doh2.test.lua index 80e76ec5b..79b051df2 100644 --- a/tests/config/doh2.test.lua +++ b/tests/config/doh2.test.lua @@ -62,20 +62,19 @@ local function check_ok(req, desc) return headers, pkt end -local function check_err(req, exp_status, desc) - local headers, errmsg, errno = req:go(8) -- randomly chosen timeout by tkrizek - if errno then - nok(errmsg, desc .. ': ' .. errmsg) - return - end - local got_status = headers:get(':status') - same(got_status, exp_status, desc) -end +--local function check_err(req, exp_status, desc) +-- local headers, errmsg, errno = req:go(8) -- randomly chosen timeout by tkrizek +-- if errno then +-- nok(errmsg, desc .. ': ' .. errmsg) +-- return +-- end +-- local got_status = headers:get(':status') +-- same(got_status, exp_status, desc) +--end -- check prerequisites -local bound +local bound, port local host = '127.0.0.1' -local port for _ = 1,10 do port = math.random(30000, 39999) bound = pcall(net.listen, host, port, { kind = 'doh2'}) @@ -92,7 +91,7 @@ else policy.add(policy.suffix(policy.DENY, policy.todnames({'nxdomain.test.'}))) policy.add(policy.suffix(gen_varying_ttls, policy.todnames({'noerror.test.'}))) - local _, req_templ, uri_templ + local req_templ, uri_templ local function start_server() local request = require('http.request') local ssl_ctx = require('openssl.ssl.context') @@ -168,34 +167,34 @@ else end -- test an invalid DNS query using POST - local function test_post_short_input() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'POST') - req:set_body(string.rep('0', 11)) -- 11 bytes < DNS msg header - check_err(req, '400', 'too short POST finishes with 400') - end - - local function test_post_long_input() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'POST') - req:set_body(string.rep('s', 1025)) -- > DNS msg over UDP - check_err(req, '413', 'too long POST finishes with 413') - end - - local function test_post_unparseable_input() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'POST') - req:set_body(string.rep('\0', 1024)) -- garbage - check_err(req, '400', 'unparseable DNS message finishes with 400') - end - - local function test_post_unsupp_type() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'POST') - req.headers:upsert('content-type', 'application/dns+json') - req:set_body(string.rep('\0', 12)) -- valid message - check_err(req, '415', 'unsupported request content type finishes with 415') - end +-- local function test_post_short_input() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'POST') +-- req:set_body(string.rep('0', 11)) -- 11 bytes < DNS msg header +-- check_err(req, '400', 'too short POST finishes with 400') +-- end +-- +-- local function test_post_long_input() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'POST') +-- req:set_body(string.rep('s', 1025)) -- > DNS msg over UDP +-- check_err(req, '413', 'too long POST finishes with 413') +-- end +-- +-- local function test_post_unparseable_input() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'POST') +-- req:set_body(string.rep('\0', 1024)) -- garbage +-- check_err(req, '400', 'unparseable DNS message finishes with 400') +-- end +-- +-- local function test_post_unsupp_type() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'POST') +-- req.headers:upsert('content-type', 'application/dns+json') +-- req:set_body(string.rep('\0', 12)) -- valid message +-- check_err(req, '415', 'unsupported request content type finishes with 415') +-- end -- test a valid DNS query using GET local function test_get_servfail() @@ -273,47 +272,47 @@ else check_ok(req, desc) end - -- test an invalid DNS query using GET - local function test_get_long_input() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'GET') - req.headers:upsert(':path', '/doh?dns=' .. basexx.to_url64(string.rep('\0', 1030))) - check_err(req, '414', 'too long GET finishes with 414') - end - - local function test_get_no_dns_param() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'GET') - req.headers:upsert(':path', '/doh?notdns=' .. basexx.to_url64(string.rep('\0', 1024))) - check_err(req, '400', 'GET without dns paramter finishes with 400') - end - - local function test_get_unparseable() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'GET') - req.headers:upsert(':path', '/doh??dns=' .. basexx.to_url64(string.rep('\0', 1024))) - check_err(req, '400', 'unparseable GET finishes with 400') - end - - local function test_get_invalid_b64() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'GET') - req.headers:upsert(':path', '/doh?dns=thisisnotb64') - check_err(req, '400', 'GET with invalid base64 finishes with 400') - end - - local function test_get_invalid_chars() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'GET') - req.headers:upsert(':path', '/doh?dns=' .. basexx.to_url64(string.rep('\0', 200)) .. '@#$%?!') - check_err(req, '400', 'GET with invalid characters in b64 finishes with 400') - end - - local function test_unsupp_method() - local req = assert(req_templ:clone()) - req.headers:upsert(':method', 'PUT') - check_err(req, '405', 'unsupported method finishes with 405') - end +-- -- test an invalid DNS query using GET +-- local function test_get_long_input() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'GET') +-- req.headers:upsert(':path', '/doh?dns=' .. basexx.to_url64(string.rep('\0', 1030))) +-- check_err(req, '414', 'too long GET finishes with 414') +-- end +-- +-- local function test_get_no_dns_param() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'GET') +-- req.headers:upsert(':path', '/doh?notdns=' .. basexx.to_url64(string.rep('\0', 1024))) +-- check_err(req, '400', 'GET without dns paramter finishes with 400') +-- end +-- +-- local function test_get_unparseable() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'GET') +-- req.headers:upsert(':path', '/doh??dns=' .. basexx.to_url64(string.rep('\0', 1024))) +-- check_err(req, '400', 'unparseable GET finishes with 400') +-- end +-- +-- local function test_get_invalid_b64() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'GET') +-- req.headers:upsert(':path', '/doh?dns=thisisnotb64') +-- check_err(req, '400', 'GET with invalid base64 finishes with 400') +-- end +-- +-- local function test_get_invalid_chars() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'GET') +-- req.headers:upsert(':path', '/doh?dns=' .. basexx.to_url64(string.rep('\0', 200)) .. '@#$%?!') +-- check_err(req, '400', 'GET with invalid characters in b64 finishes with 400') +-- end +-- +-- local function test_unsupp_method() +-- local req = assert(req_templ:clone()) +-- req.headers:upsert(':method', 'PUT') +-- check_err(req, '405', 'unsupported method finishes with 405') +-- end local function test_dstaddr() local triggered = false