[python-neutronclient/el6-havana] Fixed get_auth_info() for pre-authenticated clients

Jakub Ruzicka jruzicka at fedoraproject.org
Tue Feb 25 13:49:15 UTC 2014


commit e6981896670fb29bf5f0234ee45c1745b855cd06
Author: Jakub Ruzicka <jruzicka at redhat.com>
Date:   Tue Feb 25 14:49:20 2014 +0100

    Fixed get_auth_info() for pre-authenticated clients

 0001-Remove-runtime-dependency-on-python-pbr.patch |   43 +-------------
 ...t_auth_info-for-pre-authenticated-clients.patch |   59 ++++++++++++++++++++
 python-neutronclient.spec                          |    7 ++-
 3 files changed, 69 insertions(+), 40 deletions(-)
---
diff --git a/0001-Remove-runtime-dependency-on-python-pbr.patch b/0001-Remove-runtime-dependency-on-python-pbr.patch
index 2e5e598..fc22ab0 100644
--- a/0001-Remove-runtime-dependency-on-python-pbr.patch
+++ b/0001-Remove-runtime-dependency-on-python-pbr.patch
@@ -1,16 +1,12 @@
-From 29386e4f4042b22d0ce2cadd0c2b381b42f52c46 Mon Sep 17 00:00:00 2001
+From 52bf7822894eb3de04450b334e81951e8ed03d7f Mon Sep 17 00:00:00 2001
 From: Jakub Ruzicka <jruzicka at redhat.com>
 Date: Tue, 23 Jul 2013 18:35:38 +0200
 Subject: [PATCH] Remove runtime dependency on python-pbr
 
 ---
- neutronclient/version.py |  5 +----
- requirements.txt         |  8 --------
- setup.py                 |  1 -
- test-requirements.txt    | 11 -----------
- 4 files changed, 1 insertion(+), 24 deletions(-)
- delete mode 100644 requirements.txt
- delete mode 100644 test-requirements.txt
+ neutronclient/version.py | 5 +----
+ setup.py                 | 1 -
+ 2 files changed, 1 insertion(+), 5 deletions(-)
 
 diff --git a/neutronclient/version.py b/neutronclient/version.py
 index 9315671..f0b6efc 100644
@@ -25,20 +21,6 @@ index 9315671..f0b6efc 100644
 -
 -__version__ = pbr.version.VersionInfo('python-neutronclient').version_string()
 +__version__ = "REDHATNEUTRONCLIENTVERSION"
-diff --git a/requirements.txt b/requirements.txt
-deleted file mode 100644
-index 22e6b09..0000000
---- a/requirements.txt
-+++ /dev/null
-@@ -1,8 +0,0 @@
--pbr>=0.5.21,<1.0
--argparse
--cliff>=1.4.3
--httplib2
--iso8601>=0.1.4
--simplejson>=2.0.9
--six
--Babel>=0.9.6
 diff --git a/setup.py b/setup.py
 index 2a0786a..afab729 100644
 --- a/setup.py
@@ -49,20 +31,3 @@ index 2a0786a..afab729 100644
  setuptools.setup(
 -    setup_requires=['pbr>=0.5.21,<1.0'],
      pbr=True)
-diff --git a/test-requirements.txt b/test-requirements.txt
-deleted file mode 100644
-index a684fdd..0000000
---- a/test-requirements.txt
-+++ /dev/null
-@@ -1,11 +0,0 @@
--hacking>=0.5.6,<0.8
--
--cliff-tablib>=1.0
--coverage>=3.6
--discover
--fixtures>=0.3.14
--mox>=0.5.3
--python-subunit
--sphinx>=1.1.2
--testrepository>=0.0.17
--testtools>=0.9.32
diff --git a/0002-Fixed-get_auth_info-for-pre-authenticated-clients.patch b/0002-Fixed-get_auth_info-for-pre-authenticated-clients.patch
new file mode 100644
index 0000000..0b2efea
--- /dev/null
+++ b/0002-Fixed-get_auth_info-for-pre-authenticated-clients.patch
@@ -0,0 +1,59 @@
+From 62052d76cc63c01965e63f76f68439b2632dcf52 Mon Sep 17 00:00:00 2001
+From: Ihar Hrachyshka <ihrachys at redhat.com>
+Date: Thu, 6 Feb 2014 15:54:14 +0100
+Subject: [PATCH] Fixed get_auth_info() for pre-authenticated clients
+
+When a client is instantiated with pre-defined authorization token,
+no authentication is done, so no auth_[tenant|user]_id keys are set
+for HTTPClient. As a result, Client.get_auth_info() fails with KeyError.
+
+Fixed the issue by setting those keys on HTTPClient initialization.
+
+Change-Id: Ifc9d6b128286b635346a7bc026fcc55dbd002050
+Closes-Bug: 1277120
+---
+ neutronclient/client.py               |  2 ++
+ neutronclient/tests/unit/test_auth.py | 17 +++++++++++++++++
+ 2 files changed, 19 insertions(+)
+
+diff --git a/neutronclient/client.py b/neutronclient/client.py
+index b097703..9dbb3b6 100644
+--- a/neutronclient/client.py
++++ b/neutronclient/client.py
+@@ -111,6 +111,8 @@ class HTTPClient(httplib2.Http):
+         self.endpoint_type = endpoint_type
+         self.region_name = region_name
+         self.auth_token = token
++        self.auth_tenant_id = None
++        self.auth_user_id = None
+         self.content_type = 'application/json'
+         self.endpoint_url = endpoint_url
+         self.auth_strategy = auth_strategy
+diff --git a/neutronclient/tests/unit/test_auth.py b/neutronclient/tests/unit/test_auth.py
+index 9fa9e56..911c37a 100644
+--- a/neutronclient/tests/unit/test_auth.py
++++ b/neutronclient/tests/unit/test_auth.py
+@@ -85,6 +85,23 @@ class CLITestAuthKeystone(testtools.TestCase):
+         self.addCleanup(self.mox.VerifyAll)
+         self.addCleanup(self.mox.UnsetStubs)
+ 
++    def test_reused_token_get_auth_info(self):
++        """Test that Client.get_auth_info() works even if client was
++           instantiated with predefined token.
++        """
++        client_ = client.HTTPClient(username=USERNAME,
++                                    tenant_id=TENANT_ID,
++                                    tenant_name=TENANT_NAME,
++                                    token=TOKEN,
++                                    password=PASSWORD,
++                                    auth_url=AUTH_URL,
++                                    region_name=REGION)
++        expected = {'auth_token': TOKEN,
++                    'auth_tenant_id': None,
++                    'auth_user_id': None,
++                    'endpoint_url': self.client.endpoint_url}
++        self.assertEqual(client_.get_auth_info(), expected)
++
+     def test_get_token(self):
+         self.mox.StubOutWithMock(self.client, "request")
+ 
diff --git a/python-neutronclient.spec b/python-neutronclient.spec
index c67324a..dd0fcf8 100644
--- a/python-neutronclient.spec
+++ b/python-neutronclient.spec
@@ -1,6 +1,6 @@
 Name:       python-neutronclient
 Version:    2.3.1
-Release:    2%{?dist}
+Release:    3%{?dist}
 Summary:    Python API and CLI for OpenStack Neutron
 
 Group:      Development/Languages
@@ -12,6 +12,7 @@ Source0:    https://pypi.python.org/packages/source/p/%{name}/%{name}-%{version}
 # patches_base=2.3.1
 #
 Patch0001: 0001-Remove-runtime-dependency-on-python-pbr.patch
+Patch0002: 0002-Fixed-get_auth_info-for-pre-authenticated-clients.patch
 
 BuildArch:  noarch
 
@@ -35,6 +36,7 @@ Neutron's API.
 %setup -q -n %{name}-%{version}
 
 %patch0001 -p1
+%patch0002 -p1
 
 # We provide version like this in order to remove runtime dep on pbr.
 sed -i s/REDHATNEUTRONCLIENTVERSION/%{version}/ neutronclient/version.py
@@ -62,6 +64,9 @@ rm -rf %{buildroot}%{python_sitelib}/neutronclient/tests
 %{_sysconfdir}/profile.d/neutron.sh
 
 %changelog
+* Tue Feb 25 2014 Jakub Ruzicka <jruzicka at redhat.com> 2.3.1-3
+- Fixed get_auth_info() for pre-authenticated clients
+
 * Fri Nov 01 2013 Jakub Ruzicka <jruzicka at redhat.com> - 2.3.1-2
 - Don't obsolete python-quantumclient (#1025509)
 


More information about the scm-commits mailing list