diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index c8366927a..12571fc55 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -111,14 +111,9 @@ class OpenLPServer(RegistryProperties): self.address = address self.is_secure = Settings().value(self.settings_section + '/https enabled') self.needs_authentication = Settings().value(self.settings_section + '/authentication enabled') - if self.is_secure: - port = Settings().value(self.settings_section + '/https port') - self.port = port - self.start_server_instance(address, port, HTTPSServer) - else: - port = Settings().value(self.settings_section + '/port') - self.port = port - self.start_server_instance(address, port, ThreadingHTTPServer) + port = Settings().value(self.settings_section + '/port') + self.port = port + self.start_server_instance(address, port, ThreadingHTTPServer) if hasattr(self, 'httpd') and self.httpd: self.httpd.serve_forever() else: @@ -158,19 +153,3 @@ class OpenLPServer(RegistryProperties): self.http_thread.stop() self.httpd = None log.debug('Stopped the server.') - - -class HTTPSServer(HTTPServer): - def __init__(self, address, handler): - """ - Initialise the secure handlers for the SSL server if required.s - """ - BaseServer.__init__(self, address, handler) - local_data = AppLocation.get_directory(AppLocation.DataDir) - self.socket = ssl.SSLSocket( - sock=socket.socket(self.address_family, self.socket_type), - certfile=os.path.join(local_data, 'remotes', 'openlp.crt'), - keyfile=os.path.join(local_data, 'remotes', 'openlp.key'), - server_side=True) - self.server_bind() - self.server_activate() diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 73874ae25..314781546 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -88,42 +88,6 @@ class RemoteTab(SettingsTab): self.live_url.setOpenExternalLinks(True) self.http_setting_layout.addRow(self.live_url_label, self.live_url) self.left_layout.addWidget(self.http_settings_group_box) - self.https_settings_group_box = QtWidgets.QGroupBox(self.left_column) - self.https_settings_group_box.setCheckable(True) - self.https_settings_group_box.setChecked(False) - self.https_settings_group_box.setObjectName('https_settings_group_box') - self.https_settings_layout = QtWidgets.QFormLayout(self.https_settings_group_box) - self.https_settings_layout.setObjectName('https_settings_layout') - self.https_error_label = QtWidgets.QLabel(self.https_settings_group_box) - self.https_error_label.setVisible(False) - self.https_error_label.setWordWrap(True) - self.https_error_label.setObjectName('https_error_label') - self.https_settings_layout.addRow(self.https_error_label) - self.https_port_label = QtWidgets.QLabel(self.https_settings_group_box) - self.https_port_label.setObjectName('https_port_label') - self.https_port_spin_box = QtWidgets.QSpinBox(self.https_settings_group_box) - self.https_port_spin_box.setMaximum(32767) - self.https_port_spin_box.setObjectName('https_port_spin_box') - self.https_settings_layout.addRow(self.https_port_label, self.https_port_spin_box) - self.remote_https_url = QtWidgets.QLabel(self.https_settings_group_box) - self.remote_https_url.setObjectName('remote_http_url') - self.remote_https_url.setOpenExternalLinks(True) - self.remote_https_url_label = QtWidgets.QLabel(self.https_settings_group_box) - self.remote_https_url_label.setObjectName('remote_http_url_label') - self.https_settings_layout.addRow(self.remote_https_url_label, self.remote_https_url) - self.stage_https_url_label = QtWidgets.QLabel(self.http_settings_group_box) - self.stage_https_url_label.setObjectName('stage_https_url_label') - self.stage_https_url = QtWidgets.QLabel(self.https_settings_group_box) - self.stage_https_url.setObjectName('stage_https_url') - self.stage_https_url.setOpenExternalLinks(True) - self.https_settings_layout.addRow(self.stage_https_url_label, self.stage_https_url) - self.live_https_url_label = QtWidgets.QLabel(self.https_settings_group_box) - self.live_https_url_label.setObjectName('live_url_label') - self.live_https_url = QtWidgets.QLabel(self.https_settings_group_box) - self.live_https_url.setObjectName('live_https_url') - self.live_https_url.setOpenExternalLinks(True) - self.https_settings_layout.addRow(self.live_https_url_label, self.live_https_url) - self.left_layout.addWidget(self.https_settings_group_box) self.user_login_group_box = QtWidgets.QGroupBox(self.left_column) self.user_login_group_box.setCheckable(True) self.user_login_group_box.setChecked(False) @@ -177,8 +141,6 @@ class RemoteTab(SettingsTab): self.thumbnails_check_box.stateChanged.connect(self.on_thumbnails_check_box_changed) self.address_edit.textChanged.connect(self.set_urls) self.port_spin_box.valueChanged.connect(self.set_urls) - self.https_port_spin_box.valueChanged.connect(self.set_urls) - self.https_settings_group_box.clicked.connect(self.https_changed) def retranslateUi(self): self.server_settings_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Server Settings')) @@ -200,14 +162,6 @@ class RemoteTab(SettingsTab): translate('RemotePlugin.RemoteTab', 'Scan the QR code or click download to install the iOS app from the App ' 'Store.').format(qr='https://itunes.apple.com/app/id1096218725')) - self.https_settings_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'HTTPS Server')) - self.https_error_label.setText( - translate('RemotePlugin.RemoteTab', 'Could not find an SSL certificate. The HTTPS server will not be ' - 'available unless an SSL certificate is found. Please see the manual for more information.')) - self.https_port_label.setText(self.port_label.text()) - self.remote_https_url_label.setText(self.remote_url_label.text()) - self.stage_https_url_label.setText(self.stage_url_label.text()) - self.live_https_url_label.setText(self.live_url_label.text()) self.user_login_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'User Authentication')) self.user_id_label.setText(translate('RemotePlugin.RemoteTab', 'User id:')) self.password_label.setText(translate('RemotePlugin.RemoteTab', 'Password:')) @@ -218,17 +172,11 @@ class RemoteTab(SettingsTab): """ ip_address = self.get_ip_address(self.address_edit.text()) http_url = 'http://{url}:{text}/'.format(url=ip_address, text=self.port_spin_box.value()) - https_url = 'https://{url}:{text}/'.format(url=ip_address, text=self.https_port_spin_box.value()) self.remote_url.setText('{url}'.format(url=http_url)) - self.remote_https_url.setText('{url}'.format(url=https_url)) http_url_temp = http_url + 'stage' - https_url_temp = https_url + 'stage' self.stage_url.setText('{url}'.format(url=http_url_temp)) - self.stage_https_url.setText('{url}'.format(url=https_url_temp)) http_url_temp = http_url + 'main' - https_url_temp = https_url + 'main' self.live_url.setText('{url}'.format(url=http_url_temp)) - self.live_https_url.setText('{url}'.format(url=https_url_temp)) def get_ip_address(self, ip_address): """ @@ -254,43 +202,25 @@ class RemoteTab(SettingsTab): """ Load the configuration and update the server configuration if necessary """ - self.is_secure = Settings().value(self.settings_section + '/https enabled') self.port_spin_box.setValue(Settings().value(self.settings_section + '/port')) - self.https_port_spin_box.setValue(Settings().value(self.settings_section + '/https port')) self.address_edit.setText(Settings().value(self.settings_section + '/ip address')) self.twelve_hour = Settings().value(self.settings_section + '/twelve hour') self.twelve_hour_check_box.setChecked(self.twelve_hour) self.thumbnails = Settings().value(self.settings_section + '/thumbnails') self.thumbnails_check_box.setChecked(self.thumbnails) - local_data = AppLocation.get_directory(AppLocation.DataDir) - if not os.path.exists(os.path.join(local_data, 'remotes', 'openlp.crt')) or \ - not os.path.exists(os.path.join(local_data, 'remotes', 'openlp.key')): - self.https_settings_group_box.setChecked(False) - self.https_settings_group_box.setEnabled(False) - self.https_error_label.setVisible(True) - else: - self.https_settings_group_box.setChecked(Settings().value(self.settings_section + '/https enabled')) - self.https_settings_group_box.setEnabled(True) - self.https_error_label.setVisible(False) self.user_login_group_box.setChecked(Settings().value(self.settings_section + '/authentication enabled')) self.user_id.setText(Settings().value(self.settings_section + '/user id')) self.password.setText(Settings().value(self.settings_section + '/password')) self.set_urls() - self.https_changed() def save(self): """ Save the configuration and update the server configuration if necessary """ if Settings().value(self.settings_section + '/ip address') != self.address_edit.text() or \ - Settings().value(self.settings_section + '/port') != self.port_spin_box.value() or \ - Settings().value(self.settings_section + '/https port') != self.https_port_spin_box.value() or \ - Settings().value(self.settings_section + '/https enabled') != \ - self.https_settings_group_box.isChecked(): + Settings().value(self.settings_section + '/port') != self.port_spin_box.value(): self.settings_form.register_post_process('remotes_config_updated') Settings().setValue(self.settings_section + '/port', self.port_spin_box.value()) - Settings().setValue(self.settings_section + '/https port', self.https_port_spin_box.value()) - Settings().setValue(self.settings_section + '/https enabled', self.https_settings_group_box.isChecked()) Settings().setValue(self.settings_section + '/ip address', self.address_edit.text()) Settings().setValue(self.settings_section + '/twelve hour', self.twelve_hour) Settings().setValue(self.settings_section + '/thumbnails', self.thumbnails) @@ -317,12 +247,6 @@ class RemoteTab(SettingsTab): if check_state == QtCore.Qt.Checked: self.thumbnails = True - def https_changed(self): - """ - Invert the HTTP group box based on Https group settings - """ - self.http_settings_group_box.setEnabled(not self.https_settings_group_box.isChecked()) - def generate_icon(self): """ Generate icon for main window @@ -330,12 +254,6 @@ class RemoteTab(SettingsTab): self.remote_server_icon.hide() icon = QtGui.QImage(':/remote/network_server.png') icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - if self.is_secure: - overlay = QtGui.QImage(':/remote/network_ssl.png') - overlay = overlay.scaled(60, 60, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - painter = QtGui.QPainter(icon) - painter.drawImage(0, 0, overlay) - painter.end() if Settings().value(self.settings_section + '/authentication enabled'): overlay = QtGui.QImage(':/remote/network_auth.png') overlay = overlay.scaled(60, 60, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) diff --git a/tests/functional/openlp_plugins/remotes/test_remotetab.py b/tests/functional/openlp_plugins/remotes/test_remotetab.py index 6965503a2..2dfd41aa3 100644 --- a/tests/functional/openlp_plugins/remotes/test_remotetab.py +++ b/tests/functional/openlp_plugins/remotes/test_remotetab.py @@ -37,8 +37,6 @@ from tests.helpers.testmixin import TestMixin __default_settings__ = { 'remotes/twelve hour': True, 'remotes/port': 4316, - 'remotes/https port': 4317, - 'remotes/https enabled': False, 'remotes/user id': 'openlp', 'remotes/password': 'password', 'remotes/authentication enabled': False, @@ -85,7 +83,6 @@ class TestRemoteTab(TestCase, TestMixin): """ Test the get_ip_address function with given ip address """ - # GIVEN: A mocked location # GIVEN: An ip address given_ip = '192.168.1.1' # WHEN: the default ip address is given @@ -114,36 +111,24 @@ class TestRemoteTab(TestCase, TestMixin): self.form.set_urls() # THEN: the following screen values should be set self.assertEqual(self.form.address_edit.text(), ZERO_URL, 'The default URL should be set on the screen') - self.assertEqual(self.form.https_settings_group_box.isEnabled(), False, - 'The Https box should not be enabled') - self.assertEqual(self.form.https_settings_group_box.isChecked(), False, - 'The Https checked box should note be Checked') self.assertEqual(self.form.user_login_group_box.isChecked(), False, 'The authentication box should not be enabled') - def test_set_certificate_urls(self): + def test_set_urls(self): """ - Test the set_urls function with certificate available + Test the set_url function to generate correct url links """ - # GIVEN: A mocked location - with patch('openlp.core.common.Settings') as mocked_class, \ - patch('openlp.core.common.applocation.AppLocation.get_directory') as mocked_get_directory, \ - patch('openlp.core.common.check_directory_exists') as mocked_check_directory_exists, \ - patch('openlp.core.common.applocation.os') as mocked_os: - # GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory() - mocked_settings = mocked_class.return_value - mocked_settings.contains.return_value = False - mocked_get_directory.return_value = TEST_PATH - mocked_check_directory_exists.return_value = True - mocked_os.path.normpath.return_value = TEST_PATH - - # WHEN: when the set_urls is called having reloaded the form. - self.form.load() - self.form.set_urls() - # THEN: the following screen values should be set - self.assertEqual(self.form.http_settings_group_box.isEnabled(), True, - 'The Http group box should be enabled') - self.assertEqual(self.form.https_settings_group_box.isChecked(), False, - 'The Https checked box should be Checked') - self.assertEqual(self.form.https_settings_group_box.isEnabled(), True, - 'The Https box should be enabled') + # GIVEN: An ip address + self.form.address_edit.setText('192.168.1.1') + # WHEN: the urls are generated + self.form.set_urls() + # THEN: the following links are returned + self.assertEqual(self.form.remote_url.text(), + "http://192.168.1.1:4316/", + 'The return value should be a fully formed link') + self.assertEqual(self.form.stage_url.text(), + "http://192.168.1.1:4316/stage", + 'The return value should be a fully formed stage link') + self.assertEqual(self.form.live_url.text(), + "http://192.168.1.1:4316/main", + 'The return value should be a fully formed main link') diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 6f1f27740..670f100de 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -35,8 +35,6 @@ from tests.helpers.testmixin import TestMixin __default_settings__ = { 'remotes/twelve hour': True, 'remotes/port': 4316, - 'remotes/https port': 4317, - 'remotes/https enabled': False, 'remotes/user id': 'openlp', 'remotes/password': 'password', 'remotes/authentication enabled': False, diff --git a/tests/resources/remotes/openlp.crt b/tests/resources/remotes/openlp.crt deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/resources/remotes/openlp.key b/tests/resources/remotes/openlp.key deleted file mode 100644 index e69de29bb..000000000