summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikhil Komawar <nikhil.komawar@rackspace.com>2012-02-06 22:56:20 +0000
committerNikhil Komawar <nikhil.komawar@rackspace.com>2012-02-07 00:13:26 +0000
commit95771cf112128f5f22a6a5e2e1e0e2d251f29e53 (patch)
tree9327a3b7ef6ccd0ba39757d1a7f30c2fc4b166b8
parentd52ea46f558ef5e8d2cda238d89b420e9a5d7932 (diff)
downloadnova-95771cf112128f5f22a6a5e2e1e0e2d251f29e53.tar.gz
nova-95771cf112128f5f22a6a5e2e1e0e2d251f29e53.tar.xz
nova-95771cf112128f5f22a6a5e2e1e0e2d251f29e53.zip
dont show blank endpoint headers
fixes bug: 741972 Change-Id: I4a661a13c5baaa79ee647a6c1cedcef29a2642f6
-rw-r--r--Authors1
-rw-r--r--nova/api/openstack/auth.py12
-rw-r--r--nova/tests/api/openstack/compute/test_auth.py38
3 files changed, 35 insertions, 16 deletions
diff --git a/Authors b/Authors
index ef89231cf..2f2ebbc8d 100644
--- a/Authors
+++ b/Authors
@@ -123,6 +123,7 @@ MotoKen <motokentsai@gmail.com>
Muneyuki Noguchi <noguchimn@nttdata.co.jp>
Nachi Ueno <ueno.nachi@lab.ntt.co.jp>
Naveed Massjouni <naveedm9@gmail.com>
+Nikhil Komawar <nikhil.komawar@rackspace.com>
Nikolay Sokolov <nsokolov@griddynamics.com>
Nirmal Ranganathan <rnirmal@gmail.com>
Ollie Leahy <oliver.leahy@hp.com>
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py
index 8e0a71d4f..84e0b16ca 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/auth.py
@@ -52,8 +52,6 @@ class NoAuthMiddleware(base_wsgi.Middleware):
# 2.0 auth here as well.
res.headers['X-Auth-Token'] = '%s:%s' % (user_id, project_id)
res.headers['X-Server-Management-Url'] = os_url
- res.headers['X-Storage-Url'] = ''
- res.headers['X-CDN-Management-Url'] = ''
res.content_type = 'text/plain'
res.status = '204'
return res
@@ -177,8 +175,14 @@ class AuthMiddleware(base_wsgi.Middleware):
res.headers['X-Auth-Token'] = token['token_hash']
res.headers['X-Server-Management-Url'] = \
token['server_management_url']
- res.headers['X-Storage-Url'] = token['storage_url']
- res.headers['X-CDN-Management-Url'] = token['cdn_management_url']
+
+ if token['storage_url']:
+ res.headers['X-Storage-Url'] = token['storage_url']
+
+ if token['cdn_management_url']:
+ res.headers['X-CDN-Management-Url'] = \
+ token['cdn_management_url']
+
res.content_type = 'text/plain'
res.status = '204'
LOG.debug(_("Successfully authenticated '%s'") % username)
diff --git a/nova/tests/api/openstack/compute/test_auth.py b/nova/tests/api/openstack/compute/test_auth.py
index bc83a8b96..2fcf5f7a6 100644
--- a/nova/tests/api/openstack/compute/test_auth.py
+++ b/nova/tests/api/openstack/compute/test_auth.py
@@ -57,9 +57,6 @@ class Test(test.TestCase):
result = req.get_response(fakes.wsgi_app(fake_auth=False))
self.assertEqual(result.status, '204 No Content')
self.assertEqual(len(result.headers['X-Auth-Token']), 40)
- self.assertEqual(result.headers['X-CDN-Management-Url'],
- "")
- self.assertEqual(result.headers['X-Storage-Url'], "")
def test_authorize_token(self):
f = fakes.FakeAuthManager()
@@ -75,9 +72,6 @@ class Test(test.TestCase):
self.assertEqual(len(result.headers['X-Auth-Token']), 40)
self.assertEqual(result.headers['X-Server-Management-Url'],
"http://foo/v2/user1_project")
- self.assertEqual(result.headers['X-CDN-Management-Url'],
- "")
- self.assertEqual(result.headers['X-Storage-Url'], "")
token = result.headers['X-Auth-Token']
self.stubs.Set(nova.api.openstack.compute, 'APIRouter',
@@ -210,6 +204,21 @@ class Test(test.TestCase):
result = req.get_response(fakes.wsgi_app(fake_auth=False))
self.assertEqual(result.status, '401 Unauthorized')
+ def test_auth_token_no_empty_headers(self):
+ f = fakes.FakeAuthManager()
+ user = nova.auth.manager.User('id1', 'user1', 'user1_key', None, None)
+ f.add_user(user)
+
+ req = webob.Request.blank('/v2/')
+ req.headers['X-Auth-User'] = 'user1'
+ req.headers['X-Auth-Key'] = 'user1_key'
+ req.headers['X-Auth-Project-Id'] = 'user1_project'
+ result = req.get_response(fakes.wsgi_app(fake_auth=False))
+ self.assertEqual(result.status, '204 No Content')
+ self.assertEqual(len(result.headers['X-Auth-Token']), 40)
+ self.assertFalse('X-CDN-Management-Url' in result.headers)
+ self.assertFalse('X-Storage-Url' in result.headers)
+
class TestFunctional(test.TestCase):
def test_token_expiry(self):
@@ -297,9 +306,6 @@ class TestNoAuthMiddleware(test.TestCase):
result = req.get_response(fakes.wsgi_app(fake_auth=False,
use_no_auth=True))
self.assertEqual(result.status, '204 No Content')
- self.assertEqual(result.headers['X-CDN-Management-Url'],
- "")
- self.assertEqual(result.headers['X-Storage-Url'], "")
self.assertEqual(result.headers['X-Server-Management-Url'],
"http://localhost/v2/user1_project")
@@ -312,8 +318,16 @@ class TestNoAuthMiddleware(test.TestCase):
result = req.get_response(fakes.wsgi_app(fake_auth=False,
use_no_auth=True))
self.assertEqual(result.status, '204 No Content')
- self.assertEqual(result.headers['X-CDN-Management-Url'],
- "")
- self.assertEqual(result.headers['X-Storage-Url'], "")
self.assertEqual(result.headers['X-Server-Management-Url'],
"http://localhost/v2/user1_project")
+
+ def test_auth_token_no_empty_headers(self):
+ req = webob.Request.blank('/v2')
+ req.headers['X-Auth-User'] = 'user1'
+ req.headers['X-Auth-Key'] = 'user1_key'
+ req.headers['X-Auth-Project-Id'] = 'user1_project'
+ result = req.get_response(fakes.wsgi_app(fake_auth=False,
+ use_no_auth=True))
+ self.assertEqual(result.status, '204 No Content')
+ self.assertFalse('X-CDN-Management-Url' in result.headers)
+ self.assertFalse('X-Storage-Url' in result.headers)