check the redirected path on the request, not the response

The request object's path changes when it gets redirected. This
behaviour is in tune with the latest WebOb code as well as the
old. The response environ defaults to None in WebOb >= 1.2b1
http://docs.webob.org/en/latest/news.html#b1

Change-Id: I557563ce5407a8ef1b5dae680e456e589285be25
This commit is contained in:
Ionuț Arțăriși 2012-11-30 14:04:04 +01:00
parent f57098df8e
commit af8761d9e0
1 changed files with 4 additions and 4 deletions

View File

@ -154,15 +154,15 @@ class S3TokenMiddlewareTest(unittest.TestCase):
req = webob.Request.blank('/v1/AUTH_cfa/c/o')
req.headers['Authorization'] = 'access:signature'
req.headers['X-Storage-Token'] = 'token'
resp = webob.Request(req.get_response(self.middleware).environ)
self.assertTrue(resp.path.startswith('/v1/AUTH_TENANT_ID'))
self.assertEqual(resp.headers['X-Auth-Token'], 'TOKEN_ID')
req.get_response(self.middleware)
self.assertTrue(req.path.startswith('/v1/AUTH_TENANT_ID'))
self.assertEqual(req.headers['X-Auth-Token'], 'TOKEN_ID')
def test_authorization_nova_toconnect(self):
req = webob.Request.blank('/v1/AUTH_swiftint/c/o')
req.headers['Authorization'] = 'access:FORCED_TENANT_ID:signature'
req.headers['X-Storage-Token'] = 'token'
req = req.get_response(self.middleware)
req.get_response(self.middleware)
path = req.environ['PATH_INFO']
self.assertTrue(path.startswith('/v1/AUTH_FORCED_TENANT_ID'))