mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-03 06:55:09 -04:00
Rename slugs to passwords in the tests
This commit is contained in:
parent
6d057c0078
commit
cec63daf3a
11 changed files with 65 additions and 67 deletions
|
@ -127,7 +127,7 @@ class GuiBaseTest(object):
|
||||||
# Upload a file
|
# Upload a file
|
||||||
files = {'file[]': open('/tmp/test.txt', 'rb')}
|
files = {'file[]': open('/tmp/test.txt', 'rb')}
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, mode.web.slug)
|
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, mode.web.password)
|
||||||
else:
|
else:
|
||||||
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
||||||
response = requests.post(path, files=files)
|
response = requests.post(path, files=files)
|
||||||
|
@ -138,7 +138,7 @@ class GuiBaseTest(object):
|
||||||
if public_mode:
|
if public_mode:
|
||||||
url = "http://127.0.0.1:{}/download".format(self.gui.app.port)
|
url = "http://127.0.0.1:{}/download".format(self.gui.app.port)
|
||||||
else:
|
else:
|
||||||
url = "http://127.0.0.1:{}/{}/download".format(self.gui.app.port, mode.web.slug)
|
url = "http://127.0.0.1:{}/{}/download".format(self.gui.app.port, mode.web.password)
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
QtTest.QTest.qWait(2000)
|
QtTest.QTest.qWait(2000)
|
||||||
|
|
||||||
|
@ -190,12 +190,12 @@ class GuiBaseTest(object):
|
||||||
self.assertEqual(sock.connect_ex(('127.0.0.1',self.gui.app.port)), 0)
|
self.assertEqual(sock.connect_ex(('127.0.0.1',self.gui.app.port)), 0)
|
||||||
|
|
||||||
|
|
||||||
def have_a_slug(self, mode, public_mode):
|
def have_a_password(self, mode, public_mode):
|
||||||
'''Test that we have a valid slug'''
|
'''Test that we have a valid password'''
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
self.assertRegex(mode.server_status.web.slug, r'(\w+)-(\w+)')
|
self.assertRegex(mode.server_status.web.password, r'(\w+)-(\w+)')
|
||||||
else:
|
else:
|
||||||
self.assertIsNone(mode.server_status.web.slug, r'(\w+)-(\w+)')
|
self.assertIsNone(mode.server_status.web.password, r'(\w+)-(\w+)')
|
||||||
|
|
||||||
|
|
||||||
def url_description_shown(self, mode):
|
def url_description_shown(self, mode):
|
||||||
|
@ -212,7 +212,7 @@ class GuiBaseTest(object):
|
||||||
if public_mode:
|
if public_mode:
|
||||||
self.assertEqual(clipboard.text(), 'http://127.0.0.1:{}'.format(self.gui.app.port))
|
self.assertEqual(clipboard.text(), 'http://127.0.0.1:{}'.format(self.gui.app.port))
|
||||||
else:
|
else:
|
||||||
self.assertEqual(clipboard.text(), 'http://127.0.0.1:{}/{}'.format(self.gui.app.port, mode.server_status.web.slug))
|
self.assertEqual(clipboard.text(), 'http://127.0.0.1:{}/{}'.format(self.gui.app.port, mode.server_status.web.password))
|
||||||
|
|
||||||
|
|
||||||
def server_status_indicator_says_started(self, mode):
|
def server_status_indicator_says_started(self, mode):
|
||||||
|
@ -230,7 +230,7 @@ class GuiBaseTest(object):
|
||||||
s.connect(('127.0.0.1', self.gui.app.port))
|
s.connect(('127.0.0.1', self.gui.app.port))
|
||||||
|
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = '/{}'.format(mode.server_status.web.slug)
|
path = '/{}'.format(mode.server_status.web.password)
|
||||||
else:
|
else:
|
||||||
path = '/'
|
path = '/'
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class GuiReceiveTest(GuiBaseTest):
|
||||||
'''Test that we can upload the file'''
|
'''Test that we can upload the file'''
|
||||||
files = {'file[]': open(file_to_upload, 'rb')}
|
files = {'file[]': open(file_to_upload, 'rb')}
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.slug)
|
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.password)
|
||||||
else:
|
else:
|
||||||
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
||||||
response = requests.post(path, files=files)
|
response = requests.post(path, files=files)
|
||||||
|
@ -40,7 +40,7 @@ class GuiReceiveTest(GuiBaseTest):
|
||||||
'''Test that we can't upload the file when permissions are wrong, and expected content is shown'''
|
'''Test that we can't upload the file when permissions are wrong, and expected content is shown'''
|
||||||
files = {'file[]': open('/tmp/test.txt', 'rb')}
|
files = {'file[]': open('/tmp/test.txt', 'rb')}
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.slug)
|
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.password)
|
||||||
else:
|
else:
|
||||||
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
||||||
response = requests.post(path, files=files)
|
response = requests.post(path, files=files)
|
||||||
|
@ -61,7 +61,7 @@ class GuiReceiveTest(GuiBaseTest):
|
||||||
def uploading_zero_files_shouldnt_change_ui(self, mode, public_mode):
|
def uploading_zero_files_shouldnt_change_ui(self, mode, public_mode):
|
||||||
'''If you submit the receive mode form without selecting any files, the UI shouldn't get updated'''
|
'''If you submit the receive mode form without selecting any files, the UI shouldn't get updated'''
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.slug)
|
path = 'http://127.0.0.1:{}/{}/upload'.format(self.gui.app.port, self.gui.receive_mode.web.password)
|
||||||
else:
|
else:
|
||||||
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port)
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class GuiReceiveTest(GuiBaseTest):
|
||||||
self.settings_button_is_hidden()
|
self.settings_button_is_hidden()
|
||||||
self.server_is_started(self.gui.receive_mode)
|
self.server_is_started(self.gui.receive_mode)
|
||||||
self.web_server_is_running()
|
self.web_server_is_running()
|
||||||
self.have_a_slug(self.gui.receive_mode, public_mode)
|
self.have_a_password(self.gui.receive_mode, public_mode)
|
||||||
self.url_description_shown(self.gui.receive_mode)
|
self.url_description_shown(self.gui.receive_mode)
|
||||||
self.have_copy_url_button(self.gui.receive_mode, public_mode)
|
self.have_copy_url_button(self.gui.receive_mode, public_mode)
|
||||||
self.server_status_indicator_says_started(self.gui.receive_mode)
|
self.server_status_indicator_says_started(self.gui.receive_mode)
|
||||||
|
|
|
@ -7,9 +7,9 @@ from .GuiBaseTest import GuiBaseTest
|
||||||
|
|
||||||
class GuiShareTest(GuiBaseTest):
|
class GuiShareTest(GuiBaseTest):
|
||||||
# Persistence tests
|
# Persistence tests
|
||||||
def have_same_slug(self, slug):
|
def have_same_password(self, password):
|
||||||
'''Test that we have the same slug'''
|
'''Test that we have the same password'''
|
||||||
self.assertEqual(self.gui.share_mode.server_status.web.slug, slug)
|
self.assertEqual(self.gui.share_mode.server_status.web.password, password)
|
||||||
|
|
||||||
# Share-specific tests
|
# Share-specific tests
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class GuiShareTest(GuiBaseTest):
|
||||||
'''Test that the number of items in the list is as expected'''
|
'''Test that the number of items in the list is as expected'''
|
||||||
self.assertEqual(self.gui.share_mode.server_status.file_selection.get_num_files(), num)
|
self.assertEqual(self.gui.share_mode.server_status.file_selection.get_num_files(), num)
|
||||||
|
|
||||||
|
|
||||||
def deleting_all_files_hides_delete_button(self):
|
def deleting_all_files_hides_delete_button(self):
|
||||||
'''Test that clicking on the file item shows the delete button. Test that deleting the only item in the list hides the delete button'''
|
'''Test that clicking on the file item shows the delete button. Test that deleting the only item in the list hides the delete button'''
|
||||||
rect = self.gui.share_mode.server_status.file_selection.file_list.visualItemRect(self.gui.share_mode.server_status.file_selection.file_list.item(0))
|
rect = self.gui.share_mode.server_status.file_selection.file_list.visualItemRect(self.gui.share_mode.server_status.file_selection.file_list.item(0))
|
||||||
|
@ -35,14 +35,14 @@ class GuiShareTest(GuiBaseTest):
|
||||||
# No more files, the delete button should be hidden
|
# No more files, the delete button should be hidden
|
||||||
self.assertFalse(self.gui.share_mode.server_status.file_selection.delete_button.isVisible())
|
self.assertFalse(self.gui.share_mode.server_status.file_selection.delete_button.isVisible())
|
||||||
|
|
||||||
|
|
||||||
def add_a_file_and_delete_using_its_delete_widget(self):
|
def add_a_file_and_delete_using_its_delete_widget(self):
|
||||||
'''Test that we can also delete a file by clicking on its [X] widget'''
|
'''Test that we can also delete a file by clicking on its [X] widget'''
|
||||||
self.gui.share_mode.server_status.file_selection.file_list.add_file('/etc/hosts')
|
self.gui.share_mode.server_status.file_selection.file_list.add_file('/etc/hosts')
|
||||||
QtTest.QTest.mouseClick(self.gui.share_mode.server_status.file_selection.file_list.item(0).item_button, QtCore.Qt.LeftButton)
|
QtTest.QTest.mouseClick(self.gui.share_mode.server_status.file_selection.file_list.item(0).item_button, QtCore.Qt.LeftButton)
|
||||||
self.file_selection_widget_has_files(0)
|
self.file_selection_widget_has_files(0)
|
||||||
|
|
||||||
|
|
||||||
def file_selection_widget_readd_files(self):
|
def file_selection_widget_readd_files(self):
|
||||||
'''Re-add some files to the list so we can share'''
|
'''Re-add some files to the list so we can share'''
|
||||||
self.gui.share_mode.server_status.file_selection.file_list.add_file('/etc/hosts')
|
self.gui.share_mode.server_status.file_selection.file_list.add_file('/etc/hosts')
|
||||||
|
@ -56,14 +56,14 @@ class GuiShareTest(GuiBaseTest):
|
||||||
with open('/tmp/large_file', 'wb') as fout:
|
with open('/tmp/large_file', 'wb') as fout:
|
||||||
fout.write(os.urandom(size))
|
fout.write(os.urandom(size))
|
||||||
self.gui.share_mode.server_status.file_selection.file_list.add_file('/tmp/large_file')
|
self.gui.share_mode.server_status.file_selection.file_list.add_file('/tmp/large_file')
|
||||||
|
|
||||||
|
|
||||||
def add_delete_buttons_hidden(self):
|
def add_delete_buttons_hidden(self):
|
||||||
'''Test that the add and delete buttons are hidden when the server starts'''
|
'''Test that the add and delete buttons are hidden when the server starts'''
|
||||||
self.assertFalse(self.gui.share_mode.server_status.file_selection.add_button.isVisible())
|
self.assertFalse(self.gui.share_mode.server_status.file_selection.add_button.isVisible())
|
||||||
self.assertFalse(self.gui.share_mode.server_status.file_selection.delete_button.isVisible())
|
self.assertFalse(self.gui.share_mode.server_status.file_selection.delete_button.isVisible())
|
||||||
|
|
||||||
|
|
||||||
def download_share(self, public_mode):
|
def download_share(self, public_mode):
|
||||||
'''Test that we can download the share'''
|
'''Test that we can download the share'''
|
||||||
s = socks.socksocket()
|
s = socks.socksocket()
|
||||||
|
@ -73,7 +73,7 @@ class GuiShareTest(GuiBaseTest):
|
||||||
if public_mode:
|
if public_mode:
|
||||||
path = '/download'
|
path = '/download'
|
||||||
else:
|
else:
|
||||||
path = '{}/download'.format(self.gui.share_mode.web.slug)
|
path = '{}/download'.format(self.gui.share_mode.web.password)
|
||||||
|
|
||||||
http_request = 'GET {} HTTP/1.0\r\n'.format(path)
|
http_request = 'GET {} HTTP/1.0\r\n'.format(path)
|
||||||
http_request += 'Host: 127.0.0.1\r\n'
|
http_request += 'Host: 127.0.0.1\r\n'
|
||||||
|
@ -130,7 +130,7 @@ class GuiShareTest(GuiBaseTest):
|
||||||
self.add_a_file_and_delete_using_its_delete_widget()
|
self.add_a_file_and_delete_using_its_delete_widget()
|
||||||
self.file_selection_widget_readd_files()
|
self.file_selection_widget_readd_files()
|
||||||
|
|
||||||
|
|
||||||
def run_all_share_mode_started_tests(self, public_mode, startup_time=2000):
|
def run_all_share_mode_started_tests(self, public_mode, startup_time=2000):
|
||||||
"""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)
|
||||||
|
@ -139,12 +139,12 @@ class GuiShareTest(GuiBaseTest):
|
||||||
self.settings_button_is_hidden()
|
self.settings_button_is_hidden()
|
||||||
self.server_is_started(self.gui.share_mode, startup_time)
|
self.server_is_started(self.gui.share_mode, startup_time)
|
||||||
self.web_server_is_running()
|
self.web_server_is_running()
|
||||||
self.have_a_slug(self.gui.share_mode, public_mode)
|
self.have_a_password(self.gui.share_mode, public_mode)
|
||||||
self.url_description_shown(self.gui.share_mode)
|
self.url_description_shown(self.gui.share_mode)
|
||||||
self.have_copy_url_button(self.gui.share_mode, public_mode)
|
self.have_copy_url_button(self.gui.share_mode, public_mode)
|
||||||
self.server_status_indicator_says_started(self.gui.share_mode)
|
self.server_status_indicator_says_started(self.gui.share_mode)
|
||||||
|
|
||||||
|
|
||||||
def run_all_share_mode_download_tests(self, public_mode, stay_open):
|
def run_all_share_mode_download_tests(self, public_mode, stay_open):
|
||||||
"""Tests in share mode after downloading a share"""
|
"""Tests in share mode after downloading a share"""
|
||||||
self.web_page(self.gui.share_mode, 'Total size', public_mode)
|
self.web_page(self.gui.share_mode, 'Total size', public_mode)
|
||||||
|
@ -158,7 +158,7 @@ class GuiShareTest(GuiBaseTest):
|
||||||
self.server_is_started(self.gui.share_mode)
|
self.server_is_started(self.gui.share_mode)
|
||||||
self.history_indicator(self.gui.share_mode, public_mode)
|
self.history_indicator(self.gui.share_mode, public_mode)
|
||||||
|
|
||||||
|
|
||||||
def run_all_share_mode_tests(self, public_mode, stay_open):
|
def run_all_share_mode_tests(self, public_mode, stay_open):
|
||||||
"""End-to-end share tests"""
|
"""End-to-end share tests"""
|
||||||
self.run_all_share_mode_setup_tests()
|
self.run_all_share_mode_setup_tests()
|
||||||
|
@ -178,12 +178,12 @@ class GuiShareTest(GuiBaseTest):
|
||||||
|
|
||||||
|
|
||||||
def run_all_share_mode_persistent_tests(self, public_mode, stay_open):
|
def run_all_share_mode_persistent_tests(self, public_mode, stay_open):
|
||||||
"""Same as end-to-end share tests but also test the slug is the same on multiple shared"""
|
"""Same as end-to-end share tests but also test the password is the same on multiple shared"""
|
||||||
self.run_all_share_mode_setup_tests()
|
self.run_all_share_mode_setup_tests()
|
||||||
self.run_all_share_mode_started_tests(public_mode)
|
self.run_all_share_mode_started_tests(public_mode)
|
||||||
slug = self.gui.share_mode.server_status.web.slug
|
password = self.gui.share_mode.server_status.web.password
|
||||||
self.run_all_share_mode_download_tests(public_mode, stay_open)
|
self.run_all_share_mode_download_tests(public_mode, stay_open)
|
||||||
self.have_same_slug(slug)
|
self.have_same_password(password)
|
||||||
|
|
||||||
|
|
||||||
def run_all_share_mode_timer_tests(self, public_mode):
|
def run_all_share_mode_timer_tests(self, public_mode):
|
||||||
|
|
|
@ -76,7 +76,7 @@ class TorGuiBaseTest(GuiBaseTest):
|
||||||
# Upload a file
|
# Upload a file
|
||||||
files = {'file[]': open('/tmp/test.txt', 'rb')}
|
files = {'file[]': open('/tmp/test.txt', 'rb')}
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = 'http://{}/{}/upload'.format(self.gui.app.onion_host, mode.web.slug)
|
path = 'http://{}/{}/upload'.format(self.gui.app.onion_host, mode.web.password)
|
||||||
else:
|
else:
|
||||||
path = 'http://{}/upload'.format(self.gui.app.onion_host)
|
path = 'http://{}/upload'.format(self.gui.app.onion_host)
|
||||||
response = session.post(path, files=files)
|
response = session.post(path, files=files)
|
||||||
|
@ -87,7 +87,7 @@ class TorGuiBaseTest(GuiBaseTest):
|
||||||
if public_mode:
|
if public_mode:
|
||||||
path = "http://{}/download".format(self.gui.app.onion_host)
|
path = "http://{}/download".format(self.gui.app.onion_host)
|
||||||
else:
|
else:
|
||||||
path = "http://{}/{}/download".format(self.gui.app.onion_host, mode.web.slug)
|
path = "http://{}/{}/download".format(self.gui.app.onion_host, mode.web.password)
|
||||||
response = session.get(path)
|
response = session.get(path)
|
||||||
QtTest.QTest.qWait(4000)
|
QtTest.QTest.qWait(4000)
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class TorGuiBaseTest(GuiBaseTest):
|
||||||
s.settimeout(60)
|
s.settimeout(60)
|
||||||
s.connect((self.gui.app.onion_host, 80))
|
s.connect((self.gui.app.onion_host, 80))
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = '/{}'.format(mode.server_status.web.slug)
|
path = '/{}'.format(mode.server_status.web.password)
|
||||||
else:
|
else:
|
||||||
path = '/'
|
path = '/'
|
||||||
http_request = 'GET {} HTTP/1.0\r\n'.format(path)
|
http_request = 'GET {} HTTP/1.0\r\n'.format(path)
|
||||||
|
@ -138,7 +138,7 @@ class TorGuiBaseTest(GuiBaseTest):
|
||||||
if public_mode:
|
if public_mode:
|
||||||
self.assertEqual(clipboard.text(), 'http://{}'.format(self.gui.app.onion_host))
|
self.assertEqual(clipboard.text(), 'http://{}'.format(self.gui.app.onion_host))
|
||||||
else:
|
else:
|
||||||
self.assertEqual(clipboard.text(), 'http://{}/{}'.format(self.gui.app.onion_host, mode.server_status.web.slug))
|
self.assertEqual(clipboard.text(), 'http://{}/{}'.format(self.gui.app.onion_host, mode.server_status.web.password))
|
||||||
|
|
||||||
|
|
||||||
# Stealth tests
|
# Stealth tests
|
||||||
|
|
|
@ -13,7 +13,7 @@ class TorGuiReceiveTest(TorGuiBaseTest):
|
||||||
session.proxies['http'] = 'socks5h://{}:{}'.format(socks_address, socks_port)
|
session.proxies['http'] = 'socks5h://{}:{}'.format(socks_address, socks_port)
|
||||||
files = {'file[]': open(file_to_upload, 'rb')}
|
files = {'file[]': open(file_to_upload, 'rb')}
|
||||||
if not public_mode:
|
if not public_mode:
|
||||||
path = 'http://{}/{}/upload'.format(self.gui.app.onion_host, self.gui.receive_mode.web.slug)
|
path = 'http://{}/{}/upload'.format(self.gui.app.onion_host, self.gui.receive_mode.web.password)
|
||||||
else:
|
else:
|
||||||
path = 'http://{}/upload'.format(self.gui.app.onion_host)
|
path = 'http://{}/upload'.format(self.gui.app.onion_host)
|
||||||
response = session.post(path, files=files)
|
response = session.post(path, files=files)
|
||||||
|
@ -35,7 +35,7 @@ class TorGuiReceiveTest(TorGuiBaseTest):
|
||||||
self.server_is_started(self.gui.receive_mode, startup_time=45000)
|
self.server_is_started(self.gui.receive_mode, startup_time=45000)
|
||||||
self.web_server_is_running()
|
self.web_server_is_running()
|
||||||
self.have_an_onion_service()
|
self.have_an_onion_service()
|
||||||
self.have_a_slug(self.gui.receive_mode, public_mode)
|
self.have_a_password(self.gui.receive_mode, public_mode)
|
||||||
self.url_description_shown(self.gui.receive_mode)
|
self.url_description_shown(self.gui.receive_mode)
|
||||||
self.have_copy_url_button(self.gui.receive_mode, public_mode)
|
self.have_copy_url_button(self.gui.receive_mode, public_mode)
|
||||||
self.server_status_indicator_says_started(self.gui.receive_mode)
|
self.server_status_indicator_says_started(self.gui.receive_mode)
|
||||||
|
@ -56,4 +56,3 @@ class TorGuiReceiveTest(TorGuiBaseTest):
|
||||||
self.server_working_on_start_button_pressed(self.gui.receive_mode)
|
self.server_working_on_start_button_pressed(self.gui.receive_mode)
|
||||||
self.server_is_started(self.gui.receive_mode, startup_time=45000)
|
self.server_is_started(self.gui.receive_mode, startup_time=45000)
|
||||||
self.history_indicator(self.gui.receive_mode, public_mode)
|
self.history_indicator(self.gui.receive_mode, public_mode)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest):
|
||||||
if public_mode:
|
if public_mode:
|
||||||
path = "http://{}/download".format(self.gui.app.onion_host)
|
path = "http://{}/download".format(self.gui.app.onion_host)
|
||||||
else:
|
else:
|
||||||
path = "http://{}/{}/download".format(self.gui.app.onion_host, self.gui.share_mode.web.slug)
|
path = "http://{}/{}/download".format(self.gui.app.onion_host, self.gui.share_mode.web.password)
|
||||||
response = session.get(path, stream=True)
|
response = session.get(path, stream=True)
|
||||||
QtTest.QTest.qWait(4000)
|
QtTest.QTest.qWait(4000)
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest):
|
||||||
self.server_is_started(self.gui.share_mode, startup_time=45000)
|
self.server_is_started(self.gui.share_mode, startup_time=45000)
|
||||||
self.web_server_is_running()
|
self.web_server_is_running()
|
||||||
self.have_an_onion_service()
|
self.have_an_onion_service()
|
||||||
self.have_a_slug(self.gui.share_mode, public_mode)
|
self.have_a_password(self.gui.share_mode, public_mode)
|
||||||
self.url_description_shown(self.gui.share_mode)
|
self.url_description_shown(self.gui.share_mode)
|
||||||
self.have_copy_url_button(self.gui.share_mode, public_mode)
|
self.have_copy_url_button(self.gui.share_mode, public_mode)
|
||||||
self.server_status_indicator_says_started(self.gui.share_mode)
|
self.server_status_indicator_says_started(self.gui.share_mode)
|
||||||
|
@ -74,16 +74,16 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest):
|
||||||
|
|
||||||
|
|
||||||
def run_all_share_mode_persistent_tests(self, public_mode, stay_open):
|
def run_all_share_mode_persistent_tests(self, public_mode, stay_open):
|
||||||
"""Same as end-to-end share tests but also test the slug is the same on multiple shared"""
|
"""Same as end-to-end share tests but also test the password is the same on multiple shared"""
|
||||||
self.run_all_share_mode_setup_tests()
|
self.run_all_share_mode_setup_tests()
|
||||||
self.run_all_share_mode_started_tests(public_mode)
|
self.run_all_share_mode_started_tests(public_mode)
|
||||||
slug = self.gui.share_mode.server_status.web.slug
|
password = self.gui.share_mode.server_status.web.password
|
||||||
onion = self.gui.app.onion_host
|
onion = self.gui.app.onion_host
|
||||||
self.run_all_share_mode_download_tests(public_mode, stay_open)
|
self.run_all_share_mode_download_tests(public_mode, stay_open)
|
||||||
self.have_same_onion(onion)
|
self.have_same_onion(onion)
|
||||||
self.have_same_slug(slug)
|
self.have_same_password(password)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run_all_share_mode_timer_tests(self, public_mode):
|
def run_all_share_mode_timer_tests(self, public_mode):
|
||||||
"""Auto-stop timer tests in share mode"""
|
"""Auto-stop timer tests in share mode"""
|
||||||
self.run_all_share_mode_setup_tests()
|
self.run_all_share_mode_setup_tests()
|
||||||
|
@ -92,4 +92,3 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest):
|
||||||
self.autostop_timer_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.server_timed_out(self.gui.share_mode, 125000)
|
||||||
self.web_server_is_stopped()
|
self.web_server_is_stopped()
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@ import unittest
|
||||||
|
|
||||||
from .GuiShareTest import GuiShareTest
|
from .GuiShareTest import GuiShareTest
|
||||||
|
|
||||||
class LocalShareModePersistentSlugTest(unittest.TestCase, GuiShareTest):
|
class LocalShareModePersistentPasswordTest(unittest.TestCase, GuiShareTest):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
test_settings = {
|
test_settings = {
|
||||||
"public_mode": False,
|
"public_mode": False,
|
||||||
"slug": "",
|
"password": "",
|
||||||
"save_private_key": True,
|
"save_private_key": True,
|
||||||
"close_after_first_download": False,
|
"close_after_first_download": False,
|
||||||
}
|
}
|
|
@ -4,13 +4,13 @@ import unittest
|
||||||
|
|
||||||
from .TorGuiShareTest import TorGuiShareTest
|
from .TorGuiShareTest import TorGuiShareTest
|
||||||
|
|
||||||
class ShareModePersistentSlugTest(unittest.TestCase, TorGuiShareTest):
|
class ShareModePersistentPasswordTest(unittest.TestCase, TorGuiShareTest):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
test_settings = {
|
test_settings = {
|
||||||
"use_legacy_v2_onions": True,
|
"use_legacy_v2_onions": True,
|
||||||
"public_mode": False,
|
"public_mode": False,
|
||||||
"slug": "",
|
"password": "",
|
||||||
"save_private_key": True,
|
"save_private_key": True,
|
||||||
"close_after_first_download": False,
|
"close_after_first_download": False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,13 @@ LOG_MSG_REGEX = re.compile(r"""
|
||||||
^\[Jun\ 06\ 2013\ 11:05:00\]
|
^\[Jun\ 06\ 2013\ 11:05:00\]
|
||||||
\ TestModule\.<function\ TestLog\.test_output\.<locals>\.dummy_func
|
\ TestModule\.<function\ TestLog\.test_output\.<locals>\.dummy_func
|
||||||
\ at\ 0x[a-f0-9]+>(:\ TEST_MSG)?$""", re.VERBOSE)
|
\ at\ 0x[a-f0-9]+>(:\ TEST_MSG)?$""", re.VERBOSE)
|
||||||
SLUG_REGEX = re.compile(r'^([a-z]+)(-[a-z]+)?-([a-z]+)(-[a-z]+)?$')
|
PASSWORD_REGEX = re.compile(r'^([a-z]+)(-[a-z]+)?-([a-z]+)(-[a-z]+)?$')
|
||||||
|
|
||||||
|
|
||||||
# TODO: Improve the Common tests to test it all as a single class
|
# TODO: Improve the Common tests to test it all as a single class
|
||||||
|
|
||||||
|
|
||||||
class TestBuildSlug:
|
class TestBuildPassword:
|
||||||
@pytest.mark.parametrize('test_input,expected', (
|
@pytest.mark.parametrize('test_input,expected', (
|
||||||
# VALID, two lowercase words, separated by a hyphen
|
# VALID, two lowercase words, separated by a hyphen
|
||||||
('syrup-enzyme', True),
|
('syrup-enzyme', True),
|
||||||
|
@ -60,8 +60,8 @@ class TestBuildSlug:
|
||||||
('too-many-hyphens-', False),
|
('too-many-hyphens-', False),
|
||||||
('symbols-!@#$%', False)
|
('symbols-!@#$%', False)
|
||||||
))
|
))
|
||||||
def test_build_slug_regex(self, test_input, expected):
|
def test_build_password_regex(self, test_input, expected):
|
||||||
""" Test that `SLUG_REGEX` accounts for the following patterns
|
""" Test that `PASSWORD_REGEX` accounts for the following patterns
|
||||||
|
|
||||||
There are a few hyphenated words in `wordlist.txt`:
|
There are a few hyphenated words in `wordlist.txt`:
|
||||||
* drop-down
|
* drop-down
|
||||||
|
@ -69,17 +69,17 @@ class TestBuildSlug:
|
||||||
* t-shirt
|
* t-shirt
|
||||||
* yo-yo
|
* yo-yo
|
||||||
|
|
||||||
These words cause a few extra potential slug patterns:
|
These words cause a few extra potential password patterns:
|
||||||
* word-word
|
* word-word
|
||||||
* hyphenated-word-word
|
* hyphenated-word-word
|
||||||
* word-hyphenated-word
|
* word-hyphenated-word
|
||||||
* hyphenated-word-hyphenated-word
|
* hyphenated-word-hyphenated-word
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert bool(SLUG_REGEX.match(test_input)) == expected
|
assert bool(PASSWORD_REGEX.match(test_input)) == expected
|
||||||
|
|
||||||
def test_build_slug_unique(self, common_obj, sys_onionshare_dev_mode):
|
def test_build_password_unique(self, common_obj, sys_onionshare_dev_mode):
|
||||||
assert common_obj.build_slug() != common_obj.build_slug()
|
assert common_obj.build_password() != common_obj.build_password()
|
||||||
|
|
||||||
|
|
||||||
class TestDirSize:
|
class TestDirSize:
|
||||||
|
|
|
@ -63,7 +63,7 @@ class TestSettings:
|
||||||
'use_legacy_v2_onions': False,
|
'use_legacy_v2_onions': False,
|
||||||
'save_private_key': False,
|
'save_private_key': False,
|
||||||
'private_key': '',
|
'private_key': '',
|
||||||
'slug': '',
|
'password': '',
|
||||||
'hidservauth_string': '',
|
'hidservauth_string': '',
|
||||||
'data_dir': os.path.expanduser('~/OnionShare'),
|
'data_dir': os.path.expanduser('~/OnionShare'),
|
||||||
'public_mode': False
|
'public_mode': False
|
||||||
|
|
|
@ -44,7 +44,7 @@ def web_obj(common_obj, mode, num_files=0):
|
||||||
common_obj.settings = Settings(common_obj)
|
common_obj.settings = Settings(common_obj)
|
||||||
strings.load_strings(common_obj)
|
strings.load_strings(common_obj)
|
||||||
web = Web(common_obj, False, mode)
|
web = Web(common_obj, False, mode)
|
||||||
web.generate_slug()
|
web.generate_password()
|
||||||
web.stay_open = True
|
web.stay_open = True
|
||||||
web.running = True
|
web.running = True
|
||||||
|
|
||||||
|
@ -76,17 +76,17 @@ class TestWeb:
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 404
|
assert res.status_code == 404
|
||||||
|
|
||||||
res = c.get('/invalidslug'.format(web.slug))
|
res = c.get('/invalidpassword'.format(web.password))
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 404
|
assert res.status_code == 404
|
||||||
|
|
||||||
# Load download page
|
# Load download page
|
||||||
res = c.get('/{}'.format(web.slug))
|
res = c.get('/{}'.format(web.password))
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
res = c.get('/{}/download'.format(web.slug))
|
res = c.get('/{}/download'.format(web.password))
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
assert res.mimetype == 'application/zip'
|
assert res.mimetype == 'application/zip'
|
||||||
|
@ -99,7 +99,7 @@ class TestWeb:
|
||||||
|
|
||||||
with web.app.test_client() as c:
|
with web.app.test_client() as c:
|
||||||
# Download the first time
|
# Download the first time
|
||||||
res = c.get('/{}/download'.format(web.slug))
|
res = c.get('/{}/download'.format(web.password))
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
assert res.mimetype == 'application/zip'
|
assert res.mimetype == 'application/zip'
|
||||||
|
@ -114,7 +114,7 @@ class TestWeb:
|
||||||
|
|
||||||
with web.app.test_client() as c:
|
with web.app.test_client() as c:
|
||||||
# Download the first time
|
# Download the first time
|
||||||
res = c.get('/{}/download'.format(web.slug))
|
res = c.get('/{}/download'.format(web.password))
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
assert res.mimetype == 'application/zip'
|
assert res.mimetype == 'application/zip'
|
||||||
|
@ -130,12 +130,12 @@ class TestWeb:
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 404
|
assert res.status_code == 404
|
||||||
|
|
||||||
res = c.get('/invalidslug'.format(web.slug))
|
res = c.get('/invalidpassword'.format(web.password))
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 404
|
assert res.status_code == 404
|
||||||
|
|
||||||
# Load upload page
|
# Load upload page
|
||||||
res = c.get('/{}'.format(web.slug))
|
res = c.get('/{}'.format(web.password))
|
||||||
res.get_data()
|
res.get_data()
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
|
|
||||||
|
@ -149,8 +149,8 @@ class TestWeb:
|
||||||
data1 = res.get_data()
|
data1 = res.get_data()
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
|
|
||||||
# /[slug] should be a 404
|
# /[password] should be a 404
|
||||||
res = c.get('/{}'.format(web.slug))
|
res = c.get('/{}'.format(web.password))
|
||||||
data2 = res.get_data()
|
data2 = res.get_data()
|
||||||
assert res.status_code == 404
|
assert res.status_code == 404
|
||||||
|
|
||||||
|
@ -164,8 +164,8 @@ class TestWeb:
|
||||||
data1 = res.get_data()
|
data1 = res.get_data()
|
||||||
assert res.status_code == 404
|
assert res.status_code == 404
|
||||||
|
|
||||||
# Upload page should be accessible from /[slug]
|
# Upload page should be accessible from /[password]
|
||||||
res = c.get('/{}'.format(web.slug))
|
res = c.get('/{}'.format(web.password))
|
||||||
data2 = res.get_data()
|
data2 = res.get_data()
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue