From 18044250f984d4b2215e85375442dc30c052bd9960ecc20630782e74f4091f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 3 May 2024 22:40:00 +0200 Subject: [PATCH] Sync from SUSE:SLFO:Main python-pyu2f revision 0c70e84185adef02533048ff5421310f --- .gitattributes | 23 + fix-deprecation-warning.patch | 59 +++ python-pyu2f-no-six.patch | 71 ++++ python-pyu2f.changes | 47 +++ python-pyu2f.spec | 68 +++ python312-1.patch | 771 ++++++++++++++++++++++++++++++++++ python312-2.patch | 25 ++ pyu2f-0.1.5a.tar.gz | 3 + 8 files changed, 1067 insertions(+) create mode 100644 .gitattributes create mode 100644 fix-deprecation-warning.patch create mode 100644 python-pyu2f-no-six.patch create mode 100644 python-pyu2f.changes create mode 100644 python-pyu2f.spec create mode 100644 python312-1.patch create mode 100644 python312-2.patch create mode 100644 pyu2f-0.1.5a.tar.gz diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/fix-deprecation-warning.patch b/fix-deprecation-warning.patch new file mode 100644 index 0000000..030b483 --- /dev/null +++ b/fix-deprecation-warning.patch @@ -0,0 +1,59 @@ +From 5e2f862dd5ba61eadff341dbf0a1202e91b1b145 Mon Sep 17 00:00:00 2001 +From: Cary Zhao +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', diff --git a/python-pyu2f-no-six.patch b/python-pyu2f-no-six.patch new file mode 100644 index 0000000..f9bf4ec --- /dev/null +++ b/python-pyu2f-no-six.patch @@ -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 diff --git a/python-pyu2f.changes b/python-pyu2f.changes new file mode 100644 index 0000000..ca271ec --- /dev/null +++ b/python-pyu2f.changes @@ -0,0 +1,47 @@ +------------------------------------------------------------------- +Tue Oct 17 07:32:00 UTC 2023 - Daniel Garcia Moreno + +- 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 + +- Add python312.patch to fix tests in python3.12 + +------------------------------------------------------------------- +Fri Apr 21 12:32:28 UTC 2023 - Dirk Müller + +- add sle15_python_module_pythons (jsc#PED-68) + +------------------------------------------------------------------- +Thu Apr 13 22:44:20 UTC 2023 - Matej Cepl + +- 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á + +- Add upstream fix-deprecation-warning.patch to fix compatibility + +------------------------------------------------------------------- +Tue Apr 12 08:56:31 UTC 2022 - Markéta Machová + +- do not use mock + +------------------------------------------------------------------- +Fri Aug 20 08:28:27 UTC 2021 - John Paul Adrian Glaubitz + +- Initial build + + Version 0.1.5a diff --git a/python-pyu2f.spec b/python-pyu2f.spec new file mode 100644 index 0000000..6ef18da --- /dev/null +++ b/python-pyu2f.spec @@ -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 diff --git a/python312-1.patch b/python312-1.patch new file mode 100644 index 0000000..7360467 --- /dev/null +++ b/python312-1.patch @@ -0,0 +1,771 @@ +From dad654010a030f1038bd2df95a9647fb417e0447 Mon Sep 17 00:00:00 2001 +From: Felix Yan +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(' +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])) diff --git a/pyu2f-0.1.5a.tar.gz b/pyu2f-0.1.5a.tar.gz new file mode 100644 index 0000000..1e6dee0 --- /dev/null +++ b/pyu2f-0.1.5a.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f34660ed5f4accd493fd356b8aa361a131f5d42aab0bcc8af88663c5e6a537a3 +size 39019