Merge "Implemented the fix to handle the HTTP request methods other than GET."
This commit is contained in:
commit
d20befafd4
@ -184,7 +184,7 @@ from eventlet import Timeout
|
|||||||
import six
|
import six
|
||||||
from swift.common.swob import Response, Request, wsgi_to_str
|
from swift.common.swob import Response, Request, wsgi_to_str
|
||||||
from swift.common.swob import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \
|
from swift.common.swob import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \
|
||||||
HTTPUnauthorized
|
HTTPUnauthorized, HTTPMethodNotAllowed
|
||||||
|
|
||||||
from swift.common.request_helpers import get_sys_meta_prefix
|
from swift.common.request_helpers import get_sys_meta_prefix
|
||||||
from swift.common.middleware.acl import (
|
from swift.common.middleware.acl import (
|
||||||
@ -688,6 +688,9 @@ class TempAuth(object):
|
|||||||
"""
|
"""
|
||||||
req.start_time = time()
|
req.start_time = time()
|
||||||
handler = None
|
handler = None
|
||||||
|
if req.method != 'GET':
|
||||||
|
req.response = HTTPMethodNotAllowed(request=req)
|
||||||
|
return req.response
|
||||||
try:
|
try:
|
||||||
version, account, user, _junk = split_path(req.path_info,
|
version, account, user, _junk = split_path(req.path_info,
|
||||||
1, 4, True)
|
1, 4, True)
|
||||||
|
@ -1024,6 +1024,36 @@ class TestAuth(unittest.TestCase):
|
|||||||
resp = req.get_response(ath)
|
resp = req.get_response(ath)
|
||||||
self.assertEqual(204, resp.status_int)
|
self.assertEqual(204, resp.status_int)
|
||||||
|
|
||||||
|
def test_request_method_not_allowed(self):
|
||||||
|
test_auth = auth.filter_factory({'user_ac_user': 'testing'})(FakeApp())
|
||||||
|
req = self._make_request(
|
||||||
|
'/auth/v1.0',
|
||||||
|
headers={'X-Auth-User': 'ac:user', 'X-Auth-Key': 'testing'},
|
||||||
|
environ={'REQUEST_METHOD': 'PUT'})
|
||||||
|
resp = req.get_response(test_auth)
|
||||||
|
self.assertEqual(resp.status_int, 405)
|
||||||
|
|
||||||
|
req = self._make_request(
|
||||||
|
'/auth/v1.0',
|
||||||
|
headers={'X-Auth-User': 'ac:user', 'X-Auth-Key': 'testing'},
|
||||||
|
environ={'REQUEST_METHOD': 'HEAD'})
|
||||||
|
resp = req.get_response(test_auth)
|
||||||
|
self.assertEqual(resp.status_int, 405)
|
||||||
|
|
||||||
|
req = self._make_request(
|
||||||
|
'/auth/v1.0',
|
||||||
|
headers={'X-Auth-User': 'ac:user', 'X-Auth-Key': 'testing'},
|
||||||
|
environ={'REQUEST_METHOD': 'POST'})
|
||||||
|
resp = req.get_response(test_auth)
|
||||||
|
self.assertEqual(resp.status_int, 405)
|
||||||
|
|
||||||
|
req = self._make_request(
|
||||||
|
'/auth/v1.0',
|
||||||
|
headers={'X-Auth-User': 'ac:user', 'X-Auth-Key': 'testing'},
|
||||||
|
environ={'REQUEST_METHOD': 'DELETE'})
|
||||||
|
resp = req.get_response(test_auth)
|
||||||
|
self.assertEqual(resp.status_int, 405)
|
||||||
|
|
||||||
|
|
||||||
class TestAuthWithMultiplePrefixes(TestAuth):
|
class TestAuthWithMultiplePrefixes(TestAuth):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user