openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #28304
[Merge] lp:~alisonken1/openlp/ticket-921817 into lp:openlp
Ken Roberts has proposed merging lp:~alisonken1/openlp/ticket-921817 into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Tomas Groth (tomasgroth)
For more details, see:
https://code.launchpad.net/~alisonken1/openlp/ticket-921817/+merge/282100
Ticket 921817 - exception when connecting using PJLink authentication method
Fix typo in authenticated request method call.
Passes local nosetests3 and pep8.
--
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/projector/pjlink1.py'
--- openlp/core/lib/projector/pjlink1.py 2015-12-31 22:46:06 +0000
+++ openlp/core/lib/projector/pjlink1.py 2016-01-09 17:26:11 +0000
@@ -101,7 +101,7 @@
self.location = None
self.notes = None
self.dbid = None if 'dbid' not in kwargs else kwargs['dbid']
- self.location = None if 'location' not in kwargs else kwargs['notes']
+ self.location = None if 'location' not in kwargs else kwargs['location']
self.notes = None if 'notes' not in kwargs else kwargs['notes']
# Poll time 20 seconds unless called with something else
self.poll_time = 20000 if 'poll_time' not in kwargs else kwargs['poll_time'] * 1000
@@ -345,7 +345,7 @@
# Authenticated login with salt
log.debug('(%s) Setting hash with salt="%s"' % (self.ip, data_check[2]))
log.debug('(%s) pin="%s"' % (self.ip, self.pin))
- salt = qmd5_hash(salt=data_check[2].endcode('ascii'), data=self.pin.encode('ascii'))
+ salt = qmd5_hash(salt=data_check[2].encode('ascii'), data=self.pin.encode('ascii'))
else:
salt = None
# We're connected at this point, so go ahead and do regular I/O
=== modified file 'tests/functional/openlp_core_common/test_projector_utilities.py'
--- tests/functional/openlp_core_common/test_projector_utilities.py 2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_core_common/test_projector_utilities.py 2016-01-09 17:26:11 +0000
@@ -29,9 +29,10 @@
from openlp.core.common import verify_ip_address, md5_hash, qmd5_hash
-salt = '498e4a67'
-pin = 'JBMIAProjectorLink'
-test_hash = '5d8409bc1c3fa39749434aa3a5c38682'
+from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_HASH
+salt = TEST_SALT
+pin = TEST_PIN
+test_hash = TEST_HASH
test_non_ascii_string = '이것은 한국어 시험 문자열'
test_non_ascii_hash = 'fc00c7912976f6e9c19099b514ced201'
=== added file 'tests/functional/openlp_core_lib/test_projector_pjlink1.py'
--- tests/functional/openlp_core_lib/test_projector_pjlink1.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-01-09 17:26:11 +0000
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2015 OpenLP Developers #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+"""
+Package to test the openlp.core.lib.projector.pjlink1 package.
+"""
+
+from unittest import TestCase
+
+from mock import MagicMock, patch
+
+from openlp.core.lib.projector.pjlink1 import PJLink1
+
+from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE
+
+pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True)
+
+
+class TestPJLink(TestCase):
+ """
+ Tests for the PJLink module
+ """
+ @patch.object(pjlink_test, 'readyRead')
+ @patch.object(pjlink_test, 'send_command')
+ @patch.object(pjlink_test, 'waitForReadyRead')
+ @patch('openlp.core.common.qmd5_hash')
+ def ticket_92187_test(self,
+ mock_qmd5_hash,
+ mock_waitForReadyRead,
+ mock_send_command,
+ mock_readyRead):
+ """
+ Fix for projector connect with PJLink authentication exception
+ """
+ # GIVEN: Test object
+ pjlink = pjlink_test
+
+ # WHEN: Calling check_login with authentication request:
+ pjlink.check_login(data=TEST_CONNECT_AUTHENTICATE)
+
+ # THEN: Should have called qmd5_hash
+ self.assertTrue(mock_qmd5_hash.called_with(TEST_SALT,
+ "Connection request should have been called with TEST_SALT"))
+ self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN,
+ "Connection request should have been called with TEST_PIN"))
=== modified file 'tests/resources/projector/data.py'
--- tests/resources/projector/data.py 2016-01-07 21:07:55 +0000
+++ tests/resources/projector/data.py 2016-01-09 17:26:11 +0000
@@ -29,6 +29,16 @@
# Test data
TEST_DB = os.path.join(gettempdir(), 'openlp-test-projectordb.sql')
+TEST_SALT = '498e4a67'
+
+TEST_PIN = 'JBMIAProjectorLink'
+
+TEST_HASH = '5d8409bc1c3fa39749434aa3a5c38682'
+
+TEST_CONNECT_AUTHENTICATE = 'PJLink 1 {salt}'.format(salt=TEST_SALT)
+
+TEST_DB = os.path.join(gettempdir(), 'openlp-test-projectordb.sql')
+
TEST1_DATA = dict(ip='111.111.111.111',
port='1111',
pin='1111',
@@ -49,3 +59,4 @@
name='___TEST_THREE___',
location='location three',
notes='notes three')
+
Follow ups