diff options
author | Micah Lee <micah@micahflee.com> | 2019-05-22 20:55:31 -0700 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2019-05-22 20:55:31 -0700 |
commit | 4df989dc77b2ffee26afd529dee312665c526a9b (patch) | |
tree | 55fe5fbd46ec08b8cc8bc539fe1f02f16e3222bf /tests | |
parent | 44431becc1602a3178538f2a619abe6ebae29237 (diff) | |
download | onionshare-4df989dc77b2ffee26afd529dee312665c526a9b.tar.gz onionshare-4df989dc77b2ffee26afd529dee312665c526a9b.zip |
Rename slugs to passwords in the tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GuiBaseTest.py | 16 | ||||
-rw-r--r-- | tests/GuiReceiveTest.py | 8 | ||||
-rw-r--r-- | tests/GuiShareTest.py | 32 | ||||
-rw-r--r-- | tests/TorGuiBaseTest.py | 8 | ||||
-rw-r--r-- | tests/TorGuiReceiveTest.py | 5 | ||||
-rw-r--r-- | tests/TorGuiShareTest.py | 13 | ||||
-rw-r--r-- | tests/local_onionshare_share_mode_password_persistent_test.py (renamed from tests/local_onionshare_share_mode_slug_persistent_test.py) | 4 | ||||
-rw-r--r-- | tests/onionshare_share_mode_persistent_test.py | 4 | ||||
-rw-r--r-- | tests/test_onionshare_common.py | 16 | ||||
-rw-r--r-- | tests/test_onionshare_settings.py | 2 | ||||
-rw-r--r-- | tests/test_onionshare_web.py | 24 |
11 files changed, 65 insertions, 67 deletions
diff --git a/tests/GuiBaseTest.py b/tests/GuiBaseTest.py index d3fc9945..65178f46 100644 --- a/tests/GuiBaseTest.py +++ b/tests/GuiBaseTest.py @@ -127,7 +127,7 @@ class GuiBaseTest(object): # Upload a file files = {'file[]': open('/tmp/test.txt', 'rb')} 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: path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port) response = requests.post(path, files=files) @@ -138,7 +138,7 @@ class GuiBaseTest(object): if public_mode: url = "http://127.0.0.1:{}/download".format(self.gui.app.port) 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) 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) - def have_a_slug(self, mode, public_mode): - '''Test that we have a valid slug''' + def have_a_password(self, mode, public_mode): + '''Test that we have a valid password''' 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: - 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): @@ -212,7 +212,7 @@ class GuiBaseTest(object): if public_mode: self.assertEqual(clipboard.text(), 'http://127.0.0.1:{}'.format(self.gui.app.port)) 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): @@ -230,7 +230,7 @@ class GuiBaseTest(object): s.connect(('127.0.0.1', self.gui.app.port)) if not public_mode: - path = '/{}'.format(mode.server_status.web.slug) + path = '/{}'.format(mode.server_status.web.password) else: path = '/' diff --git a/tests/GuiReceiveTest.py b/tests/GuiReceiveTest.py index 40c3de95..6ecf608c 100644 --- a/tests/GuiReceiveTest.py +++ b/tests/GuiReceiveTest.py @@ -9,7 +9,7 @@ class GuiReceiveTest(GuiBaseTest): '''Test that we can upload the file''' files = {'file[]': open(file_to_upload, 'rb')} 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: path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port) 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''' files = {'file[]': open('/tmp/test.txt', 'rb')} 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: path = 'http://127.0.0.1:{}/upload'.format(self.gui.app.port) response = requests.post(path, files=files) @@ -61,7 +61,7 @@ class GuiReceiveTest(GuiBaseTest): 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 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: 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.server_is_started(self.gui.receive_mode) 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.have_copy_url_button(self.gui.receive_mode, public_mode) self.server_status_indicator_says_started(self.gui.receive_mode) diff --git a/tests/GuiShareTest.py b/tests/GuiShareTest.py index 29661712..02ae0eea 100644 --- a/tests/GuiShareTest.py +++ b/tests/GuiShareTest.py @@ -7,9 +7,9 @@ from .GuiBaseTest import GuiBaseTest class GuiShareTest(GuiBaseTest): # Persistence tests - def have_same_slug(self, slug): - '''Test that we have the same slug''' - self.assertEqual(self.gui.share_mode.server_status.web.slug, slug) + def have_same_password(self, password): + '''Test that we have the same password''' + self.assertEqual(self.gui.share_mode.server_status.web.password, password) # Share-specific tests @@ -17,7 +17,7 @@ class GuiShareTest(GuiBaseTest): '''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) - + 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''' 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 self.assertFalse(self.gui.share_mode.server_status.file_selection.delete_button.isVisible()) - + 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''' 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) self.file_selection_widget_has_files(0) - + def file_selection_widget_readd_files(self): '''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') @@ -56,14 +56,14 @@ class GuiShareTest(GuiBaseTest): with open('/tmp/large_file', 'wb') as fout: fout.write(os.urandom(size)) self.gui.share_mode.server_status.file_selection.file_list.add_file('/tmp/large_file') - + def add_delete_buttons_hidden(self): '''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.delete_button.isVisible()) - + def download_share(self, public_mode): '''Test that we can download the share''' s = socks.socksocket() @@ -73,7 +73,7 @@ class GuiShareTest(GuiBaseTest): if public_mode: path = '/download' 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 += '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.file_selection_widget_readd_files() - + def run_all_share_mode_started_tests(self, public_mode, startup_time=2000): """Tests in share mode after starting a share""" self.server_working_on_start_button_pressed(self.gui.share_mode) @@ -139,12 +139,12 @@ class GuiShareTest(GuiBaseTest): self.settings_button_is_hidden() self.server_is_started(self.gui.share_mode, startup_time) 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.have_copy_url_button(self.gui.share_mode, public_mode) self.server_status_indicator_says_started(self.gui.share_mode) - + def run_all_share_mode_download_tests(self, public_mode, stay_open): """Tests in share mode after downloading a share""" 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.history_indicator(self.gui.share_mode, public_mode) - + def run_all_share_mode_tests(self, public_mode, stay_open): """End-to-end share 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): - """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_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.have_same_slug(slug) + self.have_same_password(password) def run_all_share_mode_timer_tests(self, public_mode): diff --git a/tests/TorGuiBaseTest.py b/tests/TorGuiBaseTest.py index 8bd963bd..3f9952d0 100644 --- a/tests/TorGuiBaseTest.py +++ b/tests/TorGuiBaseTest.py @@ -76,7 +76,7 @@ class TorGuiBaseTest(GuiBaseTest): # Upload a file files = {'file[]': open('/tmp/test.txt', 'rb')} 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: path = 'http://{}/upload'.format(self.gui.app.onion_host) response = session.post(path, files=files) @@ -87,7 +87,7 @@ class TorGuiBaseTest(GuiBaseTest): if public_mode: path = "http://{}/download".format(self.gui.app.onion_host) 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) QtTest.QTest.qWait(4000) @@ -111,7 +111,7 @@ class TorGuiBaseTest(GuiBaseTest): s.settimeout(60) s.connect((self.gui.app.onion_host, 80)) if not public_mode: - path = '/{}'.format(mode.server_status.web.slug) + path = '/{}'.format(mode.server_status.web.password) else: path = '/' http_request = 'GET {} HTTP/1.0\r\n'.format(path) @@ -138,7 +138,7 @@ class TorGuiBaseTest(GuiBaseTest): if public_mode: self.assertEqual(clipboard.text(), 'http://{}'.format(self.gui.app.onion_host)) 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 diff --git a/tests/TorGuiReceiveTest.py b/tests/TorGuiReceiveTest.py index a21dd4fc..601f34b6 100644 --- a/tests/TorGuiReceiveTest.py +++ b/tests/TorGuiReceiveTest.py @@ -13,7 +13,7 @@ class TorGuiReceiveTest(TorGuiBaseTest): session.proxies['http'] = 'socks5h://{}:{}'.format(socks_address, socks_port) files = {'file[]': open(file_to_upload, 'rb')} 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: path = 'http://{}/upload'.format(self.gui.app.onion_host) 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.web_server_is_running() 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.have_copy_url_button(self.gui.receive_mode, public_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_is_started(self.gui.receive_mode, startup_time=45000) self.history_indicator(self.gui.receive_mode, public_mode) - diff --git a/tests/TorGuiShareTest.py b/tests/TorGuiShareTest.py index 36efacd1..352707eb 100644 --- a/tests/TorGuiShareTest.py +++ b/tests/TorGuiShareTest.py @@ -17,7 +17,7 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest): if public_mode: path = "http://{}/download".format(self.gui.app.onion_host) 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) QtTest.QTest.qWait(4000) @@ -53,7 +53,7 @@ class TorGuiShareTest(TorGuiBaseTest, GuiShareTest): self.server_is_started(self.gui.share_mode, startup_time=45000) self.web_server_is_running() 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.have_copy_url_button(self.gui.share_mode, public_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): - """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_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 self.run_all_share_mode_download_tests(public_mode, stay_open) 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): """Auto-stop timer tests in share mode""" 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.server_timed_out(self.gui.share_mode, 125000) self.web_server_is_stopped() - diff --git a/tests/local_onionshare_share_mode_slug_persistent_test.py b/tests/local_onionshare_share_mode_password_persistent_test.py index 58e1cfeb..5b515ca1 100644 --- a/tests/local_onionshare_share_mode_slug_persistent_test.py +++ b/tests/local_onionshare_share_mode_password_persistent_test.py @@ -4,12 +4,12 @@ import unittest from .GuiShareTest import GuiShareTest -class LocalShareModePersistentSlugTest(unittest.TestCase, GuiShareTest): +class LocalShareModePersistentPasswordTest(unittest.TestCase, GuiShareTest): @classmethod def setUpClass(cls): test_settings = { "public_mode": False, - "slug": "", + "password": "", "save_private_key": True, "close_after_first_download": False, } diff --git a/tests/onionshare_share_mode_persistent_test.py b/tests/onionshare_share_mode_persistent_test.py index d0fb5b22..0e461f7e 100644 --- a/tests/onionshare_share_mode_persistent_test.py +++ b/tests/onionshare_share_mode_persistent_test.py @@ -4,13 +4,13 @@ import unittest from .TorGuiShareTest import TorGuiShareTest -class ShareModePersistentSlugTest(unittest.TestCase, TorGuiShareTest): +class ShareModePersistentPasswordTest(unittest.TestCase, TorGuiShareTest): @classmethod def setUpClass(cls): test_settings = { "use_legacy_v2_onions": True, "public_mode": False, - "slug": "", + "password": "", "save_private_key": True, "close_after_first_download": False, } diff --git a/tests/test_onionshare_common.py b/tests/test_onionshare_common.py index f975dce7..d5e67381 100644 --- a/tests/test_onionshare_common.py +++ b/tests/test_onionshare_common.py @@ -33,13 +33,13 @@ LOG_MSG_REGEX = re.compile(r""" ^\[Jun\ 06\ 2013\ 11:05:00\] \ TestModule\.<function\ TestLog\.test_output\.<locals>\.dummy_func \ 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 -class TestBuildSlug: +class TestBuildPassword: @pytest.mark.parametrize('test_input,expected', ( # VALID, two lowercase words, separated by a hyphen ('syrup-enzyme', True), @@ -60,8 +60,8 @@ class TestBuildSlug: ('too-many-hyphens-', False), ('symbols-!@#$%', False) )) - def test_build_slug_regex(self, test_input, expected): - """ Test that `SLUG_REGEX` accounts for the following patterns + def test_build_password_regex(self, test_input, expected): + """ Test that `PASSWORD_REGEX` accounts for the following patterns There are a few hyphenated words in `wordlist.txt`: * drop-down @@ -69,17 +69,17 @@ class TestBuildSlug: * t-shirt * yo-yo - These words cause a few extra potential slug patterns: + These words cause a few extra potential password patterns: * word-word * hyphenated-word-word * 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): - assert common_obj.build_slug() != common_obj.build_slug() + def test_build_password_unique(self, common_obj, sys_onionshare_dev_mode): + assert common_obj.build_password() != common_obj.build_password() class TestDirSize: diff --git a/tests/test_onionshare_settings.py b/tests/test_onionshare_settings.py index bcc2f7cb..05878899 100644 --- a/tests/test_onionshare_settings.py +++ b/tests/test_onionshare_settings.py @@ -63,7 +63,7 @@ class TestSettings: 'use_legacy_v2_onions': False, 'save_private_key': False, 'private_key': '', - 'slug': '', + 'password': '', 'hidservauth_string': '', 'data_dir': os.path.expanduser('~/OnionShare'), 'public_mode': False diff --git a/tests/test_onionshare_web.py b/tests/test_onionshare_web.py index 0c29859b..f9c6c2ec 100644 --- a/tests/test_onionshare_web.py +++ b/tests/test_onionshare_web.py @@ -44,7 +44,7 @@ def web_obj(common_obj, mode, num_files=0): common_obj.settings = Settings(common_obj) strings.load_strings(common_obj) web = Web(common_obj, False, mode) - web.generate_slug() + web.generate_password() web.stay_open = True web.running = True @@ -76,17 +76,17 @@ class TestWeb: res.get_data() assert res.status_code == 404 - res = c.get('/invalidslug'.format(web.slug)) + res = c.get('/invalidpassword'.format(web.password)) res.get_data() assert res.status_code == 404 # Load download page - res = c.get('/{}'.format(web.slug)) + res = c.get('/{}'.format(web.password)) res.get_data() assert res.status_code == 200 # Download - res = c.get('/{}/download'.format(web.slug)) + res = c.get('/{}/download'.format(web.password)) res.get_data() assert res.status_code == 200 assert res.mimetype == 'application/zip' @@ -99,7 +99,7 @@ class TestWeb: with web.app.test_client() as c: # Download the first time - res = c.get('/{}/download'.format(web.slug)) + res = c.get('/{}/download'.format(web.password)) res.get_data() assert res.status_code == 200 assert res.mimetype == 'application/zip' @@ -114,7 +114,7 @@ class TestWeb: with web.app.test_client() as c: # Download the first time - res = c.get('/{}/download'.format(web.slug)) + res = c.get('/{}/download'.format(web.password)) res.get_data() assert res.status_code == 200 assert res.mimetype == 'application/zip' @@ -130,12 +130,12 @@ class TestWeb: res.get_data() assert res.status_code == 404 - res = c.get('/invalidslug'.format(web.slug)) + res = c.get('/invalidpassword'.format(web.password)) res.get_data() assert res.status_code == 404 # Load upload page - res = c.get('/{}'.format(web.slug)) + res = c.get('/{}'.format(web.password)) res.get_data() assert res.status_code == 200 @@ -149,8 +149,8 @@ class TestWeb: data1 = res.get_data() assert res.status_code == 200 - # /[slug] should be a 404 - res = c.get('/{}'.format(web.slug)) + # /[password] should be a 404 + res = c.get('/{}'.format(web.password)) data2 = res.get_data() assert res.status_code == 404 @@ -164,8 +164,8 @@ class TestWeb: data1 = res.get_data() assert res.status_code == 404 - # Upload page should be accessible from /[slug] - res = c.get('/{}'.format(web.slug)) + # Upload page should be accessible from /[password] + res = c.get('/{}'.format(web.password)) data2 = res.get_data() assert res.status_code == 200 |