From c56f4f7e406051ea33f3eee113752b4c21f68a03 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 12 Apr 2017 10:19:47 -0500 Subject: [PATCH] Shift additional_user_agent in the stack The additional_user_agent is intended for things, such as os-client-config, that sit somewhere in the stack between keystoneauth and the actual client. So according to jamielennox in irc, it should be: app client *additional_user_agent keystoneauth requests The current logic puts additional_user_agent between app and client, leading to things that look like this: "User-Agent: v.py/1 os-client-config/1.26.1 shade/1.19.1 keystoneauth1/2.18.0 python-requests/2.13.0 CPython/2.7.12" Which is a bit off. Change-Id: Iddfbeab322a39d3ba893a15aabb4c79050526451 --- keystoneauth1/session.py | 6 +++--- keystoneauth1/tests/unit/test_session.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/keystoneauth1/session.py b/keystoneauth1/session.py index d0794e93..317324e2 100644 --- a/keystoneauth1/session.py +++ b/keystoneauth1/session.py @@ -623,14 +623,14 @@ class Session(object): elif self.app_name: agent.append(self.app_name) - for additional in self.additional_user_agent: - agent.append('%s/%s' % additional) - if client_name and client_version: agent.append('%s/%s' % (client_name, client_version)) elif client_name: agent.append(client_name) + for additional in self.additional_user_agent: + agent.append('%s/%s' % additional) + if not agent: # NOTE(jamielennox): determine_user_agent will return an empty # string on failure so checking for None will ensure it is only diff --git a/keystoneauth1/tests/unit/test_session.py b/keystoneauth1/tests/unit/test_session.py index 5aa0ccba..c411f83f 100644 --- a/keystoneauth1/tests/unit/test_session.py +++ b/keystoneauth1/tests/unit/test_session.py @@ -1307,7 +1307,7 @@ class AdapterTest(utils.TestCase): adap.get(url) - agent = 'ksatest/1.2.3 one/1.1.1 two/2.2.2 testclient/4.5.6' + agent = 'ksatest/1.2.3 testclient/4.5.6 one/1.1.1 two/2.2.2' self.assertEqual(agent + ' ' + client_session.DEFAULT_USER_AGENT, self.requests_mock.last_request.headers['User-Agent'])