From cfd6d3064fc8c5836c4e74b56c5a6bc6df980e0d Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Wed, 8 Nov 2023 14:46:46 -0500 Subject: [PATCH] show hub version in koji hello --- cli/koji_cli/commands.py | 2 +- koji/__init__.py | 3 ++- tests/test_cli/test_hello.py | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 53130257..e44b1363 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -7565,7 +7565,7 @@ def handle_moshimoshi(options, session, args): u = {'name': 'anonymous user'} print("%s, %s!" % (_printable_unicode(random.choice(greetings)), u["name"])) print("") - print("You are using the hub at %s" % session.baseurl) + print("You are using the hub at %s (Koji %s)" % (session.baseurl, session.hub_version_str)) authtype = u.get('authtype', getattr(session, 'authtype', None)) if authtype == koji.AUTHTYPES['NORMAL']: print("Authenticated via password") diff --git a/koji/__init__.py b/koji/__init__.py index cea66328..5706c76c 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -2643,7 +2643,8 @@ class ClientSession(object): self.__hub_version = self.getKojiVersion() except GenericError as e: if 'Invalid method' in str(e): - # hub is older than 1.23, return latest version without the getKojiVersion + # use latest version without the getKojiVersion handler + self.logger.debug("hub is older than 1.23, assuming 1.22.0") self.__hub_version = '1.22.0' else: raise diff --git a/tests/test_cli/test_hello.py b/tests/test_cli/test_hello.py index 45712892..6e35638c 100644 --- a/tests/test_cli/test_hello.py +++ b/tests/test_cli/test_hello.py @@ -50,6 +50,8 @@ class TestHello(utils.CliTestCase): # Mock out the xmlrpc server session.getLoggedInUser.return_value = None session.krb_principal = user['krb_principal'] + mock_hub_version = '1.35.0' + session.hub_version_str = mock_hub_version print_unicode_mock.return_value = "Hello" self.assert_system_exit( @@ -63,7 +65,7 @@ class TestHello(utils.CliTestCase): # annonymous user message = "Not authenticated\n" + "Hello, anonymous user!" - hubinfo = "You are using the hub at %s" % self.huburl + hubinfo = "You are using the hub at %s (Koji %s)" % (self.huburl, mock_hub_version) handle_moshimoshi(self.options, session, []) self.assert_console_message(stdout, "{0}\n\n{1}\n".format(message, hubinfo)) self.activate_session_mock.assert_called_once_with(session, self.options) @@ -79,7 +81,7 @@ class TestHello(utils.CliTestCase): user['krb_principal'], koji.AUTHTYPES['SSL']: 'Authenticated via client certificate %s' % cert } - hubinfo = "You are using the hub at %s" % self.huburl + # same hubinfo session.getLoggedInUser.return_value = user message = "Hello, %s!" % self.progname self.options.cert = cert