diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index e5db478c2..3e9a8b422 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -352,7 +352,7 @@ class PJLink1(QTcpSocket): return elif data_check[1] == '1': # Authenticated login with salt - if pin is None: + if self.pin is None: log.warning('({ip}) Authenticated connection but no pin set'.format(ip=self.name)) self.disconnect_from_host() self.change_status(E_AUTHENTICATION) @@ -362,7 +362,7 @@ class PJLink1(QTcpSocket): else: log.debug('({ip}) Setting hash with salt="{data}"'.format(ip=self.ip, data=data_check[2])) log.debug('({ip}) pin="{data}"'.format(ip=self.ip, data=self.pin)) - salt = qmd5_hash(salt=data_check[2].encode('ascii'), data=self.pin.encode('ascii')) + salt = qmd5_hash(salt=data_check[2].encode('ascii'), data=self.pin.encode('ascii')).encode('utf-8') else: salt = None # We're connected at this point, so go ahead and do regular I/O diff --git a/tests/functional/openlp_core_lib/test_projector_pjlink1.py b/tests/functional/openlp_core_lib/test_projector_pjlink1.py index 4928e5d0c..6cdff4ff6 100644 --- a/tests/functional/openlp_core_lib/test_projector_pjlink1.py +++ b/tests/functional/openlp_core_lib/test_projector_pjlink1.py @@ -332,3 +332,27 @@ class TestPJLink(TestCase): self.assertFalse(pjlink.send_busy, 'Projector send_busy should be False') self.assertTrue(mock_timer.called, 'Projector timer.stop() should have been called') self.assertTrue(mock_socket_timer.called, 'Projector socket_timer.stop() should have been called') + + @patch.object(pjlink_test, 'send_command') + @patch.object(pjlink_test, 'waitForReadyRead') + @patch.object(pjlink_test, 'projectorNoAuthentication') + @patch.object(pjlink_test, 'timer') + @patch.object(pjlink_test, 'socket_timer') + def test_bug_1593882_no_pin_authenticated_connection(self, mock_socket_timer, + mock_timer, + mock_no_authentication, + mock_ready_read, + mock_send_command): + """ + Test bug 1593882 no pin and authenticated request exception + """ + # GIVEN: Test object and mocks + pjlink = pjlink_test + pjlink.pin = None + mock_ready_read.return_value = True + + # WHEN: call with authentication request and pin not set + pjlink.check_login(data='PJLink 1 123abc') + + # THEN: No Authentication signal should have been sent + mock_no_authentication.called_with(pjlink.name, 'projectorNoAuthentication should have been called')