diff --git a/swift/proxy/controllers/container.py b/swift/proxy/controllers/container.py index 305c904ad3..ebdffee298 100644 --- a/swift/proxy/controllers/container.py +++ b/swift/proxy/controllers/container.py @@ -17,6 +17,7 @@ from swift import gettext_ as _ import json from six.moves.urllib.parse import unquote + from swift.common.utils import public, csv_append, Timestamp, \ config_true_value, ShardRange from swift.common.constraints import check_metadata, CONTAINER_LISTING_LIMIT @@ -26,7 +27,7 @@ from swift.proxy.controllers.base import Controller, delay_denial, \ cors_validation, set_info_cache, clear_info_cache from swift.common.storage_policy import POLICIES from swift.common.swob import HTTPBadRequest, HTTPForbidden, \ - HTTPNotFound, HTTPServiceUnavailable + HTTPNotFound, HTTPServiceUnavailable, str_to_wsgi, wsgi_to_bytes class ContainerController(Controller): @@ -187,9 +188,9 @@ class ContainerController(Controller): if end_marker and end_marker in shard_range: params['end_marker'] = end_marker elif reverse: - params['end_marker'] = shard_range.lower_str + params['end_marker'] = str_to_wsgi(shard_range.lower_str) else: - params['end_marker'] = shard_range.end_marker + params['end_marker'] = str_to_wsgi(shard_range.end_marker) if (shard_range.account == self.account_name and shard_range.container == self.container_name): @@ -212,11 +213,13 @@ class ContainerController(Controller): if limit <= 0: break - elif (end_marker and reverse and - end_marker >= objects[-1]['name'].encode('utf-8')): + if (end_marker and reverse and + (wsgi_to_bytes(end_marker) >= + objects[-1]['name'].encode('utf-8'))): break - elif (end_marker and not reverse and - end_marker <= objects[-1]['name'].encode('utf-8')): + if (end_marker and not reverse and + (wsgi_to_bytes(end_marker) <= + objects[-1]['name'].encode('utf-8'))): break resp.body = json.dumps(objects).encode('ascii') diff --git a/test/unit/proxy/controllers/test_base.py b/test/unit/proxy/controllers/test_base.py index 65e661f696..4bfd0d0f1b 100644 --- a/test/unit/proxy/controllers/test_base.py +++ b/test/unit/proxy/controllers/test_base.py @@ -47,7 +47,7 @@ class FakeResponse(object): base_headers = {} - def __init__(self, status_int=200, headers=None, body=''): + def __init__(self, status_int=200, headers=None, body=b''): self.status_int = status_int self._headers = headers or {} self.body = body diff --git a/test/unit/proxy/controllers/test_container.py b/test/unit/proxy/controllers/test_container.py index a73f2c3128..c34c19700b 100644 --- a/test/unit/proxy/controllers/test_container.py +++ b/test/unit/proxy/controllers/test_container.py @@ -450,7 +450,8 @@ class TestContainerController(TestRingBase): self.assertLess(name(prev), name(next_)) container_path = '/v1/a/c' + query_string codes = (resp[0] for resp in mock_responses) - bodies = iter([json.dumps(resp[1]) for resp in mock_responses]) + bodies = iter([json.dumps(resp[1]).encode('ascii') + for resp in mock_responses]) exp_headers = [resp[2] for resp in mock_responses] request = Request.blank(container_path) with mocked_http_conn( @@ -1010,7 +1011,7 @@ class TestContainerController(TestRingBase): 'X-Backend-Sharding-State': 'unsharded', 'X-Container-Object-Count': 0, 'X-Container-Bytes-Used': 0, - 'X-Container-Meta-Flavour': 'flavour%d' % i, + 'X-Container-Meta-Flavour': 'flavour', 'X-Backend-Storage-Policy-Index': 0} # empty first shard range diff --git a/tox.ini b/tox.ini index 8eba7ef449..e5e305e530 100644 --- a/tox.ini +++ b/tox.ini @@ -80,6 +80,7 @@ commands = test/unit/obj/test_replicator.py \ test/unit/obj/test_server.py \ test/unit/proxy/controllers/test_base.py \ + test/unit/proxy/controllers/test_container.py \ test/unit/proxy/controllers/test_info.py \ test/unit/proxy/controllers/test_obj.py}