30
30
S_COOLDOWN, PJLINK_POWR_STATUS
32
32
from tests.functional import patch
33
from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE
33
from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE, TEST_HASH
35
35
pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True)
332
332
self.assertFalse(pjlink.send_busy, 'Projector send_busy should be False')
333
333
self.assertTrue(mock_timer.called, 'Projector timer.stop() should have been called')
334
334
self.assertTrue(mock_socket_timer.called, 'Projector socket_timer.stop() should have been called')
336
@patch.object(pjlink_test, 'send_command')
337
@patch.object(pjlink_test, 'waitForReadyRead')
338
@patch.object(pjlink_test, 'projectorAuthentication')
339
@patch.object(pjlink_test, 'timer')
340
@patch.object(pjlink_test, 'socket_timer')
341
def test_bug_1593882_no_pin_authenticated_connection(self, mock_socket_timer,
347
Test bug 1593882 no pin and authenticated request exception
349
# GIVEN: Test object and mocks
352
mock_ready_read.return_value = True
354
# WHEN: call with authentication request and pin not set
355
pjlink.check_login(data=TEST_CONNECT_AUTHENTICATE)
357
# THEN: No Authentication signal should have been sent
358
mock_authentication.emit.assert_called_with(pjlink.name)
360
@patch.object(pjlink_test, 'waitForReadyRead')
361
@patch.object(pjlink_test, 'state')
362
@patch.object(pjlink_test, '_send_command')
363
@patch.object(pjlink_test, 'timer')
364
@patch.object(pjlink_test, 'socket_timer')
365
def test_bug_1593883_pjlink_authentication(self, mock_socket_timer,
369
mock_waitForReadyRead):
371
Test bugfix 1593883 pjlink authentication
373
# GIVEN: Test object and data
375
pjlink.pin = TEST_PIN
376
mock_state.return_value = pjlink.ConnectedState
377
mock_waitForReadyRead.return_value = True
379
# WHEN: Athenticated connection is called
380
pjlink.check_login(data=TEST_CONNECT_AUTHENTICATE)
382
# THEN: send_command should have the proper authentication
383
self.assertEquals("{test}".format(test=mock_send_command.call_args),
384
"call(data='{hash}%1CLSS ?\\r')".format(hash=TEST_HASH))