Fix stealth test, add legacy v2 onion test

This commit is contained in:
Miguel Jacq 2018-10-17 09:23:07 +11:00
parent fea34c0f34
commit dbbc9c0c82
No known key found for this signature in database
GPG key ID: EEA4341C6D97A0B6
4 changed files with 34 additions and 5 deletions

View file

@ -158,9 +158,7 @@ class TorGuiBaseTest(GuiBaseTest):
def copy_have_hidserv_auth_button(self, mode): def copy_have_hidserv_auth_button(self, mode):
'''Test that the Copy HidservAuth button is shown''' '''Test that the Copy HidservAuth button is shown'''
self.assertTrue(mode.server_status.copy_hidservauth_button.isVisible()) 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): def hidserv_auth_string(self):
'''Test the validity of the HidservAuth string''' '''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))

View file

@ -36,11 +36,16 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest):
'''Test that we have the same onion''' '''Test that we have the same onion'''
self.assertEqual(self.gui.app.onion_host, 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 # 'Grouped' tests follow from here
def run_all_share_mode_started_tests(self, public_mode): 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_working_on_start_button_pressed(self.gui.share_mode)
self.server_status_indicator_says_starting(self.gui.share_mode) self.server_status_indicator_says_starting(self.gui.share_mode)
self.add_delete_buttons_hidden() self.add_delete_buttons_hidden()

View file

@ -22,8 +22,8 @@ class ShareModeStealthTest(unittest.TestCase, TorGuiShareTest):
self.run_all_common_setup_tests() self.run_all_common_setup_tests()
self.run_all_share_mode_setup_tests() self.run_all_share_mode_setup_tests()
self.run_all_share_mode_started_tests(False) self.run_all_share_mode_started_tests(False)
self.copy_have_hidserv_auth_button(self.gui.share_mode)
self.hidserv_auth_string() self.hidserv_auth_string()
self.copy_have_hidserv_auth_button(self.gui.share_mode)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View file

@ -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()