public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/fedpkg] 1.48-1: Backport PR #482 to fix tests with bodhi-client 6+ (#2097858)
@ 2026-08-10 21:46 Adam Williamson
  0 siblings, 0 replies; only message in thread
From: Adam Williamson @ 2026-08-10 21:46 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/fedpkg
Branch : 1.48-1
Commit : cd00093b77e36325f9d39fcf8e0c767a6262992f
Author : Adam Williamson <awilliam@redhat.com>
Date   : 2022-06-17T16:48:16-07:00
Stats  : +142/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/fedpkg/c/cd00093b77e36325f9d39fcf8e0c767a6262992f?branch=1.48-1

Log:
Backport PR #482 to fix tests with bodhi-client 6+ (#2097858)

---
diff --git a/0005-Fix-tests-with-bodhi-client-6.patch b/0005-Fix-tests-with-bodhi-client-6.patch
new file mode 100644
index 0000000..5e5b9ba
--- /dev/null
+++ b/0005-Fix-tests-with-bodhi-client-6.patch
@@ -0,0 +1,134 @@
+From 987c00d628f4a5cfb3146cbc51c4a91bf75b93a1 Mon Sep 17 00:00:00 2001
+From: Adam Williamson <awilliam@redhat.com>
+Date: Fri, 17 Jun 2022 16:04:56 -0700
+Subject: [PATCH] Fix tests with bodhi-client 6+
+
+bodhi-client was ported to use OIDC Client for authentication.
+We need to mock out its OIDC provider metadata discovery because
+it does an unavoidable network request, and we also need to make
+sure `HOME` is defined in `os.environ` because the new OIDC code
+expects to read it (in `BodhiClient._build_oidc_client()`).
+
+Signed-off-by: Adam Williamson <awilliam@redhat.com>
+---
+ test/test_cli.py | 49 +++++++++++++++++++++++++++++++++++++-----------
+ 1 file changed, 38 insertions(+), 11 deletions(-)
+
+diff --git a/test/test_cli.py b/test/test_cli.py
+index 03c9403..a2a2c60 100644
+--- a/test/test_cli.py
++++ b/test/test_cli.py
+@@ -49,6 +49,11 @@ except ImportError:
+     bodhi = None
+ 
+ 
++def _mock_metadata(self, _):
++    """Minimal replacement for OIDCClient._get_provider_metadata"""
++    self.metadata = {"token_endpoint": "", "authorization_endpoint": ""}
++
++
+ class TestIsUpdateAborted(CliTestCase):
+     """Test is_update_aborted"""
+ 
+@@ -111,7 +116,7 @@ class TestUpdate(CliTestCase):
+         self.mock_check_bodhi_version = \
+             self.check_bodhi_version_patcher.start()
+ 
+-        self.os_environ_patcher = patch.dict('os.environ', {'EDITOR': 'vi'})
++        self.os_environ_patcher = patch.dict('os.environ', {'EDITOR': 'vi', 'HOME': mkdtemp()})
+         self.os_environ_patcher.start()
+ 
+         self.user_patcher = patch('pyrpkg.Commands.user',
+@@ -136,15 +141,11 @@ class TestUpdate(CliTestCase):
+         with io.open(clog_file, 'w', encoding='utf-8') as f:
+             f.write(os.linesep.join(self.fake_clog))
+ 
+-        # Get 'bodhi_client' version. Particular versions have differences
+-        # across distributions.
+-        self.bodhi_version = None
+-        try:
+-            version_object = pkg_resources.get_distribution('bodhi_client')
+-            if version_object.has_version():
+-                self.bodhi_version = int(version_object.version.split('.')[0])
+-        except pkg_resources.DistributionNotFound:
+-            pass
++        if parse_version(bodhi_version) >= parse_version("6.0.0"):
++            self.oidcmeta_patcher = patch(
++                'bodhi.client.oidcclient.OIDCClient._get_provider_metadata', _mock_metadata
++            )
++            self.oidcmeta_patcher.start()
+ 
+     def tearDown(self):
+         if os.path.exists('bodhi.template'):
+@@ -158,6 +159,8 @@ class TestUpdate(CliTestCase):
+         self.check_bodhi_version_patcher.stop()
+         self.run_command_patcher.stop()
+         self.nvr_patcher.stop()
++        if parse_version(bodhi_version) >= parse_version("6.0.0"):
++            self.oidcmeta_patcher.stop()
+         super(TestUpdate, self).tearDown()
+ 
+     def get_cli(self, cli_cmd, name='fedpkg', cfg=None):
+@@ -221,7 +224,7 @@ class TestUpdate(CliTestCase):
+ 
+         # there wasn't the option in older releases of bodhi, but these
+         # releases are still active (epel7, epel8)
+-        if self.bodhi_version <= 4:
++        if parse_version(bodhi_version) <= parse_version("4.0.0"):
+             del expected_data["display_name"]
+ 
+         with patch('os.unlink') as unlink:
+@@ -1569,12 +1572,24 @@ class TestBodhiOverride(CliTestCase):
+         self.anon_kojisession_m = self.anon_kojisession_p.start()
+         self.kojisession = self.anon_kojisession_m.return_value
+ 
++        self.os_environ_patcher = patch.dict('os.environ', {'EDITOR': 'vi', 'HOME': mkdtemp()})
++        self.os_environ_patcher.start()
++
++        if parse_version(bodhi_version) >= parse_version("6.0.0"):
++            self.oidcmeta_patcher = patch(
++                'bodhi.client.oidcclient.OIDCClient._get_provider_metadata', _mock_metadata
++            )
++            self.oidcmeta_patcher.start()
++
+         # Fake build returned from Koji for the specified build NVR in tests
+         self.kojisession.getBuild.return_value = {'build_id': 1}
+ 
+     def tearDown(self):
+         self.anon_kojisession_p.stop()
+         self.cbv_p.stop()
++        self.os_environ_patcher.stop()
++        if parse_version(bodhi_version) >= parse_version("6.0.0"):
++            self.oidcmeta_patcher.stop()
+         super(TestBodhiOverride, self).tearDown()
+ 
+     def test_raise_error_if_build_not_exist(self):
+@@ -1802,6 +1817,15 @@ class TestBodhiOverrideExtend(CliTestCase):
+         self.anon_kojisession_m = self.anon_kojisession_p.start()
+         self.kojisession = self.anon_kojisession_m.return_value
+ 
++        self.os_environ_patcher = patch.dict('os.environ', {'EDITOR': 'vi', 'HOME': mkdtemp()})
++        self.os_environ_patcher.start()
++
++        if parse_version(bodhi_version) >= parse_version("6.0.0"):
++            self.oidcmeta_patcher = patch(
++                'bodhi.client.oidcclient.OIDCClient._get_provider_metadata', _mock_metadata
++            )
++            self.oidcmeta_patcher.start()
++
+         self.load_cookies_p = patch(
+             'fedora.client.OpenIdBaseClient._load_cookies')
+         self.mock_load_cookies = self.load_cookies_p.start()
+@@ -1813,6 +1837,9 @@ class TestBodhiOverrideExtend(CliTestCase):
+         self.load_cookies_p.stop()
+         self.anon_kojisession_p.stop()
+         self.cbv_p.stop()
++        self.os_environ_patcher.stop()
++        if parse_version(bodhi_version) >= parse_version("6.0.0"):
++            self.oidcmeta_patcher.stop()
+         super(TestBodhiOverrideExtend, self).tearDown()
+ 
+     def test_specified_build_not_exist(self):
+-- 
+2.36.1
+

diff --git a/fedpkg.spec b/fedpkg.spec
index d0441ee..5d838ca 100644
--- a/fedpkg.spec
+++ b/fedpkg.spec
@@ -5,7 +5,7 @@
 
 Name:           fedpkg
 Version:        1.42
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        Fedora utility for working with dist-git
 
 License:        GPLv2+
@@ -17,6 +17,10 @@ Patch1:         0001-Do-not-use-pytest-related-dependencies-temporarily.patch
 Patch2:         0002-Remove-pytest-coverage-execution.patch
 Patch3:         0003-fedpkg-update-suggest-logout-option-added.patch
 Patch4:         0004-Add-compatibility-for-Bodhi-6.0.0.patch
+# https://bugzilla.redhat.com/show_bug.cgi?id=2097858
+# https://pagure.io/fedpkg/pull-request/482
+# Fix tests with bodhi-client 6+
+Patch5:         0005-Fix-tests-with-bodhi-client-6.patch
 
 # RHEL7 is currently the only release that is built for Python 2.
 %if 0%{?fedora} || 0%{?rhel} > 7
@@ -147,6 +151,9 @@ mv %{buildroot}%{compdir}/fedpkg.bash %{buildroot}%{compdir}/fedpkg
 
 
 %changelog
+* Fri Jun 17 2022 Adam Williamson <awilliam@redhat.com> - 1.42-4
+- Backport PR #482 to fix tests with bodhi-client 6+ (#2097858)
+
 * Thu Jun 16 2022 Python Maint <python-maint@redhat.com> - 1.42-3
 - Rebuilt for Python 3.11
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-10 21:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10 21:46 [rpms/fedpkg] 1.48-1: Backport PR #482 to fix tests with bodhi-client 6+ (#2097858) Adam Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox