summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-05-06 18:06:14 -0700
committerGitHub <noreply@github.com>2019-05-06 18:06:14 -0700
commitbbf6c02da645fcd4fc50db18dd341178ad4fa2e6 (patch)
treec1e2757c56f517e051c9f905f8a7a12e1b8d66ae /tests
parenta8201593ec0bfe7596ef530e80aa30e5172ef71d (diff)
parent9e9c29b189cb91ea495a85ed749730395926e07b (diff)
downloadonionshare-2.1.tar.gz
onionshare-2.1.zip
Merge pull request #980 from micahflee/developv2.1
Version 2.1
Diffstat (limited to 'tests')
-rw-r--r--tests/GuiBaseTest.py45
-rw-r--r--tests/GuiReceiveTest.py27
-rw-r--r--tests/GuiShareTest.py21
-rw-r--r--tests/SettingsGuiBaseTest.py12
-rw-r--r--tests/TorGuiBaseTest.py13
-rw-r--r--tests/TorGuiShareTest.py2
-rw-r--r--tests/local_onionshare_404_public_mode_skips_ratelimit_test.py1
-rw-r--r--tests/local_onionshare_404_triggers_ratelimit_test.py1
-rw-r--r--tests/local_onionshare_quitting_during_share_prompts_warning_test.py1
-rw-r--r--tests/local_onionshare_receive_mode_sender_closed_test.py26
-rw-r--r--tests/local_onionshare_receive_mode_timer_test.py3
-rw-r--r--tests/local_onionshare_receive_mode_upload_non_writable_dir_test.py1
-rw-r--r--tests/local_onionshare_receive_mode_upload_public_mode_non_writable_dir_test.py1
-rw-r--r--tests/local_onionshare_receive_mode_upload_public_mode_test.py1
-rw-r--r--tests/local_onionshare_receive_mode_upload_test.py1
-rw-r--r--tests/local_onionshare_settings_dialog_legacy_tor_test.py1
-rw-r--r--tests/local_onionshare_settings_dialog_no_tor_test.py1
-rw-r--r--tests/local_onionshare_settings_dialog_v3_tor_test.py1
-rw-r--r--tests/local_onionshare_share_mode_autostart_and_autostop_timer_mismatch_test.py28
-rw-r--r--tests/local_onionshare_share_mode_autostart_timer_test.py27
-rw-r--r--tests/local_onionshare_share_mode_autostart_timer_too_short_test.py34
-rw-r--r--tests/local_onionshare_share_mode_cancel_share_test.py27
-rw-r--r--tests/local_onionshare_share_mode_download_public_mode_test.py1
-rw-r--r--tests/local_onionshare_share_mode_download_stay_open_test.py1
-rw-r--r--tests/local_onionshare_share_mode_download_test.py1
-rw-r--r--tests/local_onionshare_share_mode_large_download_test.py1
-rw-r--r--tests/local_onionshare_share_mode_slug_persistent_test.py1
-rw-r--r--tests/local_onionshare_share_mode_timer_test.py3
-rw-r--r--tests/local_onionshare_share_mode_timer_too_short_test.py3
-rw-r--r--tests/local_onionshare_share_mode_unreadable_file_test.py1
-rw-r--r--tests/onionshare_790_cancel_on_second_share_test.py1
-rw-r--r--tests/onionshare_receive_mode_upload_public_mode_test.py1
-rw-r--r--tests/onionshare_receive_mode_upload_test.py1
-rw-r--r--tests/onionshare_share_mode_cancel_share_test.py2
-rw-r--r--tests/onionshare_share_mode_download_public_mode_test.py1
-rw-r--r--tests/onionshare_share_mode_download_stay_open_test.py1
-rw-r--r--tests/onionshare_share_mode_download_test.py1
-rw-r--r--tests/onionshare_share_mode_persistent_test.py1
-rw-r--r--tests/onionshare_share_mode_stealth_test.py1
-rw-r--r--tests/onionshare_share_mode_timer_test.py3
-rw-r--r--tests/onionshare_share_mode_tor_connection_killed_test.py1
-rw-r--r--tests/onionshare_share_mode_v2_onion_test.py1
-rw-r--r--tests/test_onionshare.py3
-rw-r--r--tests/test_onionshare_common.py2
-rw-r--r--tests/test_onionshare_settings.py3
-rw-r--r--tests/test_onionshare_web.py2
46 files changed, 236 insertions, 76 deletions
diff --git a/tests/GuiBaseTest.py b/tests/GuiBaseTest.py
index e4b3d4c9..d3fc9945 100644
--- a/tests/GuiBaseTest.py
+++ b/tests/GuiBaseTest.py
@@ -172,6 +172,9 @@ class GuiBaseTest(object):
'''Test that the Server Status indicator shows we are Starting'''
self.assertEqual(mode.server_status_label.text(), strings._('gui_status_indicator_share_working'))
+ def server_status_indicator_says_scheduled(self, mode):
+ '''Test that the Server Status indicator shows we are Scheduled'''
+ self.assertEqual(mode.server_status_label.text(), strings._('gui_status_indicator_share_scheduled'))
def server_is_started(self, mode, startup_time=2000):
'''Test that the server has started'''
@@ -291,13 +294,12 @@ class GuiBaseTest(object):
def set_timeout(self, mode, timeout):
'''Test that the timeout can be set'''
timer = QtCore.QDateTime.currentDateTime().addSecs(timeout)
- mode.server_status.shutdown_timeout.setDateTime(timer)
- self.assertTrue(mode.server_status.shutdown_timeout.dateTime(), timer)
+ mode.server_status.autostop_timer_widget.setDateTime(timer)
+ self.assertTrue(mode.server_status.autostop_timer_widget.dateTime(), timer)
-
- def timeout_widget_hidden(self, mode):
- '''Test that the timeout widget is hidden when share has started'''
- self.assertFalse(mode.server_status.shutdown_timeout_container.isVisible())
+ def autostop_timer_widget_hidden(self, mode):
+ '''Test that the auto-stop timer widget is hidden when share has started'''
+ self.assertFalse(mode.server_status.autostop_timer_container.isVisible())
def server_timed_out(self, mode, wait):
@@ -306,6 +308,37 @@ class GuiBaseTest(object):
# We should have timed out now
self.assertEqual(mode.server_status.status, 0)
+ # Auto-start timer tests
+ def set_autostart_timer(self, mode, timer):
+ '''Test that the timer can be set'''
+ schedule = QtCore.QDateTime.currentDateTime().addSecs(timer)
+ mode.server_status.autostart_timer_widget.setDateTime(schedule)
+ self.assertTrue(mode.server_status.autostart_timer_widget.dateTime(), schedule)
+
+ def autostart_timer_widget_hidden(self, mode):
+ '''Test that the auto-start timer widget is hidden when share has started'''
+ self.assertFalse(mode.server_status.autostart_timer_container.isVisible())
+
+ def scheduled_service_started(self, mode, wait):
+ '''Test that the server has timed out after the timer ran out'''
+ QtTest.QTest.qWait(wait)
+ # We should have started now
+ self.assertEqual(mode.server_status.status, 2)
+
+ def cancel_the_share(self, mode):
+ '''Test that we can cancel a share before it's started up '''
+ self.server_working_on_start_button_pressed(mode)
+ self.server_status_indicator_says_scheduled(mode)
+ self.add_delete_buttons_hidden()
+ self.settings_button_is_hidden()
+ self.set_autostart_timer(mode, 10)
+ QtTest.QTest.mousePress(mode.server_status.server_button, QtCore.Qt.LeftButton)
+ QtTest.QTest.qWait(2000)
+ QtTest.QTest.mouseRelease(mode.server_status.server_button, QtCore.Qt.LeftButton)
+ self.assertEqual(mode.server_status.status, 0)
+ self.server_is_stopped(mode, False)
+ self.web_server_is_stopped()
+
# Hack to close an Alert dialog that would otherwise block tests
def accept_dialog(self):
window = self.gui.qtapp.activeWindow()
diff --git a/tests/GuiReceiveTest.py b/tests/GuiReceiveTest.py
index 8a03283e..40c3de95 100644
--- a/tests/GuiReceiveTest.py
+++ b/tests/GuiReceiveTest.py
@@ -5,7 +5,7 @@ from PyQt5 import QtCore, QtTest
from .GuiBaseTest import GuiBaseTest
class GuiReceiveTest(GuiBaseTest):
- def upload_file(self, public_mode, file_to_upload, expected_basename):
+ def upload_file(self, public_mode, file_to_upload, expected_basename, identical_files_at_once=False):
'''Test that we can upload the file'''
files = {'file[]': open(file_to_upload, 'rb')}
if not public_mode:
@@ -13,6 +13,9 @@ class GuiReceiveTest(GuiBaseTest):
else:
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
response = requests.post(path, files=files)
+ if identical_files_at_once:
+ # Send a duplicate upload to test for collisions
+ response = requests.post(path, files=files)
QtTest.QTest.qWait(2000)
# Make sure the file is within the last 10 seconds worth of filenames
@@ -20,7 +23,10 @@ class GuiReceiveTest(GuiBaseTest):
now = datetime.now()
for i in range(10):
date_dir = now.strftime("%Y-%m-%d")
- time_dir = now.strftime("%H.%M.%S")
+ if identical_files_at_once:
+ time_dir = now.strftime("%H.%M.%S-1")
+ else:
+ time_dir = now.strftime("%H.%M.%S")
receive_mode_dir = os.path.join(self.gui.common.settings.get('data_dir'), date_dir, time_dir)
expected_filename = os.path.join(receive_mode_dir, expected_basename)
if os.path.exists(expected_filename):
@@ -74,18 +80,6 @@ class GuiReceiveTest(GuiBaseTest):
self.assertEqual(mode.history.completed_count, before_completed_count)
self.assertEqual(len(mode.history.item_list.items), before_number_of_history_items)
- def run_receive_mode_sender_closed_tests(self, public_mode):
- '''Test that the share can be stopped by the sender in receive mode'''
- if not public_mode:
- path = 'http://127.0.0.1:{}/{}/close'.format(self.gui.app.port, self.gui.receive_mode.web.slug)
- else:
- path = 'http://127.0.0.1:{}/close'.format(self.gui.app.port)
- response = requests.post(path)
- self.server_is_stopped(self.gui.receive_mode, False)
- self.web_server_is_stopped()
- self.server_status_indicator_says_closed(self.gui.receive_mode, False)
-
-
# 'Grouped' tests follow from here
def run_all_receive_mode_setup_tests(self, public_mode):
@@ -119,6 +113,9 @@ class GuiReceiveTest(GuiBaseTest):
self.counter_incremented(self.gui.receive_mode, 3)
self.upload_file(public_mode, '/tmp/testdir/test', 'test')
self.counter_incremented(self.gui.receive_mode, 4)
+ # Test uploading the same file twice at the same time, and make sure no collisions
+ self.upload_file(public_mode, '/tmp/test.txt', 'test.txt', True)
+ self.counter_incremented(self.gui.receive_mode, 6)
self.uploading_zero_files_shouldnt_change_ui(self.gui.receive_mode, public_mode)
self.history_indicator(self.gui.receive_mode, public_mode)
self.server_is_stopped(self.gui.receive_mode, False)
@@ -142,6 +139,6 @@ class GuiReceiveTest(GuiBaseTest):
"""Auto-stop timer tests in receive mode"""
self.run_all_receive_mode_setup_tests(public_mode)
self.set_timeout(self.gui.receive_mode, 5)
- self.timeout_widget_hidden(self.gui.receive_mode)
+ self.autostop_timer_widget_hidden(self.gui.receive_mode)
self.server_timed_out(self.gui.receive_mode, 15000)
self.web_server_is_stopped()
diff --git a/tests/GuiShareTest.py b/tests/GuiShareTest.py
index 716bab73..29661712 100644
--- a/tests/GuiShareTest.py
+++ b/tests/GuiShareTest.py
@@ -191,10 +191,29 @@ class GuiShareTest(GuiBaseTest):
self.run_all_share_mode_setup_tests()
self.set_timeout(self.gui.share_mode, 5)
self.run_all_share_mode_started_tests(public_mode)
- self.timeout_widget_hidden(self.gui.share_mode)
+ self.autostop_timer_widget_hidden(self.gui.share_mode)
self.server_timed_out(self.gui.share_mode, 10000)
self.web_server_is_stopped()
+ def run_all_share_mode_autostart_timer_tests(self, public_mode):
+ """Auto-start timer tests in share mode"""
+ self.run_all_share_mode_setup_tests()
+ self.set_autostart_timer(self.gui.share_mode, 5)
+ self.server_working_on_start_button_pressed(self.gui.share_mode)
+ self.autostart_timer_widget_hidden(self.gui.share_mode)
+ self.server_status_indicator_says_scheduled(self.gui.share_mode)
+ self.web_server_is_stopped()
+ self.scheduled_service_started(self.gui.share_mode, 7000)
+ self.web_server_is_running()
+
+ def run_all_share_mode_autostop_autostart_mismatch_tests(self, public_mode):
+ """Auto-stop timer tests in share mode"""
+ self.run_all_share_mode_setup_tests()
+ self.set_autostart_timer(self.gui.share_mode, 15)
+ self.set_timeout(self.gui.share_mode, 5)
+ QtCore.QTimer.singleShot(4000, self.accept_dialog)
+ QtTest.QTest.mouseClick(self.gui.share_mode.server_status.server_button, QtCore.Qt.LeftButton)
+ self.server_is_stopped(self.gui.share_mode, False)
def run_all_share_mode_unreadable_file_tests(self):
'''Attempt to share an unreadable file'''
diff --git a/tests/SettingsGuiBaseTest.py b/tests/SettingsGuiBaseTest.py
index 844a0c86..35bdd9c6 100644
--- a/tests/SettingsGuiBaseTest.py
+++ b/tests/SettingsGuiBaseTest.py
@@ -77,11 +77,11 @@ class SettingsGuiBaseTest(object):
QtTest.QTest.mouseClick(self.gui.public_mode_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.public_mode_checkbox.height()/2))
self.assertTrue(self.gui.public_mode_checkbox.isChecked())
- # shutdown timer is off
- self.assertFalse(self.gui.shutdown_timeout_checkbox.isChecked())
- # enable shutdown timer
- QtTest.QTest.mouseClick(self.gui.shutdown_timeout_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.shutdown_timeout_checkbox.height()/2))
- self.assertTrue(self.gui.shutdown_timeout_checkbox.isChecked())
+ # autostop timer is off
+ self.assertFalse(self.gui.autostop_timer_checkbox.isChecked())
+ # enable autostop timer
+ QtTest.QTest.mouseClick(self.gui.autostop_timer_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.autostop_timer_checkbox.height()/2))
+ self.assertTrue(self.gui.autostop_timer_checkbox.isChecked())
# legacy mode checkbox and related widgets
if self.gui.onion.is_authenticated():
@@ -222,7 +222,7 @@ class SettingsGuiBaseTest(object):
data = json.load(f)
self.assertTrue(data["public_mode"])
- self.assertTrue(data["shutdown_timeout"])
+ self.assertTrue(data["autostop_timer"])
if self.gui.onion.is_authenticated():
if self.gui.onion.supports_v3_onions:
diff --git a/tests/TorGuiBaseTest.py b/tests/TorGuiBaseTest.py
index e437ac93..8bd963bd 100644
--- a/tests/TorGuiBaseTest.py
+++ b/tests/TorGuiBaseTest.py
@@ -140,19 +140,6 @@ class TorGuiBaseTest(GuiBaseTest):
else:
self.assertEqual(clipboard.text(), 'http://{}/{}'.format(self.gui.app.onion_host, mode.server_status.web.slug))
- def cancel_the_share(self, mode):
- '''Test that we can cancel this share before it's started up '''
- self.server_working_on_start_button_pressed(self.gui.share_mode)
- self.server_status_indicator_says_starting(self.gui.share_mode)
- self.add_delete_buttons_hidden()
- self.settings_button_is_hidden()
- QtTest.QTest.mousePress(mode.server_status.server_button, QtCore.Qt.LeftButton)
- QtTest.QTest.qWait(1000)
- QtTest.QTest.mouseRelease(mode.server_status.server_button, QtCore.Qt.LeftButton)
- self.assertEqual(mode.server_status.status, 0)
- self.server_is_stopped(self.gui.share_mode, False)
- self.web_server_is_stopped()
-
# Stealth tests
def copy_have_hidserv_auth_button(self, mode):
diff --git a/tests/TorGuiShareTest.py b/tests/TorGuiShareTest.py
index 53641dce..36efacd1 100644
--- a/tests/TorGuiShareTest.py
+++ b/tests/TorGuiShareTest.py
@@ -89,7 +89,7 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest):
self.run_all_share_mode_setup_tests()
self.set_timeout(self.gui.share_mode, 120)
self.run_all_share_mode_started_tests(public_mode)
- self.timeout_widget_hidden(self.gui.share_mode)
+ self.autostop_timer_widget_hidden(self.gui.share_mode)
self.server_timed_out(self.gui.share_mode, 125000)
self.web_server_is_stopped()
diff --git a/tests/local_onionshare_404_public_mode_skips_ratelimit_test.py b/tests/local_onionshare_404_public_mode_skips_ratelimit_test.py
index ebb524c2..4fad5532 100644
--- a/tests/local_onionshare_404_public_mode_skips_ratelimit_test.py
+++ b/tests/local_onionshare_404_public_mode_skips_ratelimit_test.py
@@ -18,6 +18,7 @@ class Local404PublicModeRateLimitTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(True, True)
diff --git a/tests/local_onionshare_404_triggers_ratelimit_test.py b/tests/local_onionshare_404_triggers_ratelimit_test.py
index 8ed0777a..49be0f5b 100644
--- a/tests/local_onionshare_404_triggers_ratelimit_test.py
+++ b/tests/local_onionshare_404_triggers_ratelimit_test.py
@@ -17,6 +17,7 @@ class Local404RateLimitTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, True)
diff --git a/tests/local_onionshare_quitting_during_share_prompts_warning_test.py b/tests/local_onionshare_quitting_during_share_prompts_warning_test.py
index e57167c8..e43c88ba 100644
--- a/tests/local_onionshare_quitting_during_share_prompts_warning_test.py
+++ b/tests/local_onionshare_quitting_during_share_prompts_warning_test.py
@@ -18,6 +18,7 @@ class LocalQuittingDuringSharePromptsWarningTest(unittest.TestCase, GuiShareTest
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, True)
diff --git a/tests/local_onionshare_receive_mode_sender_closed_test.py b/tests/local_onionshare_receive_mode_sender_closed_test.py
deleted file mode 100644
index bfb9499a..00000000
--- a/tests/local_onionshare_receive_mode_sender_closed_test.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python3
-import pytest
-import unittest
-
-from .GuiReceiveTest import GuiReceiveTest
-
-class LocalReceiveModeSenderClosedTest(unittest.TestCase, GuiReceiveTest):
- @classmethod
- def setUpClass(cls):
- test_settings = {
- "receive_allow_receiver_shutdown": True
- }
- cls.gui = GuiReceiveTest.set_up(test_settings)
-
- @classmethod
- def tearDownClass(cls):
- GuiReceiveTest.tear_down()
-
- @pytest.mark.gui
- def test_gui(self):
- self.run_all_common_setup_tests()
- self.run_all_receive_mode_tests(False, True)
- self.run_receive_mode_sender_closed_tests(False)
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/local_onionshare_receive_mode_timer_test.py b/tests/local_onionshare_receive_mode_timer_test.py
index 0acaa4a9..4cde86c1 100644
--- a/tests/local_onionshare_receive_mode_timer_test.py
+++ b/tests/local_onionshare_receive_mode_timer_test.py
@@ -9,7 +9,7 @@ class LocalReceiveModeTimerTest(unittest.TestCase, GuiReceiveTest):
def setUpClass(cls):
test_settings = {
"public_mode": False,
- "shutdown_timeout": True,
+ "autostop_timer": True,
}
cls.gui = GuiReceiveTest.set_up(test_settings)
@@ -18,6 +18,7 @@ class LocalReceiveModeTimerTest(unittest.TestCase, GuiReceiveTest):
GuiReceiveTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_receive_mode_timer_tests(False)
diff --git a/tests/local_onionshare_receive_mode_upload_non_writable_dir_test.py b/tests/local_onionshare_receive_mode_upload_non_writable_dir_test.py
index a1dcd679..5737bae3 100644
--- a/tests/local_onionshare_receive_mode_upload_non_writable_dir_test.py
+++ b/tests/local_onionshare_receive_mode_upload_non_writable_dir_test.py
@@ -17,6 +17,7 @@ class LocalReceiveModeUnwritableTest(unittest.TestCase, GuiReceiveTest):
GuiReceiveTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_receive_mode_unwritable_dir_tests(False, True)
diff --git a/tests/local_onionshare_receive_mode_upload_public_mode_non_writable_dir_test.py b/tests/local_onionshare_receive_mode_upload_public_mode_non_writable_dir_test.py
index 529e0c87..e6024352 100644
--- a/tests/local_onionshare_receive_mode_upload_public_mode_non_writable_dir_test.py
+++ b/tests/local_onionshare_receive_mode_upload_public_mode_non_writable_dir_test.py
@@ -18,6 +18,7 @@ class LocalReceivePublicModeUnwritableTest(unittest.TestCase, GuiReceiveTest):
GuiReceiveTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_receive_mode_unwritable_dir_tests(True, True)
diff --git a/tests/local_onionshare_receive_mode_upload_public_mode_test.py b/tests/local_onionshare_receive_mode_upload_public_mode_test.py
index f8bd38bd..885ae4fe 100644
--- a/tests/local_onionshare_receive_mode_upload_public_mode_test.py
+++ b/tests/local_onionshare_receive_mode_upload_public_mode_test.py
@@ -18,6 +18,7 @@ class LocalReceiveModePublicModeTest(unittest.TestCase, GuiReceiveTest):
GuiReceiveTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_receive_mode_tests(True, True)
diff --git a/tests/local_onionshare_receive_mode_upload_test.py b/tests/local_onionshare_receive_mode_upload_test.py
index 362e3b85..3d23730c 100644
--- a/tests/local_onionshare_receive_mode_upload_test.py
+++ b/tests/local_onionshare_receive_mode_upload_test.py
@@ -17,6 +17,7 @@ class LocalReceiveModeTest(unittest.TestCase, GuiReceiveTest):
GuiReceiveTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_receive_mode_tests(False, True)
diff --git a/tests/local_onionshare_settings_dialog_legacy_tor_test.py b/tests/local_onionshare_settings_dialog_legacy_tor_test.py
index f32023fe..54653c1b 100644
--- a/tests/local_onionshare_settings_dialog_legacy_tor_test.py
+++ b/tests/local_onionshare_settings_dialog_legacy_tor_test.py
@@ -16,6 +16,7 @@ class SettingsGuiTest(unittest.TestCase, SettingsGuiBaseTest):
SettingsGuiBaseTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui_legacy_tor(self):
self.gui.onion = OnionStub(True, False)
self.gui.reload_settings()
diff --git a/tests/local_onionshare_settings_dialog_no_tor_test.py b/tests/local_onionshare_settings_dialog_no_tor_test.py
index b34cbff3..06e3cc9e 100644
--- a/tests/local_onionshare_settings_dialog_no_tor_test.py
+++ b/tests/local_onionshare_settings_dialog_no_tor_test.py
@@ -16,6 +16,7 @@ class SettingsGuiTest(unittest.TestCase, SettingsGuiBaseTest):
SettingsGuiBaseTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui_no_tor(self):
self.gui.onion = OnionStub(False, False)
self.gui.reload_settings()
diff --git a/tests/local_onionshare_settings_dialog_v3_tor_test.py b/tests/local_onionshare_settings_dialog_v3_tor_test.py
index 1dd17c0f..88a0438e 100644
--- a/tests/local_onionshare_settings_dialog_v3_tor_test.py
+++ b/tests/local_onionshare_settings_dialog_v3_tor_test.py
@@ -16,6 +16,7 @@ class SettingsGuiTest(unittest.TestCase, SettingsGuiBaseTest):
SettingsGuiBaseTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui_v3_tor(self):
self.gui.onion = OnionStub(True, True)
self.gui.reload_settings()
diff --git a/tests/local_onionshare_share_mode_autostart_and_autostop_timer_mismatch_test.py b/tests/local_onionshare_share_mode_autostart_and_autostop_timer_mismatch_test.py
new file mode 100644
index 00000000..0bb3bfa3
--- /dev/null
+++ b/tests/local_onionshare_share_mode_autostart_and_autostop_timer_mismatch_test.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+import pytest
+import unittest
+
+from .GuiShareTest import GuiShareTest
+
+class LocalShareModeAutoStartTimerTest(unittest.TestCase, GuiShareTest):
+ @classmethod
+ def setUpClass(cls):
+ test_settings = {
+ "public_mode": False,
+ "autostart_timer": True,
+ "autostop_timer": True,
+ }
+ cls.gui = GuiShareTest.set_up(test_settings)
+
+ @classmethod
+ def tearDownClass(cls):
+ GuiShareTest.tear_down()
+
+ @pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
+ def test_gui(self):
+ self.run_all_common_setup_tests()
+ self.run_all_share_mode_autostop_autostart_mismatch_tests(False)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/local_onionshare_share_mode_autostart_timer_test.py b/tests/local_onionshare_share_mode_autostart_timer_test.py
new file mode 100644
index 00000000..4fd5f649
--- /dev/null
+++ b/tests/local_onionshare_share_mode_autostart_timer_test.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import pytest
+import unittest
+
+from .GuiShareTest import GuiShareTest
+
+class LocalShareModeAutoStartTimerTest(unittest.TestCase, GuiShareTest):
+ @classmethod
+ def setUpClass(cls):
+ test_settings = {
+ "public_mode": False,
+ "autostart_timer": True,
+ }
+ cls.gui = GuiShareTest.set_up(test_settings)
+
+ @classmethod
+ def tearDownClass(cls):
+ GuiShareTest.tear_down()
+
+ @pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
+ def test_gui(self):
+ self.run_all_common_setup_tests()
+ self.run_all_share_mode_autostart_timer_tests(False)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/local_onionshare_share_mode_autostart_timer_too_short_test.py b/tests/local_onionshare_share_mode_autostart_timer_too_short_test.py
new file mode 100644
index 00000000..d8e82aed
--- /dev/null
+++ b/tests/local_onionshare_share_mode_autostart_timer_too_short_test.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+import pytest
+import unittest
+from PyQt5 import QtCore, QtTest
+
+from .GuiShareTest import GuiShareTest
+
+class LocalShareModeAutoStartTimerTooShortTest(unittest.TestCase, GuiShareTest):
+ @classmethod
+ def setUpClass(cls):
+ test_settings = {
+ "public_mode": False,
+ "autostart_timer": True,
+ }
+ cls.gui = GuiShareTest.set_up(test_settings)
+
+ @classmethod
+ def tearDownClass(cls):
+ GuiShareTest.tear_down()
+
+ @pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
+ def test_gui(self):
+ self.run_all_common_setup_tests()
+ self.run_all_share_mode_setup_tests()
+ # Set a low timeout
+ self.set_autostart_timer(self.gui.share_mode, 2)
+ QtTest.QTest.qWait(3000)
+ QtCore.QTimer.singleShot(4000, self.accept_dialog)
+ QtTest.QTest.mouseClick(self.gui.share_mode.server_status.server_button, QtCore.Qt.LeftButton)
+ self.assertEqual(self.gui.share_mode.server_status.status, 0)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/local_onionshare_share_mode_cancel_share_test.py b/tests/local_onionshare_share_mode_cancel_share_test.py
new file mode 100644
index 00000000..5b526999
--- /dev/null
+++ b/tests/local_onionshare_share_mode_cancel_share_test.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import pytest
+import unittest
+
+from .GuiShareTest import GuiShareTest
+
+class LocalShareModeCancelTest(unittest.TestCase, GuiShareTest):
+ @classmethod
+ def setUpClass(cls):
+ test_settings = {
+ "autostart_timer": True,
+ }
+ cls.gui = GuiShareTest.set_up(test_settings)
+
+ @classmethod
+ def tearDownClass(cls):
+ GuiShareTest.tear_down()
+
+ @pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
+ def test_gui(self):
+ self.run_all_common_setup_tests()
+ self.run_all_share_mode_setup_tests()
+ self.cancel_the_share(self.gui.share_mode)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/local_onionshare_share_mode_download_public_mode_test.py b/tests/local_onionshare_share_mode_download_public_mode_test.py
index f9a9dc4c..b7ff336c 100644
--- a/tests/local_onionshare_share_mode_download_public_mode_test.py
+++ b/tests/local_onionshare_share_mode_download_public_mode_test.py
@@ -17,6 +17,7 @@ class LocalShareModePublicModeTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(True, False)
diff --git a/tests/local_onionshare_share_mode_download_stay_open_test.py b/tests/local_onionshare_share_mode_download_stay_open_test.py
index 65304924..50d82326 100644
--- a/tests/local_onionshare_share_mode_download_stay_open_test.py
+++ b/tests/local_onionshare_share_mode_download_stay_open_test.py
@@ -17,6 +17,7 @@ class LocalShareModeStayOpenTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, True)
diff --git a/tests/local_onionshare_share_mode_download_test.py b/tests/local_onionshare_share_mode_download_test.py
index ea16683e..387d63c1 100644
--- a/tests/local_onionshare_share_mode_download_test.py
+++ b/tests/local_onionshare_share_mode_download_test.py
@@ -16,6 +16,7 @@ class LocalShareModeTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, False)
diff --git a/tests/local_onionshare_share_mode_large_download_test.py b/tests/local_onionshare_share_mode_large_download_test.py
index 7d0595a2..5717a2d8 100644
--- a/tests/local_onionshare_share_mode_large_download_test.py
+++ b/tests/local_onionshare_share_mode_large_download_test.py
@@ -16,6 +16,7 @@ class LocalShareModeLargeDownloadTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_large_file_tests(False, True)
diff --git a/tests/local_onionshare_share_mode_slug_persistent_test.py b/tests/local_onionshare_share_mode_slug_persistent_test.py
index 7254f3ff..58e1cfeb 100644
--- a/tests/local_onionshare_share_mode_slug_persistent_test.py
+++ b/tests/local_onionshare_share_mode_slug_persistent_test.py
@@ -20,6 +20,7 @@ class LocalShareModePersistentSlugTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_persistent_tests(False, True)
diff --git a/tests/local_onionshare_share_mode_timer_test.py b/tests/local_onionshare_share_mode_timer_test.py
index e30ce4ec..0526be08 100644
--- a/tests/local_onionshare_share_mode_timer_test.py
+++ b/tests/local_onionshare_share_mode_timer_test.py
@@ -9,7 +9,7 @@ class LocalShareModeTimerTest(unittest.TestCase, GuiShareTest):
def setUpClass(cls):
test_settings = {
"public_mode": False,
- "shutdown_timeout": True,
+ "autostop_timer": True,
}
cls.gui = GuiShareTest.set_up(test_settings)
@@ -18,6 +18,7 @@ class LocalShareModeTimerTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_timer_tests(False)
diff --git a/tests/local_onionshare_share_mode_timer_too_short_test.py b/tests/local_onionshare_share_mode_timer_too_short_test.py
index 8d22048d..09b82af3 100644
--- a/tests/local_onionshare_share_mode_timer_too_short_test.py
+++ b/tests/local_onionshare_share_mode_timer_too_short_test.py
@@ -10,7 +10,7 @@ class LocalShareModeTimerTooShortTest(unittest.TestCase, GuiShareTest):
def setUpClass(cls):
test_settings = {
"public_mode": False,
- "shutdown_timeout": True,
+ "autostop_timer": True,
}
cls.gui = GuiShareTest.set_up(test_settings)
@@ -19,6 +19,7 @@ class LocalShareModeTimerTooShortTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_setup_tests()
diff --git a/tests/local_onionshare_share_mode_unreadable_file_test.py b/tests/local_onionshare_share_mode_unreadable_file_test.py
index c74d7a0a..8b5dd4e7 100644
--- a/tests/local_onionshare_share_mode_unreadable_file_test.py
+++ b/tests/local_onionshare_share_mode_unreadable_file_test.py
@@ -16,6 +16,7 @@ class LocalShareModeUnReadableFileTest(unittest.TestCase, GuiShareTest):
GuiShareTest.tear_down()
@pytest.mark.gui
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_unreadable_file_tests()
diff --git a/tests/onionshare_790_cancel_on_second_share_test.py b/tests/onionshare_790_cancel_on_second_share_test.py
index 4b7673bb..f970b8af 100644
--- a/tests/onionshare_790_cancel_on_second_share_test.py
+++ b/tests/onionshare_790_cancel_on_second_share_test.py
@@ -19,6 +19,7 @@ class ShareModeCancelSecondShareTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, False)
diff --git a/tests/onionshare_receive_mode_upload_public_mode_test.py b/tests/onionshare_receive_mode_upload_public_mode_test.py
index 3c733f0a..c2611ad5 100644
--- a/tests/onionshare_receive_mode_upload_public_mode_test.py
+++ b/tests/onionshare_receive_mode_upload_public_mode_test.py
@@ -19,6 +19,7 @@ class ReceiveModeTest(unittest.TestCase, TorGuiReceiveTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_receive_mode_tests(True, True)
diff --git a/tests/onionshare_receive_mode_upload_test.py b/tests/onionshare_receive_mode_upload_test.py
index 493cacc7..a1935562 100644
--- a/tests/onionshare_receive_mode_upload_test.py
+++ b/tests/onionshare_receive_mode_upload_test.py
@@ -18,6 +18,7 @@ class ReceiveModeTest(unittest.TestCase, TorGuiReceiveTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_receive_mode_tests(False, True)
diff --git a/tests/onionshare_share_mode_cancel_share_test.py b/tests/onionshare_share_mode_cancel_share_test.py
index ed28ddd7..2a248bae 100644
--- a/tests/onionshare_share_mode_cancel_share_test.py
+++ b/tests/onionshare_share_mode_cancel_share_test.py
@@ -8,6 +8,7 @@ class ShareModeCancelTest(unittest.TestCase, TorGuiShareTest):
@classmethod
def setUpClass(cls):
test_settings = {
+ "autostart_timer": True,
}
cls.gui = TorGuiShareTest.set_up(test_settings)
@@ -17,6 +18,7 @@ class ShareModeCancelTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_setup_tests()
diff --git a/tests/onionshare_share_mode_download_public_mode_test.py b/tests/onionshare_share_mode_download_public_mode_test.py
index eb9adb1e..93c23978 100644
--- a/tests/onionshare_share_mode_download_public_mode_test.py
+++ b/tests/onionshare_share_mode_download_public_mode_test.py
@@ -18,6 +18,7 @@ class ShareModePublicModeTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(True, False)
diff --git a/tests/onionshare_share_mode_download_stay_open_test.py b/tests/onionshare_share_mode_download_stay_open_test.py
index 93a41f1f..3fcebc63 100644
--- a/tests/onionshare_share_mode_download_stay_open_test.py
+++ b/tests/onionshare_share_mode_download_stay_open_test.py
@@ -18,6 +18,7 @@ class ShareModeStayOpenTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, True)
diff --git a/tests/onionshare_share_mode_download_test.py b/tests/onionshare_share_mode_download_test.py
index ac3dee76..65f68df6 100644
--- a/tests/onionshare_share_mode_download_test.py
+++ b/tests/onionshare_share_mode_download_test.py
@@ -17,6 +17,7 @@ class ShareModeTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, False)
diff --git a/tests/onionshare_share_mode_persistent_test.py b/tests/onionshare_share_mode_persistent_test.py
index 13588a68..d0fb5b22 100644
--- a/tests/onionshare_share_mode_persistent_test.py
+++ b/tests/onionshare_share_mode_persistent_test.py
@@ -22,6 +22,7 @@ class ShareModePersistentSlugTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_persistent_tests(False, True)
diff --git a/tests/onionshare_share_mode_stealth_test.py b/tests/onionshare_share_mode_stealth_test.py
index bb9114a6..ded0b7a8 100644
--- a/tests/onionshare_share_mode_stealth_test.py
+++ b/tests/onionshare_share_mode_stealth_test.py
@@ -19,6 +19,7 @@ class ShareModeStealthTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_setup_tests()
diff --git a/tests/onionshare_share_mode_timer_test.py b/tests/onionshare_share_mode_timer_test.py
index 7f636a71..1ae2b0fa 100644
--- a/tests/onionshare_share_mode_timer_test.py
+++ b/tests/onionshare_share_mode_timer_test.py
@@ -9,7 +9,7 @@ class ShareModeTimerTest(unittest.TestCase, TorGuiShareTest):
def setUpClass(cls):
test_settings = {
"public_mode": False,
- "shutdown_timeout": True,
+ "autostop_timer": True,
}
cls.gui = TorGuiShareTest.set_up(test_settings)
@@ -19,6 +19,7 @@ class ShareModeTimerTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_timer_tests(False)
diff --git a/tests/onionshare_share_mode_tor_connection_killed_test.py b/tests/onionshare_share_mode_tor_connection_killed_test.py
index cf48df3d..7362a170 100644
--- a/tests/onionshare_share_mode_tor_connection_killed_test.py
+++ b/tests/onionshare_share_mode_tor_connection_killed_test.py
@@ -13,6 +13,7 @@ class ShareModeTorConnectionKilledTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_setup_tests()
diff --git a/tests/onionshare_share_mode_v2_onion_test.py b/tests/onionshare_share_mode_v2_onion_test.py
index 18f5f058..29c97491 100644
--- a/tests/onionshare_share_mode_v2_onion_test.py
+++ b/tests/onionshare_share_mode_v2_onion_test.py
@@ -18,6 +18,7 @@ class ShareModeV2OnionTest(unittest.TestCase, TorGuiShareTest):
@pytest.mark.gui
@pytest.mark.tor
+ @pytest.mark.skipif(pytest.__version__ < '2.9', reason="requires newer pytest")
def test_gui(self):
self.run_all_common_setup_tests()
self.run_all_share_mode_tests(False, False)
diff --git a/tests/test_onionshare.py b/tests/test_onionshare.py
index 7592a777..f141fed7 100644
--- a/tests/test_onionshare.py
+++ b/tests/test_onionshare.py
@@ -30,9 +30,10 @@ class MyOnion:
self.auth_string = 'TestHidServAuth'
self.private_key = ''
self.stealth = stealth
+ self.scheduled_key = None
@staticmethod
- def start_onion_service(_):
+ def start_onion_service(self, await_publication=True, save_scheduled_key=False):
return 'test_service_id.onion'
diff --git a/tests/test_onionshare_common.py b/tests/test_onionshare_common.py
index d70f2c0e..f975dce7 100644
--- a/tests/test_onionshare_common.py
+++ b/tests/test_onionshare_common.py
@@ -268,7 +268,7 @@ class TestLog:
def dummy_func():
pass
- common_obj.debug = True
+ common_obj.verbose = True
# From: https://stackoverflow.com/questions/1218933
with io.StringIO() as buf, contextlib.redirect_stdout(buf):
diff --git a/tests/test_onionshare_settings.py b/tests/test_onionshare_settings.py
index f4be2930..bcc2f7cb 100644
--- a/tests/test_onionshare_settings.py
+++ b/tests/test_onionshare_settings.py
@@ -51,7 +51,8 @@ class TestSettings:
'auth_type': 'no_auth',
'auth_password': '',
'close_after_first_download': True,
- 'shutdown_timeout': False,
+ 'autostop_timer': False,
+ 'autostart_timer': False,
'use_stealth': False,
'use_autoupdate': True,
'autoupdate_timestamp': None,
diff --git a/tests/test_onionshare_web.py b/tests/test_onionshare_web.py
index 3f9540ae..0c29859b 100644
--- a/tests/test_onionshare_web.py
+++ b/tests/test_onionshare_web.py
@@ -41,7 +41,7 @@ RANDOM_STR_REGEX = re.compile(r'^[a-z2-7]+$')
def web_obj(common_obj, mode, num_files=0):
""" Creates a Web object, in either share mode or receive mode, ready for testing """
- common_obj.load_settings()
+ common_obj.settings = Settings(common_obj)
strings.load_strings(common_obj)
web = Web(common_obj, False, mode)
web.generate_slug()