summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2018-10-17 09:23:07 +1100
committerMiguel Jacq <mig@mig5.net>2018-10-17 09:23:07 +1100
commitdbbc9c0c820dd9fa211b7bf18b8d988923c15a6a (patch)
treecf0112f0456e19d4031e2529b2e5d44519feb033 /tests
parentfea34c0f34c6bf543a4c5b3295dd8c953f001037 (diff)
downloadonionshare-dbbc9c0c820dd9fa211b7bf18b8d988923c15a6a.tar.gz
onionshare-dbbc9c0c820dd9fa211b7bf18b8d988923c15a6a.zip
Fix stealth test, add legacy v2 onion test
Diffstat (limited to 'tests')
-rw-r--r--tests/TorGuiBaseTest.py4
-rw-r--r--tests/TorGuiShareTest.py7
-rw-r--r--tests/onionshare_share_mode_stealth_test.py2
-rw-r--r--tests/onionshare_share_mode_v2_onion_test.py26
4 files changed, 34 insertions, 5 deletions
diff --git a/tests/TorGuiBaseTest.py b/tests/TorGuiBaseTest.py
index aee05096..611cb202 100644
--- a/tests/TorGuiBaseTest.py
+++ b/tests/TorGuiBaseTest.py
@@ -158,9 +158,7 @@ class TorGuiBaseTest(GuiBaseTest):
def copy_have_hidserv_auth_button(self, mode):
'''Test that the Copy HidservAuth button is shown'''
self.assertTrue(mode.server_status.copy_hidservauth_button.isVisible())
- clipboard = self.gui.qtapp.clipboard()
- self.assertRegex(clipboard.text(), r'HidServAuth %s [a-zA-Z1-9]' % self.gui.app.onion_host)
def hidserv_auth_string(self):
'''Test the validity of the HidservAuth string'''
- self.assertRegex(self.gui.app.auth_string, r'HidServAuth %s [a-zA-Z1-9]' % self.gui.app.onion_host)
+ self.assertRegex(self.gui.app.auth_string, r'HidServAuth {} [a-zA-Z1-9]'.format(self.gui.app.onion_host))
diff --git a/tests/TorGuiShareTest.py b/tests/TorGuiShareTest.py
index ff8d0bb7..53641dce 100644
--- a/tests/TorGuiShareTest.py
+++ b/tests/TorGuiShareTest.py
@@ -36,11 +36,16 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest):
'''Test that we have the same onion'''
self.assertEqual(self.gui.app.onion_host, onion)
+ # legacy v2 onion test
+ def have_v2_onion(self):
+ '''Test that the onion is a v2 style onion'''
+ self.assertRegex(self.gui.app.onion_host, r'[a-z2-7].onion')
+ self.assertEqual(len(self.gui.app.onion_host), 22)
# 'Grouped' tests follow from here
def run_all_share_mode_started_tests(self, public_mode):
- """Tests in share mode after starting a share"""
+ '''Tests in share mode after starting a share'''
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()
diff --git a/tests/onionshare_share_mode_stealth_test.py b/tests/onionshare_share_mode_stealth_test.py
index 3096a8bc..78e87e9e 100644
--- a/tests/onionshare_share_mode_stealth_test.py
+++ b/tests/onionshare_share_mode_stealth_test.py
@@ -22,8 +22,8 @@ class ShareModeStealthTest(unittest.TestCase, TorGuiShareTest):
self.run_all_common_setup_tests()
self.run_all_share_mode_setup_tests()
self.run_all_share_mode_started_tests(False)
- self.copy_have_hidserv_auth_button(self.gui.share_mode)
self.hidserv_auth_string()
+ self.copy_have_hidserv_auth_button(self.gui.share_mode)
if __name__ == "__main__":
unittest.main()
diff --git a/tests/onionshare_share_mode_v2_onion_test.py b/tests/onionshare_share_mode_v2_onion_test.py
new file mode 100644
index 00000000..f06f6631
--- /dev/null
+++ b/tests/onionshare_share_mode_v2_onion_test.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+import pytest
+import unittest
+
+from .TorGuiShareTest import TorGuiShareTest
+
+class ShareModeV2OnionTest(unittest.TestCase, TorGuiShareTest):
+ @classmethod
+ def setUpClass(cls):
+ test_settings = {
+ "use_legacy_v2_onions": True,
+ }
+ cls.gui = TorGuiShareTest.set_up(test_settings, 'ShareModeV2OnionTest')
+
+ @classmethod
+ def tearDownClass(cls):
+ TorGuiShareTest.tear_down()
+
+ @pytest.mark.tor
+ def test_gui(self):
+ self.run_all_common_setup_tests()
+ self.run_all_share_mode_tests(False, False)
+ self.have_v2_onion()
+
+if __name__ == "__main__":
+ unittest.main()