From 133a3ea601a3fea84af36a42845f27b8182fd901 Mon Sep 17 00:00:00 2001 From: Christopher Bartz Date: Mon, 21 Dec 2015 14:17:00 +0100 Subject: [PATCH] Use the correct split_path in handle_request Change-Id: I86d423309f0b2091ee2e82b2245caf925b6a75ef Closes-Bug: #1528189 --- swift/common/middleware/tempauth.py | 3 ++- test/unit/common/middleware/test_tempauth.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/swift/common/middleware/tempauth.py b/swift/common/middleware/tempauth.py index 9eec784a6e..21a451e103 100644 --- a/swift/common/middleware/tempauth.py +++ b/swift/common/middleware/tempauth.py @@ -631,7 +631,8 @@ class TempAuth(object): req.start_time = time() handler = None try: - version, account, user, _junk = req.split_path(1, 4, True) + version, account, user, _junk = split_path(req.path_info, + 1, 4, True) except ValueError: self.logger.increment('errors') return HTTPNotFound(request=req) diff --git a/test/unit/common/middleware/test_tempauth.py b/test/unit/common/middleware/test_tempauth.py index cea15b6595..292ccecbf5 100644 --- a/test/unit/common/middleware/test_tempauth.py +++ b/test/unit/common/middleware/test_tempauth.py @@ -517,6 +517,18 @@ class TestAuth(unittest.TestCase): self.assertTrue(resp.headers['x-auth-token'].startswith('AUTH_')) self.assertTrue(len(resp.headers['x-auth-token']) > 10) + def test_get_token_success_other_auth_prefix(self): + test_auth = auth.filter_factory({'user_ac_user': 'testing', + 'auth_prefix': '/other/'})(FakeApp()) + req = self._make_request( + '/other/v1.0', + headers={'X-Auth-User': 'ac:user', 'X-Auth-Key': 'testing'}) + resp = req.get_response(test_auth) + self.assertEqual(resp.status_int, 200) + self.assertTrue(resp.headers['x-storage-url'].endswith('/v1/AUTH_ac')) + self.assertTrue(resp.headers['x-auth-token'].startswith('AUTH_')) + self.assertTrue(len(resp.headers['x-auth-token']) > 10) + def test_use_token_success(self): # Example of how to simulate an authorized request test_auth = auth.filter_factory({'user_acct_user': 'testing'})(