Sync from SUSE:SLFO:Main python-pyu2f revision 0c70e84185adef02533048ff5421310f

This commit is contained in:
Adrian Schröter 2024-05-03 22:40:00 +02:00
commit 18044250f9
8 changed files with 1067 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,59 @@
From 5e2f862dd5ba61eadff341dbf0a1202e91b1b145 Mon Sep 17 00:00:00 2001
From: Cary Zhao <zhaosukima@gmail.com>
Date: Mon, 22 Nov 2021 10:42:06 -0800
Subject: [PATCH] fix DeprecationWarning for logging and fake_filesystem
---
pyu2f/hid/macos.py | 2 +-
pyu2f/tests/hid/linux_test.py | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
Index: pyu2f-0.1.5a/pyu2f/hid/macos.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/hid/macos.py
+++ pyu2f-0.1.5a/pyu2f/hid/macos.py
@@ -174,7 +174,7 @@ if sys.platform.startswith('darwin'):
ctypes.POINTER(ctypes.c_uint8),
CF_INDEX]
else:
- logger.warn('Not running on MacOS')
+ logger.warning('Not running on MacOS')
def CFStr(s):
Index: pyu2f-0.1.5a/pyu2f/tests/hid/linux_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/hid/linux_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/hid/linux_test.py
@@ -49,14 +49,14 @@ KEYBOARD_RD = (
def AddDevice(fs, dev_name, product_name,
vendor_id, product_id, report_descriptor_b64):
- uevent = fs.CreateFile('/sys/class/hidraw/%s/device/uevent' % dev_name)
- rd = fs.CreateFile('/sys/class/hidraw/%s/device/report_descriptor' % dev_name)
+ uevent = fs.create_file('/sys/class/hidraw/%s/device/uevent' % dev_name)
+ rd = fs.create_file('/sys/class/hidraw/%s/device/report_descriptor' % dev_name)
report_descriptor = base64.b64decode(report_descriptor_b64)
- rd.SetContents(report_descriptor)
+ rd.set_contents(report_descriptor)
buf = 'HID_NAME=%s\n' % product_name.encode('utf8')
buf += 'HID_ID=0001:%08X:%08X\n' % (vendor_id, product_id)
- uevent.SetContents(buf)
+ uevent.set_contents(buf)
class FakeDeviceOsModule(object):
@@ -79,10 +79,10 @@ class FakeDeviceOsModule(object):
class LinuxTest(unittest.TestCase):
def setUp(self):
self.fs = fake_filesystem.FakeFilesystem()
- self.fs.CreateDirectory('/sys/class/hidraw')
+ self.fs.create_dir('/sys/class/hidraw')
def tearDown(self):
- self.fs.RemoveObject('/sys/class/hidraw')
+ self.fs.remove_object('/sys/class/hidraw')
def testCallEnumerate(self):
AddDevice(self.fs, 'hidraw1', 'Logitech USB Keyboard',

71
python-pyu2f-no-six.patch Normal file
View File

@ -0,0 +1,71 @@
Index: pyu2f-0.1.5a/pyu2f/convenience/localauthenticator.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/convenience/localauthenticator.py
+++ pyu2f-0.1.5a/pyu2f/convenience/localauthenticator.py
@@ -13,7 +13,6 @@
# limitations under the License.
"""Convenience class for U2F signing with local security keys."""
-import six
import base64
import sys
@@ -36,7 +35,7 @@ class LocalAuthenticator(baseauthenticat
device = u2f.GetLocalU2FInterface(origin=self.origin)
except errors.NoDeviceFoundError:
print_callback('Please insert your security key and press enter...')
- six.moves.input()
+ input()
device = u2f.GetLocalU2FInterface(origin=self.origin)
print_callback('Please touch your security key.\n')
Index: pyu2f-0.1.5a/pyu2f/hid/macos.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/hid/macos.py
+++ pyu2f-0.1.5a/pyu2f/hid/macos.py
@@ -13,8 +13,7 @@
# limitations under the License.
"""Implements HID device interface on MacOS using IOKit and HIDManager."""
-from six.moves import queue
-from six.moves import range
+import queue
import ctypes
import ctypes.util
import logging
Index: pyu2f-0.1.5a/pyu2f/tests/apdu_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/apdu_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/apdu_test.py
@@ -14,7 +14,6 @@
"""Tests for pyu2f.apdu."""
-from six.moves import range
import sys
from pyu2f import apdu
Index: pyu2f-0.1.5a/pyu2f/tests/hidtransport_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/hidtransport_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/hidtransport_test.py
@@ -14,7 +14,6 @@
"""Tests for pyu2f.hidtransport."""
-from six.moves import range
import sys
import mock
Index: pyu2f-0.1.5a/pyu2f/tests/util_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/util_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/util_test.py
@@ -14,7 +14,6 @@
"""Tests for pyu2f.tests.lib.util."""
-from six.moves import range
import sys
from pyu2f.tests.lib import util

47
python-pyu2f.changes Normal file
View File

@ -0,0 +1,47 @@
-------------------------------------------------------------------
Tue Oct 17 07:32:00 UTC 2023 - Daniel Garcia Moreno <daniel.garcia@suse.com>
- Use upstream patches instead of custom one for python312
compatibility.
- drop python312.patch
- add python312-1.patch gh#google/pyu2f@793acd9ff661
- add python312-2.patch gh#google/pyu2f@dad654010a03
-------------------------------------------------------------------
Tue Oct 17 07:18:36 UTC 2023 - Daniel Garcia Moreno <daniel.garcia@suse.com>
- Add python312.patch to fix tests in python3.12
-------------------------------------------------------------------
Fri Apr 21 12:32:28 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Thu Apr 13 22:44:20 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Make calling of %{sle15modernpython} optional.
-------------------------------------------------------------------
Mon Dec 12 14:56:04 UTC 2022 - pgajdos@suse.com
- do not require six
- added patches
fix https://github.com/google/pyu2f/issues/34
+ python-pyu2f-no-six.patch
-------------------------------------------------------------------
Tue Nov 1 09:26:18 UTC 2022 - Markéta Machová <mmachova@suse.com>
- Add upstream fix-deprecation-warning.patch to fix compatibility
-------------------------------------------------------------------
Tue Apr 12 08:56:31 UTC 2022 - Markéta Machová <mmachova@suse.com>
- do not use mock
-------------------------------------------------------------------
Fri Aug 20 08:28:27 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Initial build
+ Version 0.1.5a

68
python-pyu2f.spec Normal file
View File

@ -0,0 +1,68 @@
#
# spec file for package python-pyu2f
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%{?sle15_python_module_pythons}
Name: python-pyu2f
Version: 0.1.5a
Release: 0
Summary: U2F host library for interacting with a U2F device over USB
License: Apache-2.0
URL: https://github.com/google/pyu2f/
Source: https://github.com/google/pyu2f/archive/refs/tags/%{version}.tar.gz#/pyu2f-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/google/pyu2f/pull/32 fix DeprecationWarning for logging and fake_filesystem
Patch: fix-deprecation-warning.patch
# https://github.com/google/pyu2f/issues/34
Patch1: python-pyu2f-no-six.patch
# PATCH-FIX-UPSTREAM python312-1.patch gh#google/pyu2f@793acd9ff661
Patch2: python312-1.patch
# PATCH-FIX-UPSTREAM python312-2.patch gh#google/pyu2f@dad654010a03
Patch3: python312-2.patch
BuildRequires: %{python_module setuptools}
BuildRequires: python-rpm-macros
# SECTION test requirements
BuildRequires: %{python_module pyfakefs >= 2.4}
BuildRequires: %{python_module pytest}
# /SECTION
BuildRequires: fdupes
BuildArch: noarch
%python_subpackages
%description
U2F host library for interacting with a U2F device over USB.
%prep
%autosetup -p1 -n pyu2f-%{version}
sed -i 's/import mock/from unittest import mock/' pyu2f/tests/*_test.py pyu2f/tests/hid/*_test.py
%build
%python_build
%check
%pytest
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%files %{python_files}
%doc README.md
%license LICENSE
%{python_sitelib}/*
%changelog

771
python312-1.patch Normal file
View File

@ -0,0 +1,771 @@
From dad654010a030f1038bd2df95a9647fb417e0447 Mon Sep 17 00:00:00 2001
From: Felix Yan <felixonmars@archlinux.org>
Date: Mon, 2 Aug 2021 17:11:20 +0800
Subject: [PATCH] Fix warnings about assertEquals
Example:
```
pyu2f/tests/hid/macos_test.py::MacOsTest::testInitHidDevice
/build/python-pyu2f/src/pyu2f-0.1.5/pyu2f/tests/hid/macos_test.py:61: DeprecationWarning: Please use assertEqual instead.
self.assertEquals(64, device.GetOutReportDataLength())
```
---
pyu2f/tests/customauthenticator_test.py | 48 ++++++------
pyu2f/tests/hardware_test.py | 56 ++++++-------
pyu2f/tests/hid/linux_test.py | 24 +++---
pyu2f/tests/hid/macos_test.py | 18 ++---
pyu2f/tests/hidtransport_test.py | 44 +++++------
pyu2f/tests/localauthenticator_test.py | 34 ++++----
pyu2f/tests/model_test.py | 16 ++--
pyu2f/tests/u2f_test.py | 100 ++++++++++++------------
pyu2f/tests/util_test.py | 12 +--
9 files changed, 176 insertions(+), 176 deletions(-)
Index: pyu2f-0.1.5a/pyu2f/tests/customauthenticator_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/customauthenticator_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/customauthenticator_test.py
@@ -122,44 +122,44 @@ class CustomAuthenticatorTest(unittest.T
self.assertTrue(mock_communicate_method.called)
communicate_args = mock_communicate_method.call_args[0]
- self.assertEquals(len(communicate_args), 1,
- 'communicate() should have been called with two args')
+ self.assertEqual(len(communicate_args), 1,
+ 'communicate() should have been called with two args')
communicate_stdin = communicate_args[0]
communicate_json_len_le = communicate_stdin[:4]
communicate_json_len = struct.unpack('<I', communicate_json_len_le)[0]
communicate_json = communicate_stdin[4:]
- self.assertEquals(len(communicate_json), communicate_json_len,
- 'communicate() should have been called with correct'
- 'length field')
+ self.assertEqual(len(communicate_json), communicate_json_len,
+ 'communicate() should have been called with correct'
+ 'length field')
communicate_dict = json.loads(communicate_json.decode("utf8"))
- self.assertEquals(communicate_dict.get('type'), 'sign_helper_request')
- self.assertEquals(communicate_dict.get('timeoutSeconds'), 5)
- self.assertEquals(communicate_dict.get('localAlways'), True)
+ self.assertEqual(communicate_dict.get('type'), 'sign_helper_request')
+ self.assertEqual(communicate_dict.get('timeoutSeconds'), 5)
+ self.assertEqual(communicate_dict.get('localAlways'), True)
challenges = communicate_dict.get('signData')
# Validate Challenge portion of plugin request
self.assertIsNotNone(challenges)
- self.assertEquals(len(challenges), 1)
+ self.assertEqual(len(challenges), 1)
challenge = challenges[0]
- self.assertEquals(challenge.get('appIdHash'),
- SIGN_SUCCESS['app_id_hash_encoded'])
- self.assertEquals(challenge.get('challengeHash'),
- SIGN_SUCCESS['challenge_hash_encoded'])
- self.assertEquals(challenge.get('keyHandle'),
- SIGN_SUCCESS['key_handle_encoded'])
- self.assertEquals(challenge.get('version'),
- SIGN_SUCCESS['u2f_version'])
+ self.assertEqual(challenge.get('appIdHash'),
+ SIGN_SUCCESS['app_id_hash_encoded'])
+ self.assertEqual(challenge.get('challengeHash'),
+ SIGN_SUCCESS['challenge_hash_encoded'])
+ self.assertEqual(challenge.get('keyHandle'),
+ SIGN_SUCCESS['key_handle_encoded'])
+ self.assertEqual(challenge.get('version'),
+ SIGN_SUCCESS['u2f_version'])
mock_wait_method.assert_called_with()
# Validate Authenticate() response
- self.assertEquals(result['applicationId'], SIGN_SUCCESS['app_id'])
- self.assertEquals(result['clientData'], SIGN_SUCCESS['client_data_encoded'])
- self.assertEquals(result['keyHandle'], SIGN_SUCCESS['key_handle_encoded'])
- self.assertEquals(result['signatureData'],
- SIGN_SUCCESS['signature_data_encoded'])
+ self.assertEqual(result['applicationId'], SIGN_SUCCESS['app_id'])
+ self.assertEqual(result['clientData'], SIGN_SUCCESS['client_data_encoded'])
+ self.assertEqual(result['keyHandle'], SIGN_SUCCESS['key_handle_encoded'])
+ self.assertEqual(result['signatureData'],
+ SIGN_SUCCESS['signature_data_encoded'])
@mock.patch.object(customauthenticator.subprocess, 'Popen')
@mock.patch.object(customauthenticator.os.environ, 'get',
@@ -323,7 +323,7 @@ class CustomAuthenticatorTest(unittest.T
with self.assertRaises(errors.U2FError) as cm:
authenticator.Authenticate(SIGN_SUCCESS['app_id'], challenge_data)
- self.assertEquals(cm.exception.code, errors.U2FError.TIMEOUT)
+ self.assertEqual(cm.exception.code, errors.U2FError.TIMEOUT)
@mock.patch.object(customauthenticator.subprocess, 'Popen')
@mock.patch.object(customauthenticator.os.environ, 'get',
@@ -369,7 +369,7 @@ class CustomAuthenticatorTest(unittest.T
with self.assertRaises(errors.U2FError) as cm:
authenticator.Authenticate(SIGN_SUCCESS['app_id'], challenge_data)
- self.assertEquals(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
+ self.assertEqual(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
if __name__ == '__main__':
Index: pyu2f-0.1.5a/pyu2f/tests/hardware_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/hardware_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/hardware_test.py
@@ -60,11 +60,11 @@ class HardwareTest(unittest.TestCase):
[0x01, 0x02, 0x90, 0x00])
reply = sk.CmdRegister(challenge_param, app_param)
- self.assertEquals(reply, bytearray([0x01, 0x02]))
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(reply, bytearray([0x01, 0x02]))
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
(sent_msg,), _ = mock_transport.SendMsgBytes.call_args
- self.assertEquals(sent_msg[0:4], bytearray([0x00, 0x01, 0x03, 0x00]))
- self.assertEquals(sent_msg[7:-2], bytearray(challenge_param + app_param))
+ self.assertEqual(sent_msg[0:4], bytearray([0x00, 0x01, 0x03, 0x00]))
+ self.assertEqual(sent_msg[7:-2], bytearray(challenge_param + app_param))
def testRegisterTUPRequired(self):
mock_transport = mock.MagicMock()
@@ -77,7 +77,7 @@ class HardwareTest(unittest.TestCase):
self.assertRaises(errors.TUPRequiredError, sk.CmdRegister, challenge_param,
app_param)
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
def testVersion(self):
mock_transport = mock.MagicMock()
@@ -86,10 +86,10 @@ class HardwareTest(unittest.TestCase):
mock_transport.SendMsgBytes.return_value = bytearray(b'U2F_V2\x90\x00')
reply = sk.CmdVersion()
- self.assertEquals(reply, bytearray(b'U2F_V2'))
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(reply, bytearray(b'U2F_V2'))
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
(sent_msg,), _ = mock_transport.SendMsgBytes.call_args
- self.assertEquals(sent_msg, bytearray(
+ self.assertEqual(sent_msg, bytearray(
[0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00]))
def testVersionFallback(self):
@@ -101,17 +101,17 @@ class HardwareTest(unittest.TestCase):
bytearray(b'U2F_V2\x90\x00')]
reply = sk.CmdVersion()
- self.assertEquals(reply, bytearray(b'U2F_V2'))
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 2)
+ self.assertEqual(reply, bytearray(b'U2F_V2'))
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 2)
(sent_msg,), _ = mock_transport.SendMsgBytes.call_args_list[0]
- self.assertEquals(len(sent_msg), 7)
- self.assertEquals(sent_msg[0:4], bytearray([0x00, 0x03, 0x00, 0x00]))
- self.assertEquals(sent_msg[4:7], bytearray([0x00, 0x00, 0x00])) # Le
+ self.assertEqual(len(sent_msg), 7)
+ self.assertEqual(sent_msg[0:4], bytearray([0x00, 0x03, 0x00, 0x00]))
+ self.assertEqual(sent_msg[4:7], bytearray([0x00, 0x00, 0x00])) # Le
(sent_msg,), _ = mock_transport.SendMsgBytes.call_args_list[1]
- self.assertEquals(len(sent_msg), 9)
- self.assertEquals(sent_msg[0:4], bytearray([0x00, 0x03, 0x00, 0x00]))
- self.assertEquals(sent_msg[4:7], bytearray([0x00, 0x00, 0x00])) # Lc
- self.assertEquals(sent_msg[7:9], bytearray([0x00, 0x00])) # Le
+ self.assertEqual(len(sent_msg), 9)
+ self.assertEqual(sent_msg[0:4], bytearray([0x00, 0x03, 0x00, 0x00]))
+ self.assertEqual(sent_msg[4:7], bytearray([0x00, 0x00, 0x00])) # Lc
+ self.assertEqual(sent_msg[7:9], bytearray([0x00, 0x00])) # Le
def testVersionErrors(self):
mock_transport = mock.MagicMock()
@@ -120,7 +120,7 @@ class HardwareTest(unittest.TestCase):
mock_transport.SendMsgBytes.return_value = bytearray([0xfa, 0x05])
self.assertRaises(errors.ApduError, sk.CmdVersion)
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
def testAuthenticateSuccess(self):
mock_transport = mock.MagicMock()
@@ -134,11 +134,11 @@ class HardwareTest(unittest.TestCase):
[0x01, 0x02, 0x90, 0x00])
reply = sk.CmdAuthenticate(challenge_param, app_param, key_handle)
- self.assertEquals(reply, bytearray([0x01, 0x02]))
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(reply, bytearray([0x01, 0x02]))
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
(sent_msg,), _ = mock_transport.SendMsgBytes.call_args
- self.assertEquals(sent_msg[0:4], bytearray([0x00, 0x02, 0x03, 0x00]))
- self.assertEquals(
+ self.assertEqual(sent_msg[0:4], bytearray([0x00, 0x02, 0x03, 0x00]))
+ self.assertEqual(
sent_msg[7:-2],
bytearray(challenge_param + app_param + bytearray([4, 1, 2, 3, 4])))
@@ -157,11 +157,11 @@ class HardwareTest(unittest.TestCase):
app_param,
key_handle,
check_only=True)
- self.assertEquals(reply, bytearray([0x01, 0x02]))
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(reply, bytearray([0x01, 0x02]))
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
(sent_msg,), _ = mock_transport.SendMsgBytes.call_args
- self.assertEquals(sent_msg[0:4], bytearray([0x00, 0x02, 0x07, 0x00]))
- self.assertEquals(
+ self.assertEqual(sent_msg[0:4], bytearray([0x00, 0x02, 0x07, 0x00]))
+ self.assertEqual(
sent_msg[7:-2],
bytearray(challenge_param + app_param + bytearray([4, 1, 2, 3, 4])))
@@ -177,7 +177,7 @@ class HardwareTest(unittest.TestCase):
self.assertRaises(errors.TUPRequiredError, sk.CmdAuthenticate,
challenge_param, app_param, key_handle)
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
def testAuthenticateInvalidKeyHandle(self):
mock_transport = mock.MagicMock()
@@ -191,7 +191,7 @@ class HardwareTest(unittest.TestCase):
self.assertRaises(errors.InvalidKeyHandleError, sk.CmdAuthenticate,
challenge_param, app_param, key_handle)
- self.assertEquals(mock_transport.SendMsgBytes.call_count, 1)
+ self.assertEqual(mock_transport.SendMsgBytes.call_count, 1)
if __name__ == '__main__':
Index: pyu2f-0.1.5a/pyu2f/tests/hid/linux_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/hid/linux_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/hid/linux_test.py
@@ -94,13 +94,13 @@ class LinuxTest(unittest.TestCase):
devs = list(linux.LinuxHidDevice.Enumerate())
devs = sorted(devs, key=lambda k: (k['vendor_id']))
- self.assertEquals(len(devs), 2)
- self.assertEquals(devs[0]['vendor_id'], 0x046d)
- self.assertEquals(devs[0]['product_id'], 0x0c31c)
- self.assertEquals(devs[1]['vendor_id'], 0x1050)
- self.assertEquals(devs[1]['product_id'], 0x0407)
- self.assertEquals(devs[1]['usage_page'], 0xf1d0)
- self.assertEquals(devs[1]['usage'], 1)
+ self.assertEqual(len(devs), 2)
+ self.assertEqual(devs[0]['vendor_id'], 0x046d)
+ self.assertEqual(devs[0]['product_id'], 0x0c31c)
+ self.assertEqual(devs[1]['vendor_id'], 0x1050)
+ self.assertEqual(devs[1]['product_id'], 0x0407)
+ self.assertEqual(devs[1]['usage_page'], 0xf1d0)
+ self.assertEqual(devs[1]['usage'], 1)
def testCallOpen(self):
AddDevice(self.fs, 'hidraw1', 'Yubico U2F', 0x1050, 0x0407, YUBICO_RD)
@@ -112,17 +112,17 @@ class LinuxTest(unittest.TestCase):
fake_dev_os = FakeDeviceOsModule()
with mock.patch.object(linux, 'os', fake_dev_os):
dev = linux.LinuxHidDevice('/dev/hidraw1')
- self.assertEquals(dev.GetInReportDataLength(), 64)
- self.assertEquals(dev.GetOutReportDataLength(), 64)
+ self.assertEqual(dev.GetInReportDataLength(), 64)
+ self.assertEqual(dev.GetOutReportDataLength(), 64)
dev.Write(list(range(0, 64)))
# The HidDevice implementation prepends a zero-byte representing the
# report ID
- self.assertEquals(list(fake_dev_os.data_written),
- [0] + list(range(0, 64)))
+ self.assertEqual(list(fake_dev_os.data_written),
+ [0] + list(range(0, 64)))
fake_dev_os.data_to_return = b'x' * 64
- self.assertEquals(dev.Read(), [120] * 64) # chr(120) = 'x'
+ self.assertEqual(dev.Read(), [120] * 64) # chr(120) = 'x'
if __name__ == '__main__':
Index: pyu2f-0.1.5a/pyu2f/tests/hid/macos_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/hid/macos_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/hid/macos_test.py
@@ -57,8 +57,8 @@ class MacOsTest(unittest.TestCase):
device = macos.MacOsHidDevice('fakepath')
- self.assertEquals(64, device.GetInReportDataLength())
- self.assertEquals(64, device.GetOutReportDataLength())
+ self.assertEqual(64, device.GetInReportDataLength())
+ self.assertEqual(64, device.GetOutReportDataLength())
@mock.patch.object(macos.threading, 'Thread')
@mock.patch.multiple(macos, iokit=mock.DEFAULT, cf=mock.DEFAULT,
@@ -81,11 +81,11 @@ class MacOsTest(unittest.TestCase):
self.assertIsNotNone(set_report_call_args)
set_report_call_pos_args = iokit.IOHIDDeviceSetReport.call_args[0]
- self.assertEquals(len(set_report_call_pos_args), 5)
- self.assertEquals(set_report_call_pos_args[0], 'handle')
- self.assertEquals(set_report_call_pos_args[1], 1)
- self.assertEquals(set_report_call_pos_args[2], 0)
- self.assertEquals(set_report_call_pos_args[4], 64)
+ self.assertEqual(len(set_report_call_pos_args), 5)
+ self.assertEqual(set_report_call_pos_args[0], 'handle')
+ self.assertEqual(set_report_call_pos_args[1], 1)
+ self.assertEqual(set_report_call_pos_args[2], 0)
+ self.assertEqual(set_report_call_pos_args[4], 64)
report_buffer = set_report_call_pos_args[3]
self.assertEqual(len(report_buffer), 64)
@@ -131,8 +131,8 @@ class MacOsTest(unittest.TestCase):
# Device read should return the callback data
read_result = device.Read()
- self.assertEquals(read_result, list(range(64)), 'Read data should match '
- 'data passed into the callback')
+ self.assertEqual(read_result, list(range(64)), 'Read data should match '
+ 'data passed into the callback')
if __name__ == '__main__':
Index: pyu2f-0.1.5a/pyu2f/tests/hidtransport_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/hidtransport_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/hidtransport_test.py
@@ -88,12 +88,12 @@ class DiscoveryTest(unittest.TestCase):
# Force the iterator into a list
devs = list(hidtransport.DiscoverLocalHIDU2FDevices())
- self.assertEquals(hid_mock.Enumerate.call_count, 1)
- self.assertEquals(hid_mock.Open.call_count, 2)
- self.assertEquals(len(devs), 2)
+ self.assertEqual(hid_mock.Enumerate.call_count, 1)
+ self.assertEqual(hid_mock.Open.call_count, 2)
+ self.assertEqual(len(devs), 2)
- self.assertEquals(devs[0].hid_device.path, 'path3')
- self.assertEquals(devs[1].hid_device.path, 'path4')
+ self.assertEqual(devs[0].hid_device.path, 'path3')
+ self.assertEqual(devs[1].hid_device.path, 'path4')
class TransportTest(unittest.TestCase):
@@ -101,15 +101,15 @@ class TransportTest(unittest.TestCase):
def testInit(self):
fake_hid_dev = util.FakeHidDevice(bytearray([0x00, 0x00, 0x00, 0x01]))
t = hidtransport.UsbHidTransport(fake_hid_dev)
- self.assertEquals(t.cid, bytearray([0x00, 0x00, 0x00, 0x01]))
- self.assertEquals(t.u2fhid_version, 0x01)
+ self.assertEqual(t.cid, bytearray([0x00, 0x00, 0x00, 0x01]))
+ self.assertEqual(t.u2fhid_version, 0x01)
def testPing(self):
fake_hid_dev = util.FakeHidDevice(bytearray([0x00, 0x00, 0x00, 0x01]))
t = hidtransport.UsbHidTransport(fake_hid_dev)
reply = t.SendPing(b'1234')
- self.assertEquals(reply, b'1234')
+ self.assertEqual(reply, b'1234')
def testMsg(self):
fake_hid_dev = util.FakeHidDevice(
@@ -117,7 +117,7 @@ class TransportTest(unittest.TestCase):
t = hidtransport.UsbHidTransport(fake_hid_dev)
reply = t.SendMsgBytes([0x00, 0x01, 0x00, 0x00])
- self.assertEquals(reply, bytearray([0x01, 0x90, 0x00]))
+ self.assertEqual(reply, bytearray([0x01, 0x90, 0x00]))
def testMsgBusy(self):
fake_hid_dev = util.FakeHidDevice(
@@ -132,7 +132,7 @@ class TransportTest(unittest.TestCase):
[0x00, 0x01, 0x00, 0x00])
reply = t.SendMsgBytes([0x00, 0x01, 0x00, 0x00])
- self.assertEquals(reply, bytearray([0x01, 0x90, 0x00]))
+ self.assertEqual(reply, bytearray([0x01, 0x90, 0x00]))
def testFragmentedResponseMsg(self):
body = bytearray([x % 256 for x in range(0, 1000)])
@@ -141,7 +141,7 @@ class TransportTest(unittest.TestCase):
reply = t.SendMsgBytes([0x00, 0x01, 0x00, 0x00])
# Confirm we properly reassemble the message
- self.assertEquals(reply, bytearray(x % 256 for x in range(0, 1000)))
+ self.assertEqual(reply, bytearray(x % 256 for x in range(0, 1000)))
def testFragmentedSendApdu(self):
body = bytearray(x % 256 for x in range(0, 1000))
@@ -150,36 +150,36 @@ class TransportTest(unittest.TestCase):
t = hidtransport.UsbHidTransport(fake_hid_dev)
reply = t.SendMsgBytes(body)
- self.assertEquals(reply, bytearray([0x90, 0x00]))
+ self.assertEqual(reply, bytearray([0x90, 0x00]))
# 1 init packet from creating transport, 18 packets to send
# the fragmented message
- self.assertEquals(len(fake_hid_dev.received_packets), 18)
+ self.assertEqual(len(fake_hid_dev.received_packets), 18)
def testInitPacketShape(self):
packet = hidtransport.UsbHidTransport.InitPacket(
64, bytearray(b'\x00\x00\x00\x01'), 0x83, 2, bytearray(b'\x01\x02'))
- self.assertEquals(packet.ToWireFormat(), RPad(
+ self.assertEqual(packet.ToWireFormat(), RPad(
[0, 0, 0, 1, 0x83, 0, 2, 1, 2], 64))
copy = hidtransport.UsbHidTransport.InitPacket.FromWireFormat(
64, packet.ToWireFormat())
- self.assertEquals(copy.cid, bytearray(b'\x00\x00\x00\x01'))
- self.assertEquals(copy.cmd, 0x83)
- self.assertEquals(copy.size, 2)
- self.assertEquals(copy.payload, bytearray(b'\x01\x02'))
+ self.assertEqual(copy.cid, bytearray(b'\x00\x00\x00\x01'))
+ self.assertEqual(copy.cmd, 0x83)
+ self.assertEqual(copy.size, 2)
+ self.assertEqual(copy.payload, bytearray(b'\x01\x02'))
def testContPacketShape(self):
packet = hidtransport.UsbHidTransport.ContPacket(
64, bytearray(b'\x00\x00\x00\x01'), 5, bytearray(b'\x01\x02'))
- self.assertEquals(packet.ToWireFormat(), RPad([0, 0, 0, 1, 5, 1, 2], 64))
+ self.assertEqual(packet.ToWireFormat(), RPad([0, 0, 0, 1, 5, 1, 2], 64))
copy = hidtransport.UsbHidTransport.ContPacket.FromWireFormat(
64, packet.ToWireFormat())
- self.assertEquals(copy.cid, bytearray(b'\x00\x00\x00\x01'))
- self.assertEquals(copy.seq, 5)
- self.assertEquals(copy.payload, RPad(bytearray(b'\x01\x02'), 59))
+ self.assertEqual(copy.cid, bytearray(b'\x00\x00\x00\x01'))
+ self.assertEqual(copy.seq, 5)
+ self.assertEqual(copy.payload, RPad(bytearray(b'\x01\x02'), 59))
if __name__ == '__main__':
Index: pyu2f-0.1.5a/pyu2f/tests/localauthenticator_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/localauthenticator_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/localauthenticator_test.py
@@ -92,14 +92,14 @@ class LocalAuthenticatorTest(unittest.Te
self.assertEqual(registered_keys[0], SIGN_SUCCESS['registered_key'])
# Validate authenticator response
- self.assertEquals(response.get('clientData'),
- SIGN_SUCCESS['client_data_encoded'])
- self.assertEquals(response.get('signatureData'),
- SIGN_SUCCESS['signature_data_encoded'])
- self.assertEquals(response.get('applicationId'),
- SIGN_SUCCESS['app_id'])
- self.assertEquals(response.get('keyHandle'),
- SIGN_SUCCESS['key_handle_encoded'])
+ self.assertEqual(response.get('clientData'),
+ SIGN_SUCCESS['client_data_encoded'])
+ self.assertEqual(response.get('signatureData'),
+ SIGN_SUCCESS['signature_data_encoded'])
+ self.assertEqual(response.get('applicationId'),
+ SIGN_SUCCESS['app_id'])
+ self.assertEqual(response.get('keyHandle'),
+ SIGN_SUCCESS['key_handle_encoded'])
@mock.patch.object(localauthenticator.u2f, 'GetLocalU2FInterface')
def testSignMultipleIneligible(self, mock_get_u2f_method):
@@ -125,7 +125,7 @@ class LocalAuthenticatorTest(unittest.Te
authenticator.Authenticate(SIGN_SUCCESS['app_id'],
challenge_data)
- self.assertEquals(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
+ self.assertEqual(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
@mock.patch.object(localauthenticator.u2f, 'GetLocalU2FInterface')
def testSignMultipleSuccess(self, mock_get_u2f_method):
@@ -168,14 +168,14 @@ class LocalAuthenticatorTest(unittest.Te
self.assertEqual(registered_keys[0], SIGN_SUCCESS['registered_key'])
# Validate authenticator response
- self.assertEquals(response.get('clientData'),
- SIGN_SUCCESS['client_data_encoded'])
- self.assertEquals(response.get('signatureData'),
- SIGN_SUCCESS['signature_data_encoded'])
- self.assertEquals(response.get('applicationId'),
- SIGN_SUCCESS['app_id'])
- self.assertEquals(response.get('keyHandle'),
- SIGN_SUCCESS['key_handle_encoded'])
+ self.assertEqual(response.get('clientData'),
+ SIGN_SUCCESS['client_data_encoded'])
+ self.assertEqual(response.get('signatureData'),
+ SIGN_SUCCESS['signature_data_encoded'])
+ self.assertEqual(response.get('applicationId'),
+ SIGN_SUCCESS['app_id'])
+ self.assertEqual(response.get('keyHandle'),
+ SIGN_SUCCESS['key_handle_encoded'])
if __name__ == '__main__':
Index: pyu2f-0.1.5a/pyu2f/tests/model_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/model_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/model_test.py
@@ -32,19 +32,19 @@ class ModelTest(unittest.TestCase):
cd = model.ClientData(model.ClientData.TYP_REGISTRATION, b'ABCD',
'somemachine')
obj = json.loads(cd.GetJson())
- self.assertEquals(len(list(obj.keys())), 3)
- self.assertEquals(obj['typ'], model.ClientData.TYP_REGISTRATION)
- self.assertEquals(obj['challenge'], 'QUJDRA')
- self.assertEquals(obj['origin'], 'somemachine')
+ self.assertEqual(len(list(obj.keys())), 3)
+ self.assertEqual(obj['typ'], model.ClientData.TYP_REGISTRATION)
+ self.assertEqual(obj['challenge'], 'QUJDRA')
+ self.assertEqual(obj['origin'], 'somemachine')
def testClientDataAuth(self):
cd = model.ClientData(model.ClientData.TYP_AUTHENTICATION, b'ABCD',
'somemachine')
obj = json.loads(cd.GetJson())
- self.assertEquals(len(list(obj.keys())), 3)
- self.assertEquals(obj['typ'], model.ClientData.TYP_AUTHENTICATION)
- self.assertEquals(obj['challenge'], 'QUJDRA')
- self.assertEquals(obj['origin'], 'somemachine')
+ self.assertEqual(len(list(obj.keys())), 3)
+ self.assertEqual(obj['typ'], model.ClientData.TYP_AUTHENTICATION)
+ self.assertEqual(obj['challenge'], 'QUJDRA')
+ self.assertEqual(obj['origin'], 'somemachine')
def testClientDataInvalid(self):
self.assertRaises(errors.InvalidModelError, model.ClientData, 'foobar',
Index: pyu2f-0.1.5a/pyu2f/tests/u2f_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/u2f_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/u2f_test.py
@@ -38,11 +38,11 @@ class U2fTest(unittest.TestCase):
u2f_api = u2f.U2FInterface(mock_sk)
resp = u2f_api.Register('testapp', b'ABCD', [])
- self.assertEquals(mock_sk.CmdRegister.call_count, 2)
- self.assertEquals(mock_sk.CmdWink.call_count, 1)
- self.assertEquals(resp.client_data.raw_server_challenge, b'ABCD')
- self.assertEquals(resp.client_data.typ, 'navigator.id.finishEnrollment')
- self.assertEquals(resp.registration_data, 'regdata')
+ self.assertEqual(mock_sk.CmdRegister.call_count, 2)
+ self.assertEqual(mock_sk.CmdWink.call_count, 1)
+ self.assertEqual(resp.client_data.raw_server_challenge, b'ABCD')
+ self.assertEqual(resp.client_data.typ, 'navigator.id.finishEnrollment')
+ self.assertEqual(resp.registration_data, 'regdata')
def testRegisterSuccessWithPreviousKeys(self):
mock_sk = mock.MagicMock()
@@ -53,15 +53,15 @@ class U2fTest(unittest.TestCase):
u2f_api = u2f.U2FInterface(mock_sk)
resp = u2f_api.Register('testapp', b'ABCD', [model.RegisteredKey('khA')])
- self.assertEquals(mock_sk.CmdAuthenticate.call_count, 1)
+ self.assertEqual(mock_sk.CmdAuthenticate.call_count, 1)
# Should be "Check only"
self.assertTrue(mock_sk.CmdAuthenticate.call_args[0][3])
- self.assertEquals(mock_sk.CmdRegister.call_count, 2)
- self.assertEquals(mock_sk.CmdWink.call_count, 1)
- self.assertEquals(resp.client_data.raw_server_challenge, b'ABCD')
- self.assertEquals(resp.client_data.typ, 'navigator.id.finishEnrollment')
- self.assertEquals(resp.registration_data, 'regdata')
+ self.assertEqual(mock_sk.CmdRegister.call_count, 2)
+ self.assertEqual(mock_sk.CmdWink.call_count, 1)
+ self.assertEqual(resp.client_data.raw_server_challenge, b'ABCD')
+ self.assertEqual(resp.client_data.typ, 'navigator.id.finishEnrollment')
+ self.assertEqual(resp.registration_data, 'regdata')
def testRegisterFailAlreadyRegistered(self):
mock_sk = mock.MagicMock()
@@ -72,14 +72,14 @@ class U2fTest(unittest.TestCase):
with self.assertRaises(errors.U2FError) as cm:
u2f_api.Register('testapp', b'ABCD', [model.RegisteredKey('khA')])
- self.assertEquals(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
+ self.assertEqual(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
- self.assertEquals(mock_sk.CmdAuthenticate.call_count, 1)
+ self.assertEqual(mock_sk.CmdAuthenticate.call_count, 1)
# Should be "Check only"
self.assertTrue(mock_sk.CmdAuthenticate.call_args[0][3])
- self.assertEquals(mock_sk.CmdRegister.call_count, 0)
- self.assertEquals(mock_sk.CmdWink.call_count, 0)
+ self.assertEqual(mock_sk.CmdRegister.call_count, 0)
+ self.assertEqual(mock_sk.CmdWink.call_count, 0)
def testRegisterTimeout(self):
mock_sk = mock.MagicMock()
@@ -91,9 +91,9 @@ class U2fTest(unittest.TestCase):
with mock.patch.object(u2f, 'time') as _:
with self.assertRaises(errors.U2FError) as cm:
u2f_api.Register('testapp', b'ABCD', [])
- self.assertEquals(cm.exception.code, errors.U2FError.TIMEOUT)
- self.assertEquals(mock_sk.CmdRegister.call_count, 30)
- self.assertEquals(mock_sk.CmdWink.call_count, 30)
+ self.assertEqual(cm.exception.code, errors.U2FError.TIMEOUT)
+ self.assertEqual(mock_sk.CmdRegister.call_count, 30)
+ self.assertEqual(mock_sk.CmdWink.call_count, 30)
def testRegisterError(self):
mock_sk = mock.MagicMock()
@@ -103,12 +103,12 @@ class U2fTest(unittest.TestCase):
with self.assertRaises(errors.U2FError) as cm:
u2f_api.Register('testapp', b'ABCD', [])
- self.assertEquals(cm.exception.code, errors.U2FError.BAD_REQUEST)
- self.assertEquals(cm.exception.cause.sw1, 0xff)
- self.assertEquals(cm.exception.cause.sw2, 0xff)
+ self.assertEqual(cm.exception.code, errors.U2FError.BAD_REQUEST)
+ self.assertEqual(cm.exception.cause.sw1, 0xff)
+ self.assertEqual(cm.exception.cause.sw2, 0xff)
- self.assertEquals(mock_sk.CmdRegister.call_count, 1)
- self.assertEquals(mock_sk.CmdWink.call_count, 0)
+ self.assertEqual(mock_sk.CmdRegister.call_count, 1)
+ self.assertEqual(mock_sk.CmdWink.call_count, 0)
def testAuthenticateSuccessWithTUP(self):
mock_sk = mock.MagicMock()
@@ -119,12 +119,12 @@ class U2fTest(unittest.TestCase):
resp = u2f_api.Authenticate('testapp', b'ABCD',
[model.RegisteredKey('khA')])
- self.assertEquals(mock_sk.CmdAuthenticate.call_count, 2)
- self.assertEquals(mock_sk.CmdWink.call_count, 1)
- self.assertEquals(resp.key_handle, 'khA')
- self.assertEquals(resp.client_data.raw_server_challenge, b'ABCD')
- self.assertEquals(resp.client_data.typ, 'navigator.id.getAssertion')
- self.assertEquals(resp.signature_data, 'signature')
+ self.assertEqual(mock_sk.CmdAuthenticate.call_count, 2)
+ self.assertEqual(mock_sk.CmdWink.call_count, 1)
+ self.assertEqual(resp.key_handle, 'khA')
+ self.assertEqual(resp.client_data.raw_server_challenge, b'ABCD')
+ self.assertEqual(resp.client_data.typ, 'navigator.id.getAssertion')
+ self.assertEqual(resp.signature_data, 'signature')
def testAuthenticateSuccessSkipInvalidKey(self):
mock_sk = mock.MagicMock()
@@ -137,12 +137,12 @@ class U2fTest(unittest.TestCase):
resp = u2f_api.Authenticate(
'testapp', b'ABCD',
[model.RegisteredKey('khA'), model.RegisteredKey('khB')])
- self.assertEquals(mock_sk.CmdAuthenticate.call_count, 2)
- self.assertEquals(mock_sk.CmdWink.call_count, 0)
- self.assertEquals(resp.key_handle, 'khB')
- self.assertEquals(resp.client_data.raw_server_challenge, b'ABCD')
- self.assertEquals(resp.client_data.typ, 'navigator.id.getAssertion')
- self.assertEquals(resp.signature_data, 'signature')
+ self.assertEqual(mock_sk.CmdAuthenticate.call_count, 2)
+ self.assertEqual(mock_sk.CmdWink.call_count, 0)
+ self.assertEqual(resp.key_handle, 'khB')
+ self.assertEqual(resp.client_data.raw_server_challenge, b'ABCD')
+ self.assertEqual(resp.client_data.typ, 'navigator.id.getAssertion')
+ self.assertEqual(resp.signature_data, 'signature')
def testAuthenticateSuccessSkipInvalidVersion(self):
mock_sk = mock.MagicMock()
@@ -156,12 +156,12 @@ class U2fTest(unittest.TestCase):
[model.RegisteredKey('khA',
version='U2F_V3'),
model.RegisteredKey('khB')])
- self.assertEquals(mock_sk.CmdAuthenticate.call_count, 1)
- self.assertEquals(mock_sk.CmdWink.call_count, 0)
- self.assertEquals(resp.key_handle, 'khB')
- self.assertEquals(resp.client_data.raw_server_challenge, b'ABCD')
- self.assertEquals(resp.client_data.typ, 'navigator.id.getAssertion')
- self.assertEquals(resp.signature_data, 'signature')
+ self.assertEqual(mock_sk.CmdAuthenticate.call_count, 1)
+ self.assertEqual(mock_sk.CmdWink.call_count, 0)
+ self.assertEqual(resp.key_handle, 'khB')
+ self.assertEqual(resp.client_data.raw_server_challenge, b'ABCD')
+ self.assertEqual(resp.client_data.typ, 'navigator.id.getAssertion')
+ self.assertEqual(resp.signature_data, 'signature')
def testAuthenticateTimeout(self):
mock_sk = mock.MagicMock()
@@ -173,9 +173,9 @@ class U2fTest(unittest.TestCase):
with mock.patch.object(u2f, 'time') as _:
with self.assertRaises(errors.U2FError) as cm:
u2f_api.Authenticate('testapp', b'ABCD', [model.RegisteredKey('khA')])
- self.assertEquals(cm.exception.code, errors.U2FError.TIMEOUT)
- self.assertEquals(mock_sk.CmdAuthenticate.call_count, 30)
- self.assertEquals(mock_sk.CmdWink.call_count, 30)
+ self.assertEqual(cm.exception.code, errors.U2FError.TIMEOUT)
+ self.assertEqual(mock_sk.CmdAuthenticate.call_count, 30)
+ self.assertEqual(mock_sk.CmdWink.call_count, 30)
def testAuthenticateAllKeysInvalid(self):
mock_sk = mock.MagicMock()
@@ -187,7 +187,7 @@ class U2fTest(unittest.TestCase):
u2f_api.Authenticate('testapp', b'ABCD',
[model.RegisteredKey('khA'),
model.RegisteredKey('khB')])
- self.assertEquals(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
+ self.assertEqual(cm.exception.code, errors.U2FError.DEVICE_INELIGIBLE)
u2f_api = u2f.U2FInterface(mock_sk)
@@ -199,12 +199,12 @@ class U2fTest(unittest.TestCase):
with self.assertRaises(errors.U2FError) as cm:
u2f_api.Authenticate('testapp', b'ABCD', [model.RegisteredKey('khA')])
- self.assertEquals(cm.exception.code, errors.U2FError.BAD_REQUEST)
- self.assertEquals(cm.exception.cause.sw1, 0xff)
- self.assertEquals(cm.exception.cause.sw2, 0xff)
+ self.assertEqual(cm.exception.code, errors.U2FError.BAD_REQUEST)
+ self.assertEqual(cm.exception.cause.sw1, 0xff)
+ self.assertEqual(cm.exception.cause.sw2, 0xff)
- self.assertEquals(mock_sk.CmdAuthenticate.call_count, 1)
- self.assertEquals(mock_sk.CmdWink.call_count, 0)
+ self.assertEqual(mock_sk.CmdAuthenticate.call_count, 1)
+ self.assertEqual(mock_sk.CmdWink.call_count, 0)
if __name__ == '__main__':
Index: pyu2f-0.1.5a/pyu2f/tests/util_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/util_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/util_test.py
@@ -29,7 +29,7 @@ class UtilTest(unittest.TestCase):
def testSimplePing(self):
dev = util.FakeHidDevice(cid_to_allocate=None)
dev.Write([0, 0, 0, 1, 0x81, 0, 3, 1, 2, 3])
- self.assertEquals(
+ self.assertEqual(
dev.Read(), [0, 0, 0, 1, 0x81, 0, 3, 1, 2, 3] + [0
for _ in range(54)])
@@ -37,13 +37,13 @@ class UtilTest(unittest.TestCase):
dev = util.FakeHidDevice(cid_to_allocate=None)
dev.SetChannelBusyCount(2)
dev.Write([0, 0, 0, 1, 0x81, 0, 3, 1, 2, 3])
- self.assertEquals(
+ self.assertEqual(
dev.Read(), [0, 0, 0, 1, 0xbf, 0, 1, 6] + [0 for _ in range(56)])
dev.Write([0, 0, 0, 1, 0x81, 0, 3, 1, 2, 3])
- self.assertEquals(
+ self.assertEqual(
dev.Read(), [0, 0, 0, 1, 0xbf, 0, 1, 6] + [0 for _ in range(56)])
dev.Write([0, 0, 0, 1, 0x81, 0, 3, 1, 2, 3])
- self.assertEquals(
+ self.assertEqual(
dev.Read(), [0, 0, 0, 1, 0x81, 0, 3, 1, 2, 3] + [0
for _ in range(54)])
@@ -52,9 +52,9 @@ class UtilTest(unittest.TestCase):
msg_reply=list(range(85, 0, -1)))
dev.Write([0, 0, 0, 1, 0x83, 0, 100] + [x for x in range(57)])
dev.Write([0, 0, 0, 1, 0] + [x for x in range(57, 100)])
- self.assertEquals(
+ self.assertEqual(
dev.Read(), [0, 0, 0, 1, 0x83, 0, 85] + [x for x in range(85, 28, -1)])
- self.assertEquals(
+ self.assertEqual(
dev.Read(),
[0, 0, 0, 1, 0] + [x for x in range(28, 0, -1)] + [0
for _ in range(31)])

25
python312-2.patch Normal file
View File

@ -0,0 +1,25 @@
From 793acd9ff6612bb035f0724b04e10a01cdb5bb8d Mon Sep 17 00:00:00 2001
From: Karthikeyan Singaravelan <tir.karthi@gmail.com>
Date: Fri, 15 Oct 2021 10:38:31 +0000
Subject: [PATCH] Use assertRaisesRegex instead of assertRaisesRegexp for
Python 3.11 compatibility.
---
pyu2f/tests/hidtransport_test.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: pyu2f-0.1.5a/pyu2f/tests/hidtransport_test.py
===================================================================
--- pyu2f-0.1.5a.orig/pyu2f/tests/hidtransport_test.py
+++ pyu2f-0.1.5a/pyu2f/tests/hidtransport_test.py
@@ -128,8 +128,8 @@ class TransportTest(unittest.TestCase):
# the second will succeed on the second retry.
fake_hid_dev.SetChannelBusyCount(3)
with mock.patch.object(hidtransport, 'time') as _:
- self.assertRaisesRegexp(errors.HidError, '^Device Busy', t.SendMsgBytes,
- [0x00, 0x01, 0x00, 0x00])
+ self.assertRaisesRegex(errors.HidError, '^Device Busy', t.SendMsgBytes,
+ [0x00, 0x01, 0x00, 0x00])
reply = t.SendMsgBytes([0x00, 0x01, 0x00, 0x00])
self.assertEqual(reply, bytearray([0x01, 0x90, 0x00]))

BIN
pyu2f-0.1.5a.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.