selftest: Add new test for testing non-chunk transfer encoding
authorNoel Power <noel.power@suse.com>
Thu, 28 Mar 2024 09:16:33 +0000 (09:16 +0000)
committerJule Anger <janger@samba.org>
Thu, 11 Apr 2024 11:20:16 +0000 (11:20 +0000)
And add a known fail because there is a bug :-(

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15611
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 93709d31590d4ca25fbac813b9e499755b81ddb5)

python/samba/tests/blackbox/http_chunk.py
selftest/knownfail.d/http_chunk [new file with mode: 0644]

index 150ab2a31538977a7d2b48fd4cf73dd72ff3d854..6745c8cb392ae5c4205f5efb5115bd2e53faceec 100644 (file)
@@ -46,7 +46,10 @@ class ChunkHTTPRequestHandler(BaseHTTPRequestHandler):
 
         self.send_response(200)
         self.send_header('content-type', 'application/json; charset=UTF-8')
-        self.send_header('Transfer-Encoding', 'chunked')
+        if self.path == "usegziptransferencoding":
+            self.send_header('Transfer-Encoding', 'gzip')
+        else:
+            self.send_header('Transfer-Encoding', 'chunked')
         self.end_headers()
         resp = bytes()
         for chunk in chunks:
@@ -114,3 +117,13 @@ class HttpChunkBlackboxTests(BlackboxTestCase):
         except BlackboxProcessError as e:
             print("Failed with: %s" % e)
             self.fail(str(e))
+
+    def test_gzip_transfer_encoding(self):
+        try:
+            msg = "usegziptransferencoding"
+            resp = self.check_output("%s -U%% -I%s --rsize 50 --uri %s" % (COMMAND, os.getenv("SERVER_IP", "localhost"), msg))
+            self.assertEqual(msg, resp.decode('utf-8'))
+            self.fail("unexpected success")
+        except BlackboxProcessError as e:
+            if "http_response_needs_body: Unsupported transfer encoding type gzip" not in e.stderr.decode('utf-8'):
+                self.fail(str(e))
diff --git a/selftest/knownfail.d/http_chunk b/selftest/knownfail.d/http_chunk
new file mode 100644 (file)
index 0000000..9fa71d6
--- /dev/null
@@ -0,0 +1 @@
+^samba.tests.blackbox.http_chunk.samba.tests.blackbox.http_chunk.HttpChunkBlackboxTests.test_gzip_transfer_encoding