mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Add test for gzip compression in share mode
This commit is contained in:
parent
e434c0463c
commit
32bb224d20
@ -58,6 +58,13 @@ class GuiBaseTest(unittest.TestCase):
|
|||||||
"<html><body><p>This is a test website hosted by OnionShare</p></body></html>"
|
"<html><body><p>This is a test website hosted by OnionShare</p></body></html>"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# A file called "test.html"
|
||||||
|
cls.tmpfile_test_html = os.path.join(cls.tmpdir.name, "test.html")
|
||||||
|
with open(cls.tmpfile_test_html, "w") as file:
|
||||||
|
file.write(
|
||||||
|
"<html><body><p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p></body></html>"
|
||||||
|
)
|
||||||
|
|
||||||
# A large file
|
# A large file
|
||||||
size = 1024 * 1024 * 155
|
size = 1024 * 1024 * 155
|
||||||
cls.tmpfile_large = os.path.join(cls.tmpdir.name, "large_file")
|
cls.tmpfile_large = os.path.join(cls.tmpdir.name, "large_file")
|
||||||
|
@ -541,3 +541,30 @@ class TestShare(GuiBaseTest):
|
|||||||
self.hit_405(url, expected_resp="OnionShare: 405 Method Not Allowed", data = {'foo':'bar'}, methods = ["put", "post", "delete", "options"])
|
self.hit_405(url, expected_resp="OnionShare: 405 Method Not Allowed", data = {'foo':'bar'}, methods = ["put", "post", "delete", "options"])
|
||||||
self.history_widgets_present(tab)
|
self.history_widgets_present(tab)
|
||||||
self.close_all_tabs()
|
self.close_all_tabs()
|
||||||
|
|
||||||
|
|
||||||
|
def test_1_compression(self):
|
||||||
|
"""
|
||||||
|
A file with a compressable mimetype should return a Content-Encoding header
|
||||||
|
with gzip compression enabled.
|
||||||
|
"""
|
||||||
|
tab = self.new_share_tab()
|
||||||
|
tab.get_mode().autostop_sharing_checkbox.click()
|
||||||
|
|
||||||
|
self.run_all_common_setup_tests()
|
||||||
|
self.run_all_share_mode_setup_tests(tab)
|
||||||
|
tab.get_mode().mode_settings_widget.public_checkbox.click()
|
||||||
|
tab.get_mode().remove_all_button.click()
|
||||||
|
tab.get_mode().server_status.file_selection.file_list.add_file(
|
||||||
|
self.tmpfile_test_html
|
||||||
|
)
|
||||||
|
self.run_all_share_mode_started_tests(tab)
|
||||||
|
url = f"http://127.0.0.1:{tab.app.port}/test.html"
|
||||||
|
r = requests.get(url)
|
||||||
|
self.assertTrue("Content-Encoding" in r.headers)
|
||||||
|
self.assertEqual("gzip", r.headers["Content-Encoding"])
|
||||||
|
|
||||||
|
self.server_is_stopped(tab)
|
||||||
|
self.web_server_is_stopped(tab)
|
||||||
|
self.server_status_indicator_says_closed(tab)
|
||||||
|
self.close_all_tabs()
|
||||||
|
Loading…
Reference in New Issue
Block a user