diff --git a/swift/common/swob.py b/swift/common/swob.py index 9bf7a7fc39..8ee1ead450 100644 --- a/swift/common/swob.py +++ b/swift/common/swob.py @@ -857,6 +857,18 @@ class Request(object): return urllib2.quote(self.environ.get('SCRIPT_NAME', '') + self.environ['PATH_INFO']) + @property + def swift_entity_path(self): + """ + Provides the account/container/object path, sans API version. + + This can be useful when constructing a path to send to a backend + server, as that path will need everything after the "/v1". + """ + _ver, entity_path = self.split_path(1, 2, rest_with_last=True) + if entity_path is not None: + return '/' + entity_path + @property def url(self): "Provides the full url of the request" diff --git a/swift/proxy/controllers/account.py b/swift/proxy/controllers/account.py index f706449da0..08433b3f77 100644 --- a/swift/proxy/controllers/account.py +++ b/swift/proxy/controllers/account.py @@ -47,7 +47,7 @@ class AccountController(Controller): partition, nodes = self.app.account_ring.get_nodes(self.account_name) resp = self.GETorHEAD_base( req, _('Account'), self.app.account_ring, partition, - req.path_info.rstrip('/')) + req.swift_entity_path.rstrip('/')) if resp.status_int == HTTP_NOT_FOUND: if resp.headers.get('X-Account-Status', '').lower() == 'deleted': resp.status = HTTP_GONE @@ -81,7 +81,7 @@ class AccountController(Controller): clear_info_cache(self.app, req.environ, self.account_name) resp = self.make_requests( req, self.app.account_ring, account_partition, 'PUT', - req.path_info, [headers] * len(accounts)) + req.swift_entity_path, [headers] * len(accounts)) return resp @public @@ -101,12 +101,12 @@ class AccountController(Controller): clear_info_cache(self.app, req.environ, self.account_name) resp = self.make_requests( req, self.app.account_ring, account_partition, 'POST', - req.path_info, [headers] * len(accounts)) + req.swift_entity_path, [headers] * len(accounts)) if resp.status_int == HTTP_NOT_FOUND and self.app.account_autocreate: self.autocreate_account(req.environ, self.account_name) resp = self.make_requests( req, self.app.account_ring, account_partition, 'POST', - req.path_info, [headers] * len(accounts)) + req.swift_entity_path, [headers] * len(accounts)) return resp @public @@ -127,5 +127,5 @@ class AccountController(Controller): clear_info_cache(self.app, req.environ, self.account_name) resp = self.make_requests( req, self.app.account_ring, account_partition, 'DELETE', - req.path_info, [headers] * len(accounts)) + req.swift_entity_path, [headers] * len(accounts)) return resp diff --git a/swift/proxy/controllers/base.py b/swift/proxy/controllers/base.py index 61f695f417..167a119371 100644 --- a/swift/proxy/controllers/base.py +++ b/swift/proxy/controllers/base.py @@ -947,6 +947,7 @@ class Controller(object): :param part: the partition number :param method: the method to send to the backend :param path: the path to send to the backend + (full path ends up being /<$device>/<$part>/<$path>) :param headers: a list of dicts, where each dict represents one backend request that should be made. :param query: query string to send to the backend. @@ -992,6 +993,7 @@ class Controller(object): :param part: the partition number :param method: the method to send to the backend :param path: the path to send to the backend + (full path ends up being /<$device>/<$part>/<$path>) :param headers: a list of dicts, where each dict represents one backend request that should be made. :param query_string: optional query string to send to the backend @@ -1138,12 +1140,12 @@ class Controller(object): '%s %s' % (server_type, req.method), headers=handler.source_headers) try: - (account, container) = split_path(req.path_info, 1, 2) + (vrs, account, container) = req.split_path(2, 3) _set_info_cache(self.app, req.environ, account, container, res) except ValueError: pass try: - (account, container, obj) = split_path(req.path_info, 3, 3, True) + (vrs, account, container, obj) = req.split_path(4, 4, True) _set_object_info_cache(self.app, req.environ, account, container, obj, res) except ValueError: diff --git a/swift/proxy/controllers/container.py b/swift/proxy/controllers/container.py index 18febc4d2e..4e2ac770d2 100644 --- a/swift/proxy/controllers/container.py +++ b/swift/proxy/controllers/container.py @@ -64,7 +64,8 @@ class ContainerController(Controller): part = self.app.container_ring.get_part( self.account_name, self.container_name) resp = self.GETorHEAD_base( - req, _('Container'), self.app.container_ring, part, req.path_info) + req, _('Container'), self.app.container_ring, part, + req.swift_entity_path) if 'swift.authorize' in req.environ: req.acl = resp.headers.get('x-container-read') aresp = req.environ['swift.authorize'](req) @@ -126,7 +127,7 @@ class ContainerController(Controller): self.account_name, self.container_name) resp = self.make_requests( req, self.app.container_ring, - container_partition, 'PUT', req.path_info, headers) + container_partition, 'PUT', req.swift_entity_path, headers) return resp @public @@ -148,7 +149,7 @@ class ContainerController(Controller): self.account_name, self.container_name) resp = self.make_requests( req, self.app.container_ring, container_partition, 'POST', - req.path_info, [headers] * len(containers)) + req.swift_entity_path, [headers] * len(containers)) return resp @public @@ -167,7 +168,7 @@ class ContainerController(Controller): self.account_name, self.container_name) resp = self.make_requests( req, self.app.container_ring, container_partition, 'DELETE', - req.path_info, headers) + req.swift_entity_path, headers) # Indicates no server had the container if resp.status_int == HTTP_ACCEPTED: return HTTPNotFound(request=req) diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index 8235c54125..b230269e48 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -158,8 +158,9 @@ class SegmentedIterable(object): container, obj = self.container, self.segment_dict['name'] partition = self.controller.app.object_ring.get_part( self.controller.account_name, container, obj) - path = '/%s/%s/%s' % (self.controller.account_name, container, obj) - req = Request.blank(path) + path = '/%s/%s/%s' % (self.controller.account_name, + container, obj) + req = Request.blank('/v1' + path) if self.seek or (self.length and self.length > 0): bytes_available = \ self.segment_dict['bytes'] - self.seek @@ -375,14 +376,14 @@ class ObjectController(Controller): lreq = Request.blank('i will be overridden by env', environ=env) # Don't quote PATH_INFO, by WSGI spec lreq.environ['PATH_INFO'] = \ - '/%s/%s' % (self.account_name, lcontainer) + '/v1/%s/%s' % (self.account_name, lcontainer) lreq.environ['REQUEST_METHOD'] = 'GET' lreq.environ['QUERY_STRING'] = \ 'format=json&prefix=%s&marker=%s' % (quote(lprefix), quote(marker)) lresp = self.GETorHEAD_base( lreq, _('Container'), self.app.container_ring, lpartition, - lreq.path_info) + lreq.swift_entity_path) if 'swift.authorize' in env: lreq.acl = lresp.headers.get('x-container-read') aresp = env['swift.authorize'](lreq) @@ -417,7 +418,7 @@ class ObjectController(Controller): new_req = incoming_req.copy_get() new_req.method = 'GET' new_req.range = None - new_req.path_info = '/'.join(['', account, container, obj]) + new_req.path_info = '/'.join(['/v1', account, container, obj]) if partition is None: try: partition = self.app.object_ring.get_part( @@ -428,7 +429,7 @@ class ObjectController(Controller): new_req.path) valid_resp = self.GETorHEAD_base( new_req, _('Object'), self.app.object_ring, partition, - new_req.path_info) + new_req.swift_entity_path) if 'swift.authorize' in incoming_req.environ: incoming_req.acl = valid_resp.headers.get('x-container-read') @@ -535,7 +536,8 @@ class ObjectController(Controller): partition = self.app.object_ring.get_part( self.account_name, self.container_name, self.object_name) resp = self.GETorHEAD_base( - req, _('Object'), self.app.object_ring, partition, req.path_info) + req, _('Object'), self.app.object_ring, partition, + req.swift_entity_path) if ';' in resp.headers.get('content-type', ''): # strip off swift_bytes from content-type @@ -677,7 +679,7 @@ class ObjectController(Controller): req.headers['x-delete-at'] = '%d' % (time.time() + x_delete_after) if self.app.object_post_as_copy: req.method = 'PUT' - req.path_info = '/%s/%s/%s' % ( + req.path_info = '/v1/%s/%s/%s' % ( self.account_name, self.container_name, self.object_name) req.headers['Content-Length'] = 0 req.headers['X-Copy-From'] = quote('/%s/%s' % (self.container_name, @@ -741,7 +743,7 @@ class ObjectController(Controller): delete_at_container, delete_at_part, delete_at_nodes) resp = self.make_requests(req, self.app.object_ring, partition, - 'POST', req.path_info, headers) + 'POST', req.swift_entity_path, headers) return resp def _backend_requests(self, req, n_outgoing, @@ -913,7 +915,7 @@ class ObjectController(Controller): environ={'REQUEST_METHOD': 'HEAD'}) hresp = self.GETorHEAD_base( hreq, _('Object'), self.app.object_ring, partition, - hreq.path_info) + hreq.swift_entity_path) # Used by container sync feature if 'x-timestamp' in req.headers: try: @@ -989,15 +991,15 @@ class ObjectController(Controller): req.environ.setdefault('swift.log_info', []).append( 'x-copy-from:%s' % source_header) source_header = unquote(source_header) - acct = req.path_info.split('/', 2)[1] + acct = req.swift_entity_path.split('/', 2)[1] if isinstance(acct, unicode): acct = acct.encode('utf-8') if not source_header.startswith('/'): source_header = '/' + source_header - source_header = '/' + acct + source_header + source_header = '/v1/' + acct + source_header try: src_container_name, src_obj_name = \ - source_header.split('/', 3)[2:] + source_header.split('/', 4)[3:] except ValueError: return HTTPPreconditionFailed( request=req, @@ -1082,7 +1084,8 @@ class ObjectController(Controller): if (req.content_length > 0) or chunked: nheaders['Expect'] = '100-continue' pile.spawn(self._connect_put_node, node_iter, partition, - req.path_info, nheaders, self.app.logger.thread_locals) + req.swift_entity_path, nheaders, + self.app.logger.thread_locals) conns = [conn for conn in pile if conn] min_conns = quorum_size(len(nodes)) @@ -1156,7 +1159,7 @@ class ObjectController(Controller): _('Object PUT'), etag=etag) if source_header: resp.headers['X-Copied-From'] = quote( - source_header.split('/', 2)[2]) + source_header.split('/', 3)[3]) if 'last-modified' in source_resp.headers: resp.headers['X-Copied-From-Last-Modified'] = \ source_resp.headers['last-modified'] @@ -1201,7 +1204,7 @@ class ObjectController(Controller): orig_obj = self.object_name self.container_name = lcontainer self.object_name = last_item['name'].encode('utf-8') - copy_path = '/' + self.account_name + '/' + \ + copy_path = '/v1/' + self.account_name + '/' + \ self.container_name + '/' + self.object_name copy_headers = {'X-Newest': 'True', 'Destination': orig_container + '/' + orig_obj @@ -1256,7 +1259,8 @@ class ObjectController(Controller): headers = self._backend_requests( req, len(nodes), container_partition, containers) resp = self.make_requests(req, self.app.object_ring, - partition, 'DELETE', req.path_info, headers) + partition, 'DELETE', req.swift_entity_path, + headers) return resp @public @@ -1284,7 +1288,7 @@ class ObjectController(Controller): # re-write the existing request as a PUT instead of creating a new one # since this one is already attached to the posthooklogger req.method = 'PUT' - req.path_info = '/' + self.account_name + dest + req.path_info = '/v1/' + self.account_name + dest req.headers['Content-Length'] = 0 req.headers['X-Copy-From'] = quote(source) del req.headers['Destination'] diff --git a/swift/proxy/server.py b/swift/proxy/server.py index d78aa78ff9..46bff8b4ed 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -292,8 +292,6 @@ class Application(object): allowed_methods = getattr(controller, 'allowed_methods', set()) return HTTPMethodNotAllowed( request=req, headers={'Allow': ', '.join(allowed_methods)}) - if path_parts['version']: - req.path_info_pop() if 'swift.authorize' in req.environ: # We call authorize before the handler, always. If authorized, # we remove the swift.authorize hook so isn't ever called diff --git a/test/unit/common/test_swob.py b/test/unit/common/test_swob.py index 3ba51ab858..977160284d 100644 --- a/test/unit/common/test_swob.py +++ b/test/unit/common/test_swob.py @@ -669,6 +669,19 @@ class TestRequest(unittest.TestCase): req.accept.best_match(['text/plain', 'application/json']), 'application/json') + def test_swift_entity_path(self): + req = swift.common.swob.Request.blank('/v1/a/c/o') + self.assertEqual(req.swift_entity_path, '/a/c/o') + + req = swift.common.swob.Request.blank('/v1/a/c') + self.assertEqual(req.swift_entity_path, '/a/c') + + req = swift.common.swob.Request.blank('/v1/a') + self.assertEqual(req.swift_entity_path, '/a') + + req = swift.common.swob.Request.blank('/v1') + self.assertEqual(req.swift_entity_path, None) + def test_path_qs(self): req = swift.common.swob.Request.blank('/hi/there?hello=equal&acl') self.assertEqual(req.path_qs, '/hi/there?hello=equal&acl') diff --git a/test/unit/proxy/controllers/test_account.py b/test/unit/proxy/controllers/test_account.py index c0a5d93748..29ed09bd62 100644 --- a/test/unit/proxy/controllers/test_account.py +++ b/test/unit/proxy/controllers/test_account.py @@ -34,7 +34,7 @@ class TestAccountController(unittest.TestCase): controller = proxy_server.AccountController(self.app, 'AUTH_bob') with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(200, body='')): - req = Request.blank('/AUTH_bob', {'PATH_INFO': '/AUTH_bob'}) + req = Request.blank('/v1/AUTH_bob', {'PATH_INFO': '/v1/AUTH_bob'}) resp = controller.HEAD(req) self.assertEqual(2, resp.status_int // 100) self.assertTrue('swift.account/AUTH_bob' in resp.environ) @@ -47,7 +47,7 @@ class TestAccountController(unittest.TestCase): 'x-account-meta-temp-url-key-2': 'value'} controller = proxy_server.AccountController(self.app, 'a') - req = Request.blank('/a') + req = Request.blank('/v1/a') with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(200, headers=owner_headers)): resp = controller.HEAD(req) @@ -55,7 +55,7 @@ class TestAccountController(unittest.TestCase): for key in owner_headers: self.assertTrue(key not in resp.headers) - req = Request.blank('/a', environ={'swift_owner': True}) + req = Request.blank('/v1/a', environ={'swift_owner': True}) with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(200, headers=owner_headers)): resp = controller.HEAD(req) @@ -69,7 +69,7 @@ class TestAccountController(unittest.TestCase): } controller = proxy_server.AccountController(self.app, 'a') - req = Request.blank('/a') + req = Request.blank('/v1/a') with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(404, headers=resp_headers)): resp = controller.HEAD(req) @@ -79,7 +79,7 @@ class TestAccountController(unittest.TestCase): long_acct_name = '%sLongAccountName' % ('Very' * (MAX_ANAME_LEN // 4)) controller = proxy_server.AccountController(self.app, long_acct_name) - req = Request.blank('/%s' % long_acct_name) + req = Request.blank('/v1/%s' % long_acct_name) with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(200)): resp = controller.HEAD(req) diff --git a/test/unit/proxy/controllers/test_base.py b/test/unit/proxy/controllers/test_base.py index 403bf3d40e..7797e74961 100644 --- a/test/unit/proxy/controllers/test_base.py +++ b/test/unit/proxy/controllers/test_base.py @@ -89,7 +89,7 @@ class TestFuncs(unittest.TestCase): def test_GETorHEAD_base(self): base = Controller(self.app) - req = Request.blank('/a/c/o/with/slashes') + req = Request.blank('/v1/a/c/o/with/slashes') with patch('swift.proxy.controllers.base.' 'http_connect', fake_http_connect(200)): resp = base.GETorHEAD_base(req, 'object', FakeRing(), 'part', @@ -97,14 +97,14 @@ class TestFuncs(unittest.TestCase): self.assertTrue('swift.object/a/c/o/with/slashes' in resp.environ) self.assertEqual( resp.environ['swift.object/a/c/o/with/slashes']['status'], 200) - req = Request.blank('/a/c/o') + req = Request.blank('/v1/a/c/o') with patch('swift.proxy.controllers.base.' 'http_connect', fake_http_connect(200)): resp = base.GETorHEAD_base(req, 'object', FakeRing(), 'part', '/a/c/o') self.assertTrue('swift.object/a/c/o' in resp.environ) self.assertEqual(resp.environ['swift.object/a/c/o']['status'], 200) - req = Request.blank('/a/c') + req = Request.blank('/v1/a/c') with patch('swift.proxy.controllers.base.' 'http_connect', fake_http_connect(200)): resp = base.GETorHEAD_base(req, 'container', FakeRing(), 'part', @@ -112,7 +112,7 @@ class TestFuncs(unittest.TestCase): self.assertTrue('swift.container/a/c' in resp.environ) self.assertEqual(resp.environ['swift.container/a/c']['status'], 200) - req = Request.blank('/a') + req = Request.blank('/v1/a') with patch('swift.proxy.controllers.base.' 'http_connect', fake_http_connect(200)): resp = base.GETorHEAD_base(req, 'account', FakeRing(), 'part', diff --git a/test/unit/proxy/controllers/test_container.py b/test/unit/proxy/controllers/test_container.py index 63e6b0e030..e98e04fe8d 100644 --- a/test/unit/proxy/controllers/test_container.py +++ b/test/unit/proxy/controllers/test_container.py @@ -33,7 +33,7 @@ class TestContainerController(unittest.TestCase): controller = proxy_server.ContainerController(self.app, 'a', 'c') with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(200, 200, body='')): - req = Request.blank('/a/c', {'PATH_INFO': '/a/c'}) + req = Request.blank('/v1/a/c', {'PATH_INFO': '/v1/a/c'}) resp = controller.HEAD(req) self.assertEqual(2, resp.status_int // 100) self.assertTrue("swift.container/a/c" in resp.environ) @@ -46,7 +46,7 @@ class TestContainerController(unittest.TestCase): 'x-container-sync-key': 'value', 'x-container-sync-to': 'value'} controller = proxy_server.ContainerController(self.app, 'a', 'c') - req = Request.blank('/a/c') + req = Request.blank('/v1/a/c') with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(200, 200, headers=owner_headers)): resp = controller.HEAD(req) @@ -54,7 +54,7 @@ class TestContainerController(unittest.TestCase): for key in owner_headers: self.assertTrue(key not in resp.headers) - req = Request.blank('/a/c', environ={'swift_owner': True}) + req = Request.blank('/v1/a/c', environ={'swift_owner': True}) with mock.patch('swift.proxy.controllers.base.http_connect', fake_http_connect(200, 200, headers=owner_headers)): resp = controller.HEAD(req) diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 883a06025b..1e64ebbbc2 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -514,7 +514,7 @@ class TestProxyServer(unittest.TestCase): app = MyApp(None, FakeMemcache(), account_ring=FakeRing(), container_ring=FakeRing(), object_ring=FakeRing()) - req = Request.blank('/account', environ={'REQUEST_METHOD': 'HEAD'}) + req = Request.blank('/v1/account', environ={'REQUEST_METHOD': 'HEAD'}) app.update_request(req) resp = app.handle_request(req) self.assertEquals(resp.status_int, 500) @@ -701,7 +701,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c/o', + req = Request.blank('/v1/a/c/o', headers={'Content-Length': '0', 'Content-Type': 'text/plain'}) self.app.update_request(req) @@ -711,7 +711,7 @@ class TestObjectController(unittest.TestCase): # repeat test set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c/o', + req = Request.blank('/v1/a/c/o', headers={'Content-Length': '0', 'Content-Type': 'text/plain'}) self.app.update_request(req) @@ -764,7 +764,7 @@ class TestObjectController(unittest.TestCase): # 100. Perfectly straightforward. set_http_connect(200, 200, (201, -4), (201, -4), (201, -4), give_connect=test_connect) - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/v1/a/c/o.jpg', {}) req.content_length = 0 self.app.update_request(req) self.app.memcache.store = {} @@ -787,7 +787,7 @@ class TestObjectController(unittest.TestCase): proxy_server.ObjectController(self.app, 'a', 'c', 'o.jpg') set_http_connect(200, 200, 201, 201, 201, give_connect=test_connect) - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/v1/a/c/o.jpg', {}) req.content_length = 1 req.body = 'a' self.app.update_request(req) @@ -815,7 +815,7 @@ class TestObjectController(unittest.TestCase): proxy_server.ObjectController(self.app, 'a', 'c', 'o.jpg') set_http_connect(200, 200, 201, 201, 201, give_connect=test_connect) - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/v1/a/c/o.jpg', {}) req.content_length = 1 req.body = 'a' self.app.memcache.store = {} @@ -852,7 +852,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200, # account, container 201, 201, 201, # 3 working backends give_connect=test_connect) - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/v1/a/c/o.jpg', {}) req.content_length = 1 req.body = 'a' self.app.memcache.store = {} @@ -1061,7 +1061,7 @@ class TestObjectController(unittest.TestCase): body_iter=body_iter, headers={'x-versions-location': 'foo'}) self.app.memcache.store = {} - req = Request.blank('/a/c/o', + req = Request.blank('/v1/a/c/o', headers={'X-If-Delete-At': 1}, environ={'REQUEST_METHOD': 'DELETE'}) self.app.update_request(req) @@ -1088,7 +1088,7 @@ class TestObjectController(unittest.TestCase): headers=hdict, body_iter=response_bodies) - req = Request.blank('/a/c/manifest') + req = Request.blank('/v1/a/c/manifest') resp = controller.GET(req) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.body, '') @@ -1167,7 +1167,7 @@ class TestObjectController(unittest.TestCase): body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest') + req = Request.blank('/v1/a/c/manifest') resp = controller.GET(req) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.body, 'AaBbCcDdEe') @@ -1240,7 +1240,7 @@ class TestObjectController(unittest.TestCase): body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest') + req = Request.blank('/v1/a/c/manifest') resp = controller.GET(req) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.body, 'AaBb') @@ -1292,7 +1292,7 @@ class TestObjectController(unittest.TestCase): body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest?multipart-manifest=get') + req = Request.blank('/v1/a/c/manifest?multipart-manifest=get') resp = controller.GET(req) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.body, json_listing) @@ -1342,7 +1342,7 @@ class TestObjectController(unittest.TestCase): body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest?multipart-manifest=get', + req = Request.blank('/v1/a/c/manifest?multipart-manifest=get', headers={'x-copy-from': '/a/c/manifest'}) resp = controller.GET(req) self.assertEqual(resp.status_int, 200) @@ -1395,7 +1395,7 @@ class TestObjectController(unittest.TestCase): 'content-type': 'text/html; swift_bytes=4'}, {}, {}], body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest') + req = Request.blank('/v1/a/c/manifest') resp = controller.GET(req) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.content_length, 4) # content incomplete @@ -1475,7 +1475,7 @@ class TestObjectController(unittest.TestCase): headers=[{}, {}, slob_headers, slob_headers, {}, {}, {}, {}], body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest') + req = Request.blank('/v1/a/c/manifest') resp = controller.GET(req) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.content_length, 8) @@ -1578,7 +1578,7 @@ class TestObjectController(unittest.TestCase): body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest') + req = Request.blank('/v1/a/c/manifest') req.range = 'bytes=4-7' resp = controller.GET(req) got_called = [False, ] @@ -1650,7 +1650,7 @@ class TestObjectController(unittest.TestCase): 'content-type': 'text/html; swift_bytes=4'}, {}, {}], body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest') + req = Request.blank('/v1/a/c/manifest') resp = controller.GET(req) self.assertEqual(resp.status_int, 200) self.assertEqual(resp.content_length, 6) # content incomplete @@ -1707,7 +1707,7 @@ class TestObjectController(unittest.TestCase): body_iter=response_bodies, give_connect=capture_requested_paths) - req = Request.blank('/a/c/manifest', + req = Request.blank('/v1/a/c/manifest', environ={'REQUEST_METHOD': 'HEAD'}) resp = controller.HEAD(req) self.assertEqual(resp.status_int, 200) @@ -1735,7 +1735,7 @@ class TestObjectController(unittest.TestCase): expected.next())) # We need into include a transfer-encoding to get past # constraints.check_object_creation() - req = Request.blank('/a/c/%s' % filename, {}, + req = Request.blank('/v1/a/c/%s' % filename, {}, headers={'transfer-encoding': 'chunked'}) self.app.update_request(req) self.app.memcache.store = {} @@ -1774,7 +1774,7 @@ class TestObjectController(unittest.TestCase): def test_status_map(statuses, expected): set_http_connect(*statuses) - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/v1/a/c/o.jpg', {}) req.content_length = 0 self.app.update_request(req) self.app.memcache.store = {} @@ -1794,7 +1794,7 @@ class TestObjectController(unittest.TestCase): def test_status_map(statuses, expected): set_http_connect(*statuses) self.app.memcache.store = {} - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/v1/a/c/o.jpg', {}) req.content_length = 0 self.app.update_request(req) res = controller.PUT(req) @@ -1814,7 +1814,7 @@ class TestObjectController(unittest.TestCase): def test_status_map(statuses, expected): self.app.memcache.store = {} set_http_connect(*statuses) - req = Request.blank('/a/c/o.jpg', + req = Request.blank('/v1/a/c/o.jpg', environ={'REQUEST_METHOD': 'PUT'}, body='some data') self.app.update_request(req) @@ -1830,7 +1830,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', {}, headers={ + req = Request.blank('/v1/a/c/o', {}, headers={ 'Content-Length': str(MAX_FILE_SIZE + 1), 'Content-Type': 'foo/bar'}) self.app.update_request(req) @@ -1842,7 +1842,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', {}, headers={ + req = Request.blank('/v1/a/c/o', {}, headers={ 'Content-Length': 0, 'Content-Type': 'foo/bar;swift_hey=45'}) self.app.update_request(req) res = controller.PUT(req) @@ -1857,7 +1857,7 @@ class TestObjectController(unittest.TestCase): def test_status_map(statuses, expected): self.app.memcache.store = {} set_http_connect(*statuses) - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/v1/a/c/o.jpg', {}) req.content_length = 0 self.app.update_request(req) res = controller.PUT(req) @@ -2513,7 +2513,7 @@ class TestObjectController(unittest.TestCase): def test_best_response_sets_headers(self): controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'GET'}) + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'GET'}) resp = controller.best_response(req, [200] * 3, ['OK'] * 3, [''] * 3, 'Object', headers=[{'X-Test': '1'}, {'X-Test': '2'}, @@ -2523,7 +2523,7 @@ class TestObjectController(unittest.TestCase): def test_best_response_sets_etag(self): controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'GET'}) + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'GET'}) resp = controller.best_response(req, [200] * 3, ['OK'] * 3, [''] * 3, 'Object') self.assertEquals(resp.etag, None) @@ -2552,7 +2552,8 @@ class TestObjectController(unittest.TestCase): def test_proxy_passes_content_length_on_head(self): with save_globals(): - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'HEAD'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'HEAD'}) self.app.update_request(req) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') @@ -2609,7 +2610,8 @@ class TestObjectController(unittest.TestCase): controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') set_http_connect(200, 200, 200, 200, 200, 200) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) self.app.update_request(req) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 200) @@ -2617,49 +2619,56 @@ class TestObjectController(unittest.TestCase): set_http_connect(404, 404, 404) # acct acct acct # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) set_http_connect(503, 404, 404) # acct acct acct # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) set_http_connect(503, 503, 404) # acct acct acct # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) set_http_connect(503, 503, 503) # acct acct acct # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) set_http_connect(200, 200, 204, 204, 204) # acct cont obj obj obj # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 204) set_http_connect(200, 404, 404, 404) # acct cont cont cont # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) set_http_connect(200, 503, 503, 503) # acct cont cont cont # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) @@ -2670,7 +2679,8 @@ class TestObjectController(unittest.TestCase): # acct [isn't actually called since everything # is error limited] # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) @@ -2683,7 +2693,8 @@ class TestObjectController(unittest.TestCase): # acct cont [isn't actually called since # everything is error limited] # make sure to use a fresh request without cached env - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}) resp = getattr(controller, 'DELETE')(req) self.assertEquals(resp.status_int, 404) @@ -2695,13 +2706,15 @@ class TestObjectController(unittest.TestCase): 'container', 'object') set_http_connect(200, 404, 404, 404, 200, 200, 200) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'PUT'}) self.app.update_request(req) resp = controller.PUT(req) self.assertEquals(resp.status_int, 404) set_http_connect(200, 404, 404, 404, 200, 200) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'POST'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'POST'}, headers={'Content-Type': 'text/plain'}) self.app.update_request(req) resp = controller.POST(req) @@ -2713,13 +2726,14 @@ class TestObjectController(unittest.TestCase): controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') set_http_connect(200, 404, 404, 404, 200, 200, 200) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}) + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}) self.app.update_request(req) resp = controller.PUT(req) self.assertEquals(resp.status_int, 404) set_http_connect(200, 404, 404, 404, 200, 200, 200, 200, 200, 200) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'POST'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'POST'}, headers={'Content-Type': 'text/plain'}) self.app.update_request(req) resp = controller.POST(req) @@ -2731,14 +2745,14 @@ class TestObjectController(unittest.TestCase): 'container', 'object') set_http_connect(200, 200, 201, 201, 201) # acct cont obj obj obj - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0'}) self.app.update_request(req) resp = controller.PUT(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Object-Meta-' + ('a' * MAX_META_NAME_LENGTH): 'v'}) @@ -2746,7 +2760,7 @@ class TestObjectController(unittest.TestCase): resp = controller.PUT(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Object-Meta-' + ('a' * (MAX_META_NAME_LENGTH + 1)): 'v'}) @@ -2755,7 +2769,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 400) set_http_connect(201, 201, 201) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Object-Meta-Too-Long': 'a' * MAX_META_VALUE_LENGTH}) @@ -2763,7 +2777,7 @@ class TestObjectController(unittest.TestCase): resp = controller.PUT(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Object-Meta-Too-Long': 'a' * (MAX_META_VALUE_LENGTH + 1)}) @@ -2775,7 +2789,7 @@ class TestObjectController(unittest.TestCase): headers = {'Content-Length': '0'} for x in xrange(MAX_META_COUNT): headers['X-Object-Meta-%d' % x] = 'v' - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers=headers) self.app.update_request(req) resp = controller.PUT(req) @@ -2784,7 +2798,7 @@ class TestObjectController(unittest.TestCase): headers = {'Content-Length': '0'} for x in xrange(MAX_META_COUNT + 1): headers['X-Object-Meta-%d' % x] = 'v' - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers=headers) self.app.update_request(req) resp = controller.PUT(req) @@ -2803,7 +2817,7 @@ class TestObjectController(unittest.TestCase): if MAX_META_OVERALL_SIZE - size > 1: headers['X-Object-Meta-a'] = \ 'a' * (MAX_META_OVERALL_SIZE - size - 1) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers=headers) self.app.update_request(req) resp = controller.PUT(req) @@ -2811,7 +2825,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(201, 201, 201) headers['X-Object-Meta-a'] = \ 'a' * (MAX_META_OVERALL_SIZE - size) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers=headers) self.app.update_request(req) resp = controller.PUT(req) @@ -2822,7 +2836,7 @@ class TestObjectController(unittest.TestCase): controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') # initial source object PUT - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0'}) self.app.update_request(req) set_http_connect(200, 200, 201, 201, 201) @@ -2831,7 +2845,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 201) # basic copy - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': 'c/o'}) self.app.update_request(req) @@ -2843,7 +2857,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.headers['x-copied-from'], 'c/o') # non-zero content length - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '5', 'X-Copy-From': 'c/o'}) self.app.update_request(req) @@ -2854,7 +2868,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 400) # extra source path parsing - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': 'c/o/o2'}) req.account = 'a' @@ -2866,7 +2880,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2') # space in soure path - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': 'c/o%20o2'}) req.account = 'a' @@ -2878,7 +2892,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.headers['x-copied-from'], 'c/o%20o2') # repeat tests with leading / - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c/o'}) self.app.update_request(req) @@ -2889,7 +2903,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 201) self.assertEquals(resp.headers['x-copied-from'], 'c/o') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c/o/o2'}) req.account = 'a' @@ -2903,7 +2917,7 @@ class TestObjectController(unittest.TestCase): # negative tests # invalid x-copy-from path - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c'}) self.app.update_request(req) @@ -2912,7 +2926,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int // 100, 4) # client error # server error - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c/o'}) self.app.update_request(req) @@ -2923,7 +2937,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 503) # not found - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c/o'}) self.app.update_request(req) @@ -2934,7 +2948,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 404) # some missing containers - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c/o'}) self.app.update_request(req) @@ -2945,7 +2959,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 201) # test object meta data - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c/o', 'X-Object-Meta-Ours': 'okay'}) @@ -2961,7 +2975,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.headers.get('x-delete-at'), '9876543210') # copy-from object is too large to fit in target object - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0', 'X-Copy-From': '/c/o'}) self.app.update_request(req) @@ -2984,7 +2998,7 @@ class TestObjectController(unittest.TestCase): def test_COPY(self): with save_globals(): controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0'}) req.account = 'a' set_http_connect(200, 200, 201, 201, 201) @@ -2992,7 +3006,8 @@ class TestObjectController(unittest.TestCase): resp = controller.PUT(req) self.assertEquals(resp.status_int, 201) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': 'c/o'}) req.account = 'a' set_http_connect(200, 200, 200, 200, 200, 201, 201, 201, 200, 200) @@ -3002,7 +3017,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 201) self.assertEquals(resp.headers['x-copied-from'], 'c/o') - req = Request.blank('/a/c/o/o2', + req = Request.blank('/v1/a/c/o/o2', environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': 'c/o'}) req.account = 'a' @@ -3014,7 +3029,8 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 201) self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) req.account = 'a' controller.object_name = 'o' @@ -3025,7 +3041,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 201) self.assertEquals(resp.headers['x-copied-from'], 'c/o') - req = Request.blank('/a/c/o/o2', + req = Request.blank('/v1/a/c/o/o2', environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) req.account = 'a' @@ -3037,7 +3053,8 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int, 201) self.assertEquals(resp.headers['x-copied-from'], 'c/o/o2') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': 'c_o'}) req.account = 'a' controller.object_name = 'o' @@ -3047,7 +3064,8 @@ class TestObjectController(unittest.TestCase): resp = controller.COPY(req) self.assertEquals(resp.status_int, 412) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) req.account = 'a' controller.object_name = 'o' @@ -3057,7 +3075,8 @@ class TestObjectController(unittest.TestCase): resp = controller.COPY(req) self.assertEquals(resp.status_int, 503) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) req.account = 'a' controller.object_name = 'o' @@ -3067,7 +3086,8 @@ class TestObjectController(unittest.TestCase): resp = controller.COPY(req) self.assertEquals(resp.status_int, 404) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) req.account = 'a' controller.object_name = 'o' @@ -3077,7 +3097,8 @@ class TestObjectController(unittest.TestCase): resp = controller.COPY(req) self.assertEquals(resp.status_int, 201) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o', 'X-Object-Meta-Ours': 'okay'}) req.account = 'a' @@ -3092,7 +3113,8 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.headers.get('x-object-meta-ours'), 'okay') self.assertEquals(resp.headers.get('x-delete-at'), '9876543210') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) self.app.update_request(req) @@ -3114,7 +3136,8 @@ class TestObjectController(unittest.TestCase): def test_COPY_newest(self): with save_globals(): controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) req.account = 'a' controller.object_name = 'o' @@ -3141,7 +3164,8 @@ class TestObjectController(unittest.TestCase): controller._connect_put_node = fake_connect_put_node set_http_connect(200, 200, 200, 200, 200, 201, 201, 201) self.app.memcache.store = {} - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': '/c/o'}) self.app.update_request(req) @@ -3177,7 +3201,8 @@ class TestObjectController(unittest.TestCase): set_http_connect(201, 201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Transfer-Encoding': 'chunked', 'Content-Type': 'foo/bar'}) @@ -3189,7 +3214,8 @@ class TestObjectController(unittest.TestCase): # test 413 entity to large set_http_connect(201, 201, 201, 201) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Transfer-Encoding': 'chunked', 'Content-Type': 'foo/bar'}) req.body_file = ChunkedFile(11) @@ -4279,7 +4305,7 @@ class TestObjectController(unittest.TestCase): # no etag supplied, object servers return success w/ diff values controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '0'}) self.app.update_request(req) set_http_connect(200, 201, 201, 201, @@ -4291,7 +4317,7 @@ class TestObjectController(unittest.TestCase): self.assertEquals(resp.status_int // 100, 5) # server error # req supplies etag, object servers return 422 - mismatch - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={ 'Content-Length': '0', 'ETag': '68b329da9893e34099c7d8ad5cb9c940', @@ -4307,7 +4333,7 @@ class TestObjectController(unittest.TestCase): def test_response_get_accept_ranges_header(self): with save_globals(): - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'GET'}) + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'GET'}) self.app.update_request(req) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') @@ -4318,7 +4344,8 @@ class TestObjectController(unittest.TestCase): def test_response_head_accept_ranges_header(self): with save_globals(): - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'HEAD'}) + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'HEAD'}) self.app.update_request(req) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') @@ -4337,7 +4364,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200, 201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o') + req = Request.blank('/v1/a/c/o') req.environ['swift.authorize'] = authorize self.app.update_request(req) controller.GET(req) @@ -4353,7 +4380,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200, 201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', {'REQUEST_METHOD': 'HEAD'}) + req = Request.blank('/v1/a/c/o', {'REQUEST_METHOD': 'HEAD'}) req.environ['swift.authorize'] = authorize self.app.update_request(req) controller.HEAD(req) @@ -4370,7 +4397,8 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200, 201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'POST'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'POST'}, headers={'Content-Length': '5'}, body='12345') req.environ['swift.authorize'] = authorize self.app.update_request(req) @@ -4387,7 +4415,8 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200, 200, 200, 200, 201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'POST'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'POST'}, headers={'Content-Length': '5'}, body='12345') req.environ['swift.authorize'] = authorize self.app.update_request(req) @@ -4404,7 +4433,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200, 201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '5'}, body='12345') req.environ['swift.authorize'] = authorize self.app.update_request(req) @@ -4421,7 +4450,8 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200, 200, 200, 200, 201, 201, 201) controller = proxy_server.ObjectController(self.app, 'account', 'container', 'object') - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'COPY'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'COPY'}, headers={'Destination': 'c/o'}) req.environ['swift.authorize'] = authorize self.app.update_request(req) @@ -4438,7 +4468,7 @@ class TestObjectController(unittest.TestCase): try: t = time.time() time.time = lambda: t - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Type': 'foo/bar', 'X-Delete-After': '60'}) self.app.update_request(req) @@ -4453,7 +4483,7 @@ class TestObjectController(unittest.TestCase): 'object') set_http_connect(200, 200, 202, 202, 202) self.app.memcache.store = {} - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Type': 'foo/bar', 'X-Delete-After': '60'}) self.app.update_request(req) @@ -4470,7 +4500,7 @@ class TestObjectController(unittest.TestCase): 'container', 'object') set_http_connect(200, 200, 200, 200, 200, 202, 202, 202) self.app.memcache.store = {} - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Type': 'foo/bar', 'X-Delete-After': '60.1'}) self.app.update_request(req) @@ -4484,7 +4514,7 @@ class TestObjectController(unittest.TestCase): 'container', 'object') set_http_connect(200, 200, 200, 200, 200, 202, 202, 202) self.app.memcache.store = {} - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Type': 'foo/bar', 'X-Delete-After': '-60'}) self.app.update_request(req) @@ -4507,7 +4537,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200) self.app.memcache.store = {} t = str(int(time.time() + 100)) - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Type': 'foo/bar', 'X-Delete-At': t}) self.app.update_request(req) @@ -4519,7 +4549,7 @@ class TestObjectController(unittest.TestCase): self.assertTrue('X-Delete-At-Container' in given_headers) t = str(int(time.time() + 100)) + '.1' - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Type': 'foo/bar', 'X-Delete-At': t}) self.app.update_request(req) @@ -4528,7 +4558,7 @@ class TestObjectController(unittest.TestCase): self.assertTrue('Non-integer X-Delete-At' in resp.body) t = str(int(time.time() - 100)) - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Type': 'foo/bar', 'X-Delete-At': t}) self.app.update_request(req) @@ -4546,7 +4576,7 @@ class TestObjectController(unittest.TestCase): try: t = time.time() time.time = lambda: t - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Length': '0', 'Content-Type': 'foo/bar', 'X-Delete-After': '60'}) @@ -4564,7 +4594,7 @@ class TestObjectController(unittest.TestCase): 'container', 'object') set_http_connect(200, 200, 201, 201, 201) self.app.memcache.store = {} - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Length': '0', 'Content-Type': 'foo/bar', 'X-Delete-After': '60.1'}) @@ -4579,7 +4609,7 @@ class TestObjectController(unittest.TestCase): 'container', 'object') set_http_connect(200, 200, 201, 201, 201) self.app.memcache.store = {} - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Length': '0', 'Content-Type': 'foo/bar', 'X-Delete-After': '-60'}) @@ -4602,7 +4632,7 @@ class TestObjectController(unittest.TestCase): set_http_connect(200, 200) self.app.memcache.store = {} t = str(int(time.time() + 100)) - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Length': '0', 'Content-Type': 'foo/bar', 'X-Delete-At': t}) @@ -4615,7 +4645,7 @@ class TestObjectController(unittest.TestCase): self.assertTrue('X-Delete-At-Container' in given_headers) t = str(int(time.time() + 100)) + '.1' - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Length': '0', 'Content-Type': 'foo/bar', 'X-Delete-At': t}) @@ -4625,7 +4655,7 @@ class TestObjectController(unittest.TestCase): self.assertTrue('Non-integer X-Delete-At' in resp.body) t = str(int(time.time() - 100)) - req = Request.blank('/a/c/o', {}, + req = Request.blank('/v1/a/c/o', {}, headers={'Content-Length': '0', 'Content-Type': 'foo/bar', 'X-Delete-At': t}) @@ -4692,7 +4722,7 @@ class TestObjectController(unittest.TestCase): return {} controller.container_info = my_empty_container_info req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.com', 'Access-Control-Request-Method': 'GET'}) @@ -4703,7 +4733,7 @@ class TestObjectController(unittest.TestCase): return {'cors': {'allow_origin': None}} controller.container_info = my_empty_origin_container_info req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.com', 'Access-Control-Request-Method': 'GET'}) @@ -4719,7 +4749,7 @@ class TestObjectController(unittest.TestCase): } controller.container_info = my_container_info req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'https://foo.bar', 'Access-Control-Request-Method': 'GET'}) @@ -4737,13 +4767,13 @@ class TestObjectController(unittest.TestCase): 7) self.assertEquals('999', resp.headers['access-control-max-age']) req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'https://foo.bar'}) req.content_length = 0 resp = controller.OPTIONS(req) self.assertEquals(401, resp.status_int) - req = Request.blank('/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}) + req = Request.blank('/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}) req.content_length = 0 resp = controller.OPTIONS(req) self.assertEquals(200, resp.status_int) @@ -4752,13 +4782,13 @@ class TestObjectController(unittest.TestCase): verb in resp.headers['Allow']) self.assertEquals(len(resp.headers['Allow'].split(', ')), 7) req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.com'}) resp = controller.OPTIONS(req) self.assertEquals(401, resp.status_int) req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.bar', 'Access-Control-Request-Method': 'GET'}) @@ -4775,7 +4805,7 @@ class TestObjectController(unittest.TestCase): } controller.container_info = my_container_info_wildcard req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'https://bar.baz', 'Access-Control-Request-Method': 'GET'}) @@ -4812,7 +4842,7 @@ class TestObjectController(unittest.TestCase): }) req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'GET'}, headers={'Origin': 'http://foo.bar'}) @@ -4862,7 +4892,7 @@ class TestObjectController(unittest.TestCase): key=lambda d: d.get(header_list[0]) or 'z') def test_PUT_x_container_headers_with_equal_replicas(self): - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '5'}, body='12345') controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o') seen_headers = self._gather_x_container_headers( @@ -4883,7 +4913,7 @@ class TestObjectController(unittest.TestCase): def test_PUT_x_container_headers_with_fewer_container_replicas(self): self.app.container_ring.set_replicas(2) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '5'}, body='12345') controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o') seen_headers = self._gather_x_container_headers( @@ -4905,7 +4935,7 @@ class TestObjectController(unittest.TestCase): def test_PUT_x_container_headers_with_more_container_replicas(self): self.app.container_ring.set_replicas(4) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Length': '5'}, body='12345') controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o') seen_headers = self._gather_x_container_headers( @@ -4928,7 +4958,8 @@ class TestObjectController(unittest.TestCase): self.app.container_ring.set_replicas(4) self.app.object_post_as_copy = False - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'POST'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'POST'}, headers={'Content-Type': 'application/stuff'}) controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o') seen_headers = self._gather_x_container_headers( @@ -4950,7 +4981,8 @@ class TestObjectController(unittest.TestCase): def test_DELETE_x_container_headers_with_more_container_replicas(self): self.app.container_ring.set_replicas(4) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'DELETE'}, + req = Request.blank('/v1/a/c/o', + environ={'REQUEST_METHOD': 'DELETE'}, headers={'Content-Type': 'application/stuff'}) controller = proxy_server.ObjectController(self.app, 'a', 'c', 'o') seen_headers = self._gather_x_container_headers( @@ -4978,7 +5010,7 @@ class TestObjectController(unittest.TestCase): delete_at_timestamp / self.app.expiring_objects_container_divisor * self.app.expiring_objects_container_divisor) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Type': 'application/stuff', 'Content-Length': '0', 'X-Delete-At': str(delete_at_timestamp)}) @@ -5015,7 +5047,7 @@ class TestObjectController(unittest.TestCase): delete_at_timestamp / self.app.expiring_objects_container_divisor * self.app.expiring_objects_container_divisor) - req = Request.blank('/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'PUT'}, headers={'Content-Type': 'application/stuff', 'Content-Length': 0, 'X-Delete-At': str(delete_at_timestamp)}) @@ -5070,14 +5102,14 @@ class TestContainerController(unittest.TestCase): kwargs['missing_container'] = missing_container set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c', headers={'Content-Length': '0', + req = Request.blank('/v1/a/c', headers={'Content-Length': '0', 'Content-Type': 'text/plain'}) self.app.update_request(req) res = method(req) self.assertEquals(res.status_int, expected) set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c/', headers={'Content-Length': '0', + req = Request.blank('/v1/a/c/', headers={'Content-Length': '0', 'Content-Type': 'text/plain'}) self.app.update_request(req) res = method(req) @@ -5091,7 +5123,7 @@ class TestContainerController(unittest.TestCase): c_expected=None, a_expected=None, **kwargs): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c', {}) + req = Request.blank('/v1/a/c', {}) self.app.update_request(req) res = controller.HEAD(req) self.assertEquals(res.status[:len(str(expected))], @@ -5115,7 +5147,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c', {}) + req = Request.blank('/v1/a/c', {}) self.app.update_request(req) res = controller.GET(req) self.assertEquals(res.status[:len(str(expected))], @@ -5165,7 +5197,7 @@ class TestContainerController(unittest.TestCase): def test_status_map(statuses, expected, **kwargs): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c', {}) + req = Request.blank('/v1/a/c', {}) req.content_length = 0 self.app.update_request(req) res = controller.PUT(req) @@ -5223,7 +5255,7 @@ class TestContainerController(unittest.TestCase): def test_status_map(statuses, expected, **kwargs): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a/c', {}) + req = Request.blank('/v1/a/c', {}) req.content_length = 0 self.app.update_request(req) res = controller.POST(req) @@ -5302,26 +5334,30 @@ class TestContainerController(unittest.TestCase): else: set_http_connect(200, 200, 200, 200) self.app.memcache.store = {} - req = Request.blank('/a/c', environ={'REQUEST_METHOD': meth}) + req = Request.blank('/v1/a/c', + environ={'REQUEST_METHOD': meth}) self.app.update_request(req) resp = getattr(controller, meth)(req) self.assertEquals(resp.status_int, 200) set_http_connect(404, 404, 404, 200, 200, 200) # Make sure it is a blank request wthout env caching - req = Request.blank('/a/c', environ={'REQUEST_METHOD': meth}) + req = Request.blank('/v1/a/c', + environ={'REQUEST_METHOD': meth}) resp = getattr(controller, meth)(req) self.assertEquals(resp.status_int, 404) set_http_connect(503, 404, 404) # Make sure it is a blank request wthout env caching - req = Request.blank('/a/c', environ={'REQUEST_METHOD': meth}) + req = Request.blank('/v1/a/c', + environ={'REQUEST_METHOD': meth}) resp = getattr(controller, meth)(req) self.assertEquals(resp.status_int, 404) set_http_connect(503, 404, raise_exc=True) # Make sure it is a blank request wthout env caching - req = Request.blank('/a/c', environ={'REQUEST_METHOD': meth}) + req = Request.blank('/v1/a/c', + environ={'REQUEST_METHOD': meth}) resp = getattr(controller, meth)(req) self.assertEquals(resp.status_int, 404) @@ -5330,7 +5366,8 @@ class TestContainerController(unittest.TestCase): dev['last_error'] = time.time() set_http_connect(200, 200, 200, 200, 200, 200) # Make sure it is a blank request wthout env caching - req = Request.blank('/a/c', environ={'REQUEST_METHOD': meth}) + req = Request.blank('/v1/a/c', + environ={'REQUEST_METHOD': meth}) resp = getattr(controller, meth)(req) self.assertEquals(resp.status_int, 404) @@ -5355,7 +5392,7 @@ class TestContainerController(unittest.TestCase): self.app.memcache = MockMemcache(allow_lock=True) set_http_connect(200, 201, 201, 201, missing_container=True) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': 'PUT'}) + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'PUT'}) self.app.update_request(req) res = controller.PUT(req) self.assertEquals(res.status_int, 201) @@ -5413,7 +5450,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 200, body='{}') controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c?format=json') + req = Request.blank('/v1/a/c?format=json') self.app.update_request(req) res = controller.GET(req) self.assert_('accept-ranges' in res.headers) @@ -5424,7 +5461,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 200, body='{}') controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c?format=json') + req = Request.blank('/v1/a/c?format=json') self.app.update_request(req) res = controller.HEAD(req) self.assert_('accept-ranges' in res.headers) @@ -5467,7 +5504,8 @@ class TestContainerController(unittest.TestCase): controller = \ proxy_server.ContainerController(self.app, 'a', 'c') set_http_connect(200, 201, 201, 201, give_connect=test_connect) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', + environ={'REQUEST_METHOD': method}, headers={test_header: test_value}) self.app.update_request(req) getattr(controller, method)(req) @@ -5483,20 +5521,20 @@ class TestContainerController(unittest.TestCase): with save_globals(): controller = proxy_server.ContainerController(self.app, 'a', 'c') set_http_connect(200, 201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}) + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}) self.app.update_request(req) resp = getattr(controller, method)(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Container-Meta-' + ('a' * MAX_META_NAME_LENGTH): 'v'}) self.app.update_request(req) resp = getattr(controller, method)(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Container-Meta-' + ('a' * (MAX_META_NAME_LENGTH + 1)): 'v'}) self.app.update_request(req) @@ -5504,14 +5542,14 @@ class TestContainerController(unittest.TestCase): self.assertEquals(resp.status_int, 400) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Container-Meta-Too-Long': 'a' * MAX_META_VALUE_LENGTH}) self.app.update_request(req) resp = getattr(controller, method)(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Container-Meta-Too-Long': 'a' * (MAX_META_VALUE_LENGTH + 1)}) self.app.update_request(req) @@ -5522,7 +5560,7 @@ class TestContainerController(unittest.TestCase): headers = {} for x in xrange(MAX_META_COUNT): headers['X-Container-Meta-%d' % x] = 'v' - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -5531,7 +5569,7 @@ class TestContainerController(unittest.TestCase): headers = {} for x in xrange(MAX_META_COUNT + 1): headers['X-Container-Meta-%d' % x] = 'v' - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -5549,7 +5587,7 @@ class TestContainerController(unittest.TestCase): if MAX_META_OVERALL_SIZE - size > 1: headers['X-Container-Meta-a'] = \ 'a' * (MAX_META_OVERALL_SIZE - size - 1) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -5557,7 +5595,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(201, 201, 201) headers['X-Container-Meta-a'] = \ 'a' * (MAX_META_OVERALL_SIZE - size) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -5573,7 +5611,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 201, 201, 201) controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c', environ={'REQUEST_METHOD': 'POST'}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'POST'}, headers={'X-Container-Read': '.r:*'}) req.environ['swift.clean_acl'] = clean_acl self.app.update_request(req) @@ -5584,7 +5622,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 201, 201, 201) controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c', environ={'REQUEST_METHOD': 'POST'}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'POST'}, headers={'X-Container-Write': '.r:*'}) req.environ['swift.clean_acl'] = clean_acl self.app.update_request(req) @@ -5601,7 +5639,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 201, 201, 201) controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'PUT'}, headers={'X-Container-Read': '.r:*'}) req.environ['swift.clean_acl'] = clean_acl self.app.update_request(req) @@ -5612,7 +5650,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 201, 201, 201) controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c', environ={'REQUEST_METHOD': 'PUT'}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'PUT'}, headers={'X-Container-Write': '.r:*'}) req.environ['swift.clean_acl'] = clean_acl self.app.update_request(req) @@ -5624,9 +5662,10 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 204, 204, 204) controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c') + req = Request.blank('/v1/a/c') self.app.update_request(req) res = controller.GET(req) + self.assertEquals(res.status_int, 204) self.assertEquals( res.environ['swift.container/a/c']['status'], 204) self.assertEquals(res.content_length, 0) @@ -5642,7 +5681,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 201, 201, 201) controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c') + req = Request.blank('/v1/a/c') req.environ['swift.authorize'] = authorize self.app.update_request(req) res = controller.GET(req) @@ -5659,7 +5698,7 @@ class TestContainerController(unittest.TestCase): set_http_connect(200, 201, 201, 201) controller = proxy_server.ContainerController(self.app, 'account', 'container') - req = Request.blank('/a/c', {'REQUEST_METHOD': 'HEAD'}) + req = Request.blank('/v1/a/c', {'REQUEST_METHOD': 'HEAD'}) req.environ['swift.authorize'] = authorize self.app.update_request(req) controller.HEAD(req) @@ -5673,7 +5712,7 @@ class TestContainerController(unittest.TestCase): return {} controller.container_info = my_empty_container_info req = Request.blank( - '/a/c', + '/v1/a/c', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.com', 'Access-Control-Request-Method': 'GET'}) @@ -5684,7 +5723,7 @@ class TestContainerController(unittest.TestCase): return {'cors': {'allow_origin': None}} controller.container_info = my_empty_origin_container_info req = Request.blank( - '/a/c', + '/v1/a/c', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.com', 'Access-Control-Request-Method': 'GET'}) @@ -5700,7 +5739,7 @@ class TestContainerController(unittest.TestCase): } controller.container_info = my_container_info req = Request.blank( - '/a/c', + '/v1/a/c', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'https://foo.bar', 'Access-Control-Request-Method': 'GET'}) @@ -5718,13 +5757,13 @@ class TestContainerController(unittest.TestCase): 6) self.assertEquals('999', resp.headers['access-control-max-age']) req = Request.blank( - '/a/c', + '/v1/a/c', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'https://foo.bar'}) req.content_length = 0 resp = controller.OPTIONS(req) self.assertEquals(401, resp.status_int) - req = Request.blank('/a/c', {'REQUEST_METHOD': 'OPTIONS'}) + req = Request.blank('/v1/a/c', {'REQUEST_METHOD': 'OPTIONS'}) req.content_length = 0 resp = controller.OPTIONS(req) self.assertEquals(200, resp.status_int) @@ -5733,14 +5772,14 @@ class TestContainerController(unittest.TestCase): verb in resp.headers['Allow']) self.assertEquals(len(resp.headers['Allow'].split(', ')), 6) req = Request.blank( - '/a/c', + '/v1/a/c', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.bar', 'Access-Control-Request-Method': 'GET'}) resp = controller.OPTIONS(req) self.assertEquals(401, resp.status_int) req = Request.blank( - '/a/c', + '/v1/a/c', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.bar', 'Access-Control-Request-Method': 'GET'}) @@ -5757,7 +5796,7 @@ class TestContainerController(unittest.TestCase): } controller.container_info = my_container_info_wildcard req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'https://bar.baz', 'Access-Control-Request-Method': 'GET'}) @@ -5776,7 +5815,7 @@ class TestContainerController(unittest.TestCase): self.assertEquals('999', resp.headers['access-control-max-age']) req = Request.blank( - '/a/c/o.jpg', + '/v1/a/c/o.jpg', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'https://bar.baz', 'Access-Control-Request-Headers': @@ -5809,7 +5848,7 @@ class TestContainerController(unittest.TestCase): }) req = Request.blank( - '/a/c', + '/v1/a/c', {'REQUEST_METHOD': 'GET'}, headers={'Origin': 'http://foo.bar'}) @@ -5859,7 +5898,7 @@ class TestContainerController(unittest.TestCase): def test_PUT_x_account_headers_with_fewer_account_replicas(self): self.app.account_ring.set_replicas(2) - req = Request.blank('/a/c', headers={'': ''}) + req = Request.blank('/v1/a/c', headers={'': ''}) controller = proxy_server.ContainerController(self.app, 'a', 'c') seen_headers = self._gather_x_account_headers( @@ -5879,7 +5918,7 @@ class TestContainerController(unittest.TestCase): def test_PUT_x_account_headers_with_more_account_replicas(self): self.app.account_ring.set_replicas(4) - req = Request.blank('/a/c', headers={'': ''}) + req = Request.blank('/v1/a/c', headers={'': ''}) controller = proxy_server.ContainerController(self.app, 'a', 'c') seen_headers = self._gather_x_account_headers( @@ -5899,7 +5938,7 @@ class TestContainerController(unittest.TestCase): def test_DELETE_x_account_headers_with_fewer_account_replicas(self): self.app.account_ring.set_replicas(2) - req = Request.blank('/a/c', headers={'': ''}) + req = Request.blank('/v1/a/c', headers={'': ''}) controller = proxy_server.ContainerController(self.app, 'a', 'c') seen_headers = self._gather_x_account_headers( @@ -5919,7 +5958,7 @@ class TestContainerController(unittest.TestCase): def test_DELETE_x_account_headers_with_more_account_replicas(self): self.app.account_ring.set_replicas(4) - req = Request.blank('/a/c', headers={'': ''}) + req = Request.blank('/v1/a/c', headers={'': ''}) controller = proxy_server.ContainerController(self.app, 'a', 'c') seen_headers = self._gather_x_account_headers( @@ -5949,7 +5988,7 @@ class TestAccountController(unittest.TestCase): def assert_status_map(self, method, statuses, expected, env_expected=None): with save_globals(): set_http_connect(*statuses) - req = Request.blank('/a', {}) + req = Request.blank('/v1/a', {}) self.app.update_request(req) res = method(req) self.assertEquals(res.status_int, expected) @@ -5957,7 +5996,7 @@ class TestAccountController(unittest.TestCase): self.assertEquals(res.environ['swift.account/a']['status'], env_expected) set_http_connect(*statuses) - req = Request.blank('/a/', {}) + req = Request.blank('/v1/a/', {}) self.app.update_request(req) res = method(req) self.assertEquals(res.status_int, expected) @@ -5969,7 +6008,7 @@ class TestAccountController(unittest.TestCase): with save_globals(): self.app.allow_account_management = False controller = proxy_server.AccountController(self.app, 'account') - req = Request.blank('/account', {'REQUEST_METHOD': 'OPTIONS'}) + req = Request.blank('/v1/account', {'REQUEST_METHOD': 'OPTIONS'}) req.content_length = 0 resp = controller.OPTIONS(req) self.assertEquals(200, resp.status_int) @@ -5983,7 +6022,7 @@ class TestAccountController(unittest.TestCase): self.app.allow_account_management = False controller = proxy_server.AccountController(self.app, 'account') req = Request.blank( - '/account', {'REQUEST_METHOD': 'OPTIONS'}, + '/v1/account', {'REQUEST_METHOD': 'OPTIONS'}, headers={'Origin': 'http://foo.com', 'Access-Control-Request-Method': 'GET'}) req.content_length = 0 @@ -5996,7 +6035,7 @@ class TestAccountController(unittest.TestCase): self.app.allow_account_management = True controller = proxy_server.AccountController(self.app, 'account') - req = Request.blank('/account', {'REQUEST_METHOD': 'OPTIONS'}) + req = Request.blank('/v1/account', {'REQUEST_METHOD': 'OPTIONS'}) req.content_length = 0 resp = controller.OPTIONS(req) self.assertEquals(200, resp.status_int) @@ -6114,7 +6153,7 @@ class TestAccountController(unittest.TestCase): dev['ip'] = '127.0.0.1' dev['port'] = 1 # can't connect on this port controller = proxy_server.AccountController(self.app, 'account') - req = Request.blank('/account', environ={'REQUEST_METHOD': 'HEAD'}) + req = Request.blank('/v1/account', environ={'REQUEST_METHOD': 'HEAD'}) self.app.update_request(req) resp = controller.HEAD(req) self.assertEquals(resp.status_int, 503) @@ -6125,7 +6164,7 @@ class TestAccountController(unittest.TestCase): dev['ip'] = '127.0.0.1' dev['port'] = -1 # invalid port number controller = proxy_server.AccountController(self.app, 'account') - req = Request.blank('/account', environ={'REQUEST_METHOD': 'HEAD'}) + req = Request.blank('/v1/account', environ={'REQUEST_METHOD': 'HEAD'}) self.app.update_request(req) resp = controller.HEAD(req) self.assertEquals(resp.status_int, 503) @@ -6134,7 +6173,7 @@ class TestAccountController(unittest.TestCase): with save_globals(): set_http_connect(200, 200, body='{}') controller = proxy_server.AccountController(self.app, 'account') - req = Request.blank('/a?format=json') + req = Request.blank('/v1/a?format=json') self.app.update_request(req) res = controller.GET(req) self.assert_('accept-ranges' in res.headers) @@ -6144,7 +6183,7 @@ class TestAccountController(unittest.TestCase): with save_globals(): set_http_connect(200, 200, body='{}') controller = proxy_server.AccountController(self.app, 'account') - req = Request.blank('/a?format=json') + req = Request.blank('/v1/a?format=json') self.app.update_request(req) res = controller.HEAD(req) res.body @@ -6158,7 +6197,7 @@ class TestAccountController(unittest.TestCase): def test_status_map(statuses, expected, **kwargs): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a', {}) + req = Request.blank('/v1/a', {}) req.content_length = 0 self.app.update_request(req) res = controller.PUT(req) @@ -6223,7 +6262,8 @@ class TestAccountController(unittest.TestCase): controller = \ proxy_server.AccountController(self.app, 'a') set_http_connect(201, 201, 201, give_connect=test_connect) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', + environ={'REQUEST_METHOD': method}, headers={test_header: test_value}) self.app.update_request(req) getattr(controller, method)(req) @@ -6240,20 +6280,20 @@ class TestAccountController(unittest.TestCase): self.app.allow_account_management = True controller = proxy_server.AccountController(self.app, 'a') set_http_connect(200, 201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}) + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}) self.app.update_request(req) resp = getattr(controller, method)(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Account-Meta-' + ('a' * MAX_META_NAME_LENGTH): 'v'}) self.app.update_request(req) resp = getattr(controller, method)(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Account-Meta-' + ('a' * (MAX_META_NAME_LENGTH + 1)): 'v'}) self.app.update_request(req) @@ -6261,14 +6301,14 @@ class TestAccountController(unittest.TestCase): self.assertEquals(resp.status_int, 400) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Account-Meta-Too-Long': 'a' * MAX_META_VALUE_LENGTH}) self.app.update_request(req) resp = getattr(controller, method)(req) self.assertEquals(resp.status_int, 201) set_http_connect(201, 201, 201) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers={'X-Account-Meta-Too-Long': 'a' * (MAX_META_VALUE_LENGTH + 1)}) self.app.update_request(req) @@ -6279,7 +6319,7 @@ class TestAccountController(unittest.TestCase): headers = {} for x in xrange(MAX_META_COUNT): headers['X-Account-Meta-%d' % x] = 'v' - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -6288,7 +6328,7 @@ class TestAccountController(unittest.TestCase): headers = {} for x in xrange(MAX_META_COUNT + 1): headers['X-Account-Meta-%d' % x] = 'v' - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -6306,7 +6346,7 @@ class TestAccountController(unittest.TestCase): if MAX_META_OVERALL_SIZE - size > 1: headers['X-Account-Meta-a'] = \ 'a' * (MAX_META_OVERALL_SIZE - size - 1) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -6314,7 +6354,7 @@ class TestAccountController(unittest.TestCase): set_http_connect(201, 201, 201) headers['X-Account-Meta-a'] = \ 'a' * (MAX_META_OVERALL_SIZE - size) - req = Request.blank('/a/c', environ={'REQUEST_METHOD': method}, + req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': method}, headers=headers) self.app.update_request(req) resp = getattr(controller, method)(req) @@ -6327,7 +6367,7 @@ class TestAccountController(unittest.TestCase): def test_status_map(statuses, expected, **kwargs): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a', {'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a', {'REQUEST_METHOD': 'DELETE'}) req.content_length = 0 self.app.update_request(req) res = controller.DELETE(req) @@ -6350,7 +6390,8 @@ class TestAccountController(unittest.TestCase): def test_status_map(statuses, expected, **kwargs): set_http_connect(*statuses, **kwargs) self.app.memcache.store = {} - req = Request.blank('/a?whoops', {'REQUEST_METHOD': 'DELETE'}) + req = Request.blank('/v1/a?whoops', + environ={'REQUEST_METHOD': 'DELETE'}) req.content_length = 0 self.app.update_request(req) res = controller.DELETE(req)