From 302f5d5bd67ab7397950420d3d51aef3e411d93a Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 24 May 2019 18:28:49 +0000 Subject: [PATCH] http.lua tests using gzip will fail unless zlib is available. --- nselib/http.lua | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/nselib/http.lua b/nselib/http.lua index 49f0d5595..9cad906e7 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -3159,14 +3159,25 @@ do decoded = {"identity"}, undecoded = {"mystery", "miracle"} }) - table.insert(content_encoding_tests, - { name = "stacked encoding", - encoding = "identity, gzip, identity", - source = stdnse.fromhex("1f8b0800000000000000f348cdc9c9d75108cf2fca49510400d0c34aec0d000000"), - target = "Hello, World!", - decoded = {"identity", "gzip", "identity"}, - undecoded = {} - }) + if have_zlib then + table.insert(content_encoding_tests, + { name = "stacked encoding", + encoding = "identity, gzip, identity", + source = stdnse.fromhex("1f8b0800000000000000f348cdc9c9d75108cf2fca49510400d0c34aec0d000000"), + target = "Hello, World!", + decoded = {"identity", "gzip", "identity"}, + undecoded = {} + }) + else + table.insert(content_encoding_tests, + { name = "stacked encoding", + encoding = "identity, gzip, identity", + source = stdnse.fromhex("1f8b0800000000000000f348cdc9c9d75108cf2fca49510400d0c34aec0d000000"), + target = stdnse.fromhex("1f8b0800000000000000f348cdc9c9d75108cf2fca49510400d0c34aec0d000000"), + decoded = {"identity"}, + undecoded = {"gzip", "identity"}, + }) + end for _, test in ipairs(content_encoding_tests) do local body, dcd, undcd, err, fragment = decode_body(test.source, test.encoding, test.maxlen) test_suite:add_test(unittest.equal(body, test.target), test.name .. " (body)")