From 61c07da8d68c8e03a80a182db57aed6fac1c24de58f8f11bcb843daef0422f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Wed, 30 Sep 2020 17:23:20 +0000 Subject: [PATCH] Accepting request 838789 from home:frispete:python - Fold -tests package into mail package again - Apply fix-kwallet-tests.patch - fix packaging tests - Package tests in separate package $flavor-tests Allows packages, that depend on these tests, to build successfully e.g. keyrings.cryptfile OBS-URL: https://build.opensuse.org/request/show/838789 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-keyring?expand=0&rev=86 --- fix-kwallet-tests.patch | 95 +++++++++++++++++++++++++++++++++++++++++ python-keyring.changes | 22 ++++++++++ python-keyring.spec | 3 ++ 3 files changed, 120 insertions(+) create mode 100644 fix-kwallet-tests.patch diff --git a/fix-kwallet-tests.patch b/fix-kwallet-tests.patch new file mode 100644 index 0000000..57cf4e8 --- /dev/null +++ b/fix-kwallet-tests.patch @@ -0,0 +1,95 @@ +diff --git a/tests/backends/test_kwallet.py b/tests/backends/test_kwallet.py +index 68cb4c7..f2d1638 100644 +--- a/tests/backends/test_kwallet.py ++++ b/tests/backends/test_kwallet.py +@@ -6,6 +6,7 @@ from keyring.testing.backend import BackendBasicTests + + @pytest.mark.skipif(not kwallet.DBusKeyring.viable, reason="KWallet5 unavailable") + class TestDBusKWallet(BackendBasicTests): ++ __test__ = True + + # Remove '@' from service name as this is not supported in service names + # '@' will cause troubles during migration of kwallet entries +@@ -14,66 +15,27 @@ class TestDBusKWallet(BackendBasicTests): + def init_keyring(self): + return kwallet.DBusKeyring() + +- def cleanup(self): +- for item in self.credentials_created: +- # Suppress errors, as only one pre/post migration item will be +- # present +- try: +- self.keyring.delete_password(*item) +- except BaseException: +- pass +- +- # TODO Remove empty folders created during tests +- +- def set_password(self, service, username, password, old_format=False): +- # set the password and save the result so the test runner can clean +- # up after if necessary. +- self.credentials_created.add((service, username)) +- +- if old_format: +- username = username + '@' + service +- service = 'Python' +- +- super().set_password(service, username, password) +- +- def check_set_get(self, service, username, password): ++ def test_credential(self): + keyring = self.keyring + +- # for the non-existent password +- self.assertEqual(keyring.get_password(service, username), None) ++ # not supported from kwallets ++ #cred = keyring.get_credential('service', None) ++ #assert cred is None + +- # common usage +- self.set_password(service, username, password, True) +- # re-init keyring to force migration +- self.keyring = keyring = self.init_keyring() +- ret_password = keyring.get_password(service, username) +- self.assertEqual( +- ret_password, +- password, +- "Incorrect password for username: '%s' " +- "on service: '%s'. '%s' != '%s'" +- % (service, username, ret_password, password), +- ) ++ self.set_password('service1', 'user1', 'password1') ++ self.set_password('service1', 'user2', 'password2') + +- # for the empty password +- self.set_password(service, username, "", True) +- # re-init keyring to force migration +- self.keyring = keyring = self.init_keyring() +- ret_password = keyring.get_password(service, username) +- self.assertEqual( +- ret_password, +- "", +- "Incorrect password for username: '%s' " +- "on service: '%s'. '%s' != '%s'" % (service, username, ret_password, ""), ++ cred = keyring.get_credential('service1', None) ++ assert cred is None or (cred.username, cred.password) in ( ++ ('user1', 'password1'), ++ ('user2', 'password2'), + ) +- ret_password = keyring.get_password('Python', username + '@' + service) +- self.assertEqual( +- ret_password, +- None, +- "Not 'None' password returned for username: '%s' " +- "on service: '%s'. '%s' != '%s'. Passwords from old " +- "folder should be deleted during migration." +- % (service, username, ret_password, None), ++ ++ cred = keyring.get_credential('service1', 'user2') ++ assert cred is not None ++ assert (cred.username, cred.password) in ( ++ ('user1', 'password1'), ++ ('user2', 'password2'), + ) + + diff --git a/python-keyring.changes b/python-keyring.changes index 27081c6..77caf0b 100644 --- a/python-keyring.changes +++ b/python-keyring.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Wed Sep 30 12:35:11 UTC 2020 - Hans-Peter Jansen + +- Fold -tests package into mail package again + +------------------------------------------------------------------- +Mon Sep 21 16:25:13 UTC 2020 - Hans-Peter Jansen + +- Apply fix-kwallet-tests.patch + ------------------------------------------------------------------- Tue Jun 2 16:32:46 UTC 2020 - Dirk Mueller @@ -17,6 +27,11 @@ Mon May 25 06:50:30 UTC 2020 - Petr Gajdos - %python3_only -> %python_alternative +------------------------------------------------------------------- +Sat May 2 17:54:41 UTC 2020 - Hans-Peter Jansen + +- fix packaging tests + ------------------------------------------------------------------- Thu Apr 16 08:27:33 UTC 2020 - pgajdos@suse.com @@ -93,6 +108,13 @@ Wed Mar 6 08:40:32 UTC 2019 - Tomáš Chvátal - Revert the test removal pending fix of upstream bug: https://github.com/jaraco/keyrings.alt/issues/33 +------------------------------------------------------------------- +Sat Mar 2 10:41:01 UTC 2019 - Hans-Peter Jansen + +- Package tests in separate package $flavor-tests + Allows packages, that depend on these tests, to build successfully + e.g. keyrings.cryptfile + ------------------------------------------------------------------- Tue Feb 26 13:10:57 UTC 2019 - John Vandenberg diff --git a/python-keyring.spec b/python-keyring.spec index 50d7956..1b3fc41 100644 --- a/python-keyring.spec +++ b/python-keyring.spec @@ -23,8 +23,10 @@ Version: 21.2.1 Release: 0 Summary: System keyring service access from Python License: Python-2.0 AND MIT +Group: Development/Languages/Python URL: https://github.com/jaraco/keyring Source: https://files.pythonhosted.org/packages/source/k/keyring/keyring-%{version}.tar.gz +Patch: fix-kwallet-tests.patch BuildRequires: %{python_module SecretStorage >= 3} BuildRequires: %{python_module entrypoints} BuildRequires: %{python_module importlib-metadata} @@ -50,6 +52,7 @@ from python. It can be used in any application that needs safe password storage. %prep %setup -q -n keyring-%{version} +%patch -p1 # For rpmlint warning: remove shebang from python library: sed -i '/^#!/d' keyring/cli.py sed -i -e 's,--flake8,,' -e 's,--black,,' -e 's,--cov,,' pytest.ini