Merge branch 'develop' into fix_405_error_and_other_methods

This commit is contained in:
Miguel Jacq 2021-05-11 08:15:35 +10:00
commit a066c871a9
No known key found for this signature in database
GPG Key ID: EEA4341C6D97A0B6
9 changed files with 132 additions and 15 deletions

View File

@ -14,6 +14,8 @@ Before making a release, you must update the version in these places:
- [ ] `docs/source/conf.py` (`version` at the top, and the `versions` list too)
- [ ] `snap/snapcraft.yaml`
If you update flask-socketio, ensure that you also update the [socket.io.min.js](https://github.com/micahflee/onionshare/blob/develop/cli/onionshare_cli/resources/static/js/socket.io.min.js) file to a version that is [supported](https://flask-socketio.readthedocs.io/en/latest/#version-compatibility) by the updated version of flask-socketio.
Use tor binaries from the latest Tor Browser:
- [ ] `desktop/scripts/get-tor-osx.py`

View File

@ -21,11 +21,13 @@
{% if not disable_text and not disable_files %}
<p class="upload-header">Submit Files or Messages</p>
<p class="upload-description">You can submit files, a message, or both</p>
<p class="upload-description">You can submit files, a message, or both.</p>
<p class="upload-description">Remember, you are accessing this service anonymously! Provide contact info if you want a response to the message.</p>
{% endif %}
{% if not disable_text and disable_files %}
<p class="upload-header">Submit Messages</p>
<p class="upload-description">You can submit a message</p>
<p class="upload-description">You can submit a message.</p>
<p class="upload-description">Remember, you are accessing this service anonymously! Provide contact info if you want a response to the message.</p>
{% endif %}
{% if disable_text and not disable_files %}
<p class="upload-header">Submit Files</p>
@ -61,4 +63,4 @@
<script async src="{{ static_url_path }}/js/receive.js" id="receive-script"></script>
</body>
</html>
</html>

View File

@ -20,7 +20,7 @@ python = "^3.6"
click = "*"
flask = "*"
flask-httpauth = "*"
flask-socketio = "*"
flask-socketio = "5.0.1"
psutil = "*"
pycryptodome = "*"
pysocks = "*"

View File

@ -101,6 +101,10 @@
"gui_status_indicator_receive_working": "Starting…",
"gui_status_indicator_receive_scheduled": "Scheduled…",
"gui_status_indicator_receive_started": "Receiving",
"gui_status_indicator_chat_stopped": "Ready to chat",
"gui_status_indicator_chat_working": "Starting…",
"gui_status_indicator_chat_scheduled": "Scheduled…",
"gui_status_indicator_chat_started": "Chatting",
"gui_file_info": "{} files, {}",
"gui_file_info_single": "{} file, {}",
"history_in_progress_tooltip": "{} in progress",
@ -198,4 +202,4 @@
"error_port_not_available": "OnionShare port not available",
"history_receive_read_message_button": "Read Message",
"error_tor_protocol_error": "There was an error with Tor: {}"
}
}

View File

@ -452,20 +452,20 @@ class Tab(QtWidgets.QWidget):
# Chat mode
if self.chat_mode.server_status.status == ServerStatus.STATUS_STOPPED:
self.set_server_status_indicator_stopped(
strings._("gui_status_indicator_receive_stopped")
strings._("gui_status_indicator_chat_stopped")
)
elif self.chat_mode.server_status.status == ServerStatus.STATUS_WORKING:
if self.settings.get("general", "autostart_timer"):
self.set_server_status_indicator_working(
strings._("gui_status_indicator_receive_scheduled")
strings._("gui_status_indicator_chat_scheduled")
)
else:
self.set_server_status_indicator_working(
strings._("gui_status_indicator_receive_working")
strings._("gui_status_indicator_chat_working")
)
elif self.chat_mode.server_status.status == ServerStatus.STATUS_STARTED:
self.set_server_status_indicator_started(
strings._("gui_status_indicator_receive_started")
strings._("gui_status_indicator_chat_started")
)
def set_server_status_indicator_stopped(self, label_text):

View File

@ -14,6 +14,7 @@ from onionshare import Application, MainWindow, GuiCommon
from onionshare.tab.mode.share_mode import ShareMode
from onionshare.tab.mode.receive_mode import ReceiveMode
from onionshare.tab.mode.website_mode import WebsiteMode
from onionshare.tab.mode.chat_mode import ChatMode
from onionshare import strings
@ -133,6 +134,17 @@ class GuiBaseTest(unittest.TestCase):
return tab
def new_chat_tab(self):
tab = self.gui.tabs.widget(0)
self.verify_new_tab(tab)
# Chat
tab.chat_button.click()
self.assertFalse(tab.new_tab.isVisible())
self.assertTrue(tab.chat_mode.isVisible())
return tab
def close_all_tabs(self):
for _ in range(self.gui.tabs.count()):
tab = self.gui.tabs.widget(0)
@ -361,6 +373,7 @@ class GuiBaseTest(unittest.TestCase):
and not tab.settings.get("share", "autostop_sharing")
)
or (type(tab.get_mode()) == WebsiteMode)
or (type(tab.get_mode()) == ChatMode)
):
tab.get_mode().server_status.server_button.click()
self.assertEqual(tab.get_mode().server_status.status, 0)

View File

@ -2,4 +2,5 @@
pytest -v tests/test_gui_tabs.py && \
pytest -v tests/test_gui_share.py && \
pytest -v tests/test_gui_receive.py && \
pytest -v tests/test_gui_website.py
pytest -v tests/test_gui_website.py && \
pytest -v tests/test_gui_chat.py

View File

@ -0,0 +1,75 @@
import requests
from PySide2 import QtTest
from .gui_base_test import GuiBaseTest
class TestChat(GuiBaseTest):
# Shared test methods
def view_chat(self, tab):
"""Test that we can view the chat room"""
url = f"http://127.0.0.1:{tab.app.port}/"
if tab.settings.get("general", "public"):
r = requests.get(url)
else:
r = requests.get(
url,
auth=requests.auth.HTTPBasicAuth(
"onionshare", tab.get_mode().server_status.web.password
),
)
QtTest.QTest.qWait(500, self.gui.qtapp)
self.assertTrue("Chat <b>requires JavaScript</b>" in r.text)
cookies_dict = requests.utils.dict_from_cookiejar(r.cookies)
self.assertTrue("session" in cookies_dict.keys())
def change_username(self, tab):
"""Test that we can change our username"""
url = f"http://127.0.0.1:{tab.app.port}/update-session-username"
data = {"username":"oniontest"}
if tab.settings.get("general", "public"):
r = requests.post(url, json=data)
else:
r = requests.post(
url,
json=data,
auth=requests.auth.HTTPBasicAuth(
"onionshare", tab.get_mode().server_status.web.password
),
)
QtTest.QTest.qWait(500, self.gui.qtapp)
jsonResponse = r.json()
self.assertTrue(jsonResponse["success"])
self.assertEqual(jsonResponse["username"], "oniontest")
def run_all_chat_mode_tests(self, tab):
"""Tests in chat mode after starting a chat"""
self.server_working_on_start_button_pressed(tab)
self.server_status_indicator_says_starting(tab)
self.server_is_started(tab, startup_time=500)
self.web_server_is_running(tab)
self.have_a_password(tab)
self.url_description_shown(tab)
self.have_copy_url_button(tab)
self.have_show_qr_code_button(tab)
self.server_status_indicator_says_started(tab)
self.view_chat(tab)
self.change_username(tab)
self.server_is_stopped(tab)
self.web_server_is_stopped(tab)
self.server_status_indicator_says_closed(tab)
# Tests
def test_chat(self):
"""
Test chat mode
"""
tab = self.new_chat_tab()
self.run_all_chat_mode_tests(tab)
self.close_all_tabs()

View File

@ -153,11 +153,21 @@ class TestTabs(GuiBaseTest):
self.gui.status_bar.server_status_label.text(), "Ready to share"
)
# New tab, chat mode
self.gui.tabs.new_tab_button.click()
self.gui.tabs.widget(4).chat_button.click()
self.assertFalse(self.gui.tabs.widget(4).new_tab.isVisible())
self.assertTrue(self.gui.tabs.widget(4).chat_mode.isVisible())
self.assertEqual(
self.gui.status_bar.server_status_label.text(), "Ready to chat"
)
# Close tabs
self.gui.tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide).click()
self.gui.tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide).click()
self.gui.tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide).click()
self.gui.tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide).click()
self.gui.tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide).click()
def test_07_close_share_tab_while_server_started_should_warn(self):
"""Closing a share mode tab when the server is running should throw a warning"""
@ -165,7 +175,7 @@ class TestTabs(GuiBaseTest):
self.close_tab_with_active_server(tab)
def test_08_close_receive_tab_while_server_started_should_warn(self):
"""Closing a recieve mode tab when the server is running should throw a warning"""
"""Closing a receive mode tab when the server is running should throw a warning"""
tab = self.new_receive_tab()
self.close_tab_with_active_server(tab)
@ -174,22 +184,32 @@ class TestTabs(GuiBaseTest):
tab = self.new_website_tab_with_files()
self.close_tab_with_active_server(tab)
def test_10_close_persistent_share_tab_shows_warning(self):
def test_10_close_chat_tab_while_server_started_should_warn(self):
"""Closing a chat mode tab when the server is running should throw a warning"""
tab = self.new_chat_tab()
self.close_tab_with_active_server(tab)
def test_11_close_persistent_share_tab_shows_warning(self):
"""Closing a share mode tab that's persistent should show a warning"""
tab = self.new_share_tab_with_files()
self.close_persistent_tab(tab)
def test_11_close_persistent_receive_tab_shows_warning(self):
def test_12_close_persistent_receive_tab_shows_warning(self):
"""Closing a receive mode tab that's persistent should show a warning"""
tab = self.new_receive_tab()
self.close_persistent_tab(tab)
def test_12_close_persistent_website_tab_shows_warning(self):
def test_13_close_persistent_website_tab_shows_warning(self):
"""Closing a website mode tab that's persistent should show a warning"""
tab = self.new_website_tab_with_files()
self.close_persistent_tab(tab)
def test_13_quit_with_server_started_should_warn(self):
def test_14_close_persistent_chat_tab_shows_warning(self):
"""Closing a chat mode tab that's persistent should show a warning"""
tab = self.new_chat_tab()
self.close_persistent_tab(tab)
def test_15_quit_with_server_started_should_warn(self):
"""Quitting OnionShare with any active servers should show a warning"""
tab = self.new_share_tab()