]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/http: new DOH tests for GET
authorIvana Krumlová <ivana.krumlova@nic.cz>
Fri, 21 Jun 2019 12:09:07 +0000 (14:09 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Tue, 25 Jun 2019 11:01:54 +0000 (11:01 +0000)
modules/http/http_doh.test.lua

index 90a39d03a0432ff2fba853a3a641e62e2e1548f9..00238b8d7bb745e050cf8bc97e2c68eb5ac05c85 100644 (file)
@@ -254,6 +254,42 @@ else
                same(pkt:ancount(), 2, desc .. ': ANSWER contains both RRs')
        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_unparseble_get()
+                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', 'unparseble GET finishes with 400')
+        end
+
+        local function test_get_other_params()
+                local desc = 'valid GET query with other parameters than dns finishes with 200'
+                local req = req_templ:clone()
+                req.headers:upsert(':method', 'GET')
+                req.headers:upsert(':path', '/doh?other=something&dns=vMEBAAABAAAAAAAAB25vZXJyb3IEdGVzdAAAAQAB&another=something')
+                local headers, pkt = check_ok(req, desc)
+        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
+
 --     not implemented
 --     local function test_post_unsupp_accept()
 --             local req = assert(req_templ:clone())
@@ -277,7 +313,12 @@ else
                test_doh_noerror,
                test_dstaddr,
                test_srcaddr,
-               test_huge_answer
+               test_huge_answer,
+               test_get_no_dns_param,
+               test_unparseble_get,
+               test_get_other_params,
+               test_get_invalid_b64,
+               test_get_invalid_chars
        }
 
        return tests