summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--swiftclient/client.py4
-rw-r--r--tests/unit/test_swiftclient.py22
-rw-r--r--tox.ini4
3 files changed, 27 insertions, 3 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 56f236c..e5d564d 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -835,7 +835,7 @@ def get_container(url, token, container, marker=None, limit=None,
if full_listing:
rv = get_container(url, token, container, marker, limit, prefix,
delimiter, end_marker, path, http_conn,
- service_token, headers=headers)
+ service_token=service_token, headers=headers)
listing = rv[1]
while listing:
if not delimiter:
@@ -844,7 +844,7 @@ def get_container(url, token, container, marker=None, limit=None,
marker = listing[-1].get('name', listing[-1].get('subdir'))
listing = get_container(url, token, container, marker, limit,
prefix, delimiter, end_marker, path,
- http_conn, service_token,
+ http_conn, service_token=service_token,
headers=headers)[1]
if listing:
rv[1].extend(listing)
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index c3074fe..5b03831 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -2462,6 +2462,28 @@ class TestServiceToken(MockHttpTest):
actual['full_path'])
self.assertEqual(conn.attempts, 1)
+ def test_service_token_get_container_full_listing(self):
+ # verify service token is sent with each request for a full listing
+ with mock.patch('swiftclient.client.http_connection',
+ self.fake_http_connection(200, 200)):
+ with mock.patch('swiftclient.client.parse_api_response') as resp:
+ resp.side_effect = ([{"name": "obj1"}], [])
+ conn = self.get_connection()
+ conn.get_container('container1', full_listing=True)
+ self.assertEqual(2, len(self.request_log), self.request_log)
+ expected_urls = iter((
+ 'http://storage_url.com/container1?format=json',
+ 'http://storage_url.com/container1?format=json&marker=obj1'
+ ))
+ for actual in self.iter_request_log():
+ self.assertEqual('GET', actual['method'])
+ actual_hdrs = actual['headers']
+ self.assertEqual('stoken', actual_hdrs.get('X-Service-Token'))
+ self.assertEqual('token', actual_hdrs['X-Auth-Token'])
+ self.assertEqual(next(expected_urls),
+ actual['full_path'])
+ self.assertEqual(conn.attempts, 1)
+
def test_service_token_head_container(self):
with mock.patch('swiftclient.client.http_connection',
self.fake_http_connection(200)):
diff --git a/tox.ini b/tox.ini
index a21ea99..cc68d31 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,7 +6,9 @@ skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
-setenv = VIRTUAL_ENV={envdir}
+setenv =
+ LANG=en_US.utf8
+ VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt