From 8883a4ef639229ccffa58595f4164365e2c9dd67 Mon Sep 17 00:00:00 2001 From: Koert van der Veer Date: Mon, 22 Oct 2012 15:16:23 +0200 Subject: [PATCH] Stub out ?versioning command. This is necessary for CyberDuck, which issues the versioning command and errors out if that doesn't work. This implementation simply returns that versioning hasn't been configured. --- swift3/middleware.py | 8 +++++++- swift3/test/unit/test_swift3.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/swift3/middleware.py b/swift3/middleware.py index f1e3f07b..5f415613 100644 --- a/swift3/middleware.py +++ b/swift3/middleware.py @@ -270,7 +270,7 @@ def canonical_string(req): path, args = path.split('?', 1) for key in urlparse.parse_qs(args, keep_blank_values=True): if key in ('acl', 'logging', 'torrent', 'location', - 'requestPayment'): + 'requestPayment', 'versioning'): return "%s%s?%s" % (buf, path, key) return buf + path @@ -431,6 +431,12 @@ class BucketController(WSGIContext): if 'acl' in args: return get_acl(self.account_name, headers) + if 'versioning' in args: + # Just report there is no versioning configured here. + body = ('') + return Response(body=body, content_type="text/plain") + if status != HTTP_OK: if status == HTTP_UNAUTHORIZED: return get_err_response('AccessDenied') diff --git a/swift3/test/unit/test_swift3.py b/swift3/test/unit/test_swift3.py index 84ba6854..8e2646ba 100644 --- a/swift3/test/unit/test_swift3.py +++ b/swift3/test/unit/test_swift3.py @@ -408,6 +408,16 @@ class TestSwift3(unittest.TestCase): resp = local_app(req.environ, local_app.app.do_start_response) self._check_acl('test:tester', resp) + def test_bucket_versioning_GET(self): + local_app = swift3.filter_factory({})(FakeAppBucket()) + bucket_name = 'junk' + req = Request.blank('/%s?versioning' % bucket_name, + environ={'REQUEST_METHOD': 'GET'}, + headers={'Authorization': 'AWS test:tester:hmac'}) + resp = local_app(req.environ, local_app.app.do_start_response) + dom = xml.dom.minidom.parseString("".join(resp)) + self.assertEquals(dom.firstChild.nodeName, 'VersioningConfiguration') + def _test_object_GETorHEAD(self, method): local_app = swift3.filter_factory({})(FakeAppObject()) req = Request.blank('/bucket/object',