From 8d623bff0cab9ec89e096ed2d87075203264ef4e Mon Sep 17 00:00:00 2001 From: zhang Shaowen Date: Fri, 12 Jul 2019 09:36:15 +0800 Subject: [PATCH 1/3] Add a test case for continuation token in list objects v2 Signed-off-by: zhang Shaowen --- s3tests_boto3/functional/test_s3.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 7b15154..16a1a32 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -1392,6 +1392,23 @@ def test_bucket_listv2_continuationtoken_empty(): keys = _get_keys(response) eq(keys, key_names) +@attr(resource='bucket') +@attr(method='get') +@attr(operation='list keys with list-objects-v2') +@attr(assertion='no pagination, non-empty continuationtoken') +@attr('list-objects-v2') +def test_bucket_listv2_continuationtoken(): + key_names = ['bar', 'baz', 'foo', 'quxx'] + bucket_name = _create_objects(keys=key_names) + client = get_client() + + response = client.list_objects_v2(Bucket=bucket_name, ContinuationToken='baz') + eq(response['ContinuationToken'], 'baz') + eq(response['IsTruncated'], False) + key_names2 = ['foo', 'quxx'] + keys = _get_keys(response) + eq(keys, key_names2) + @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') From 9ca600eeafaac34596cbefa579acaafd72bfb556 Mon Sep 17 00:00:00 2001 From: zhang Shaowen Date: Tue, 16 Jul 2019 19:03:25 +0800 Subject: [PATCH 2/3] Add a test case for list objects v2 with both continuation token and start after parameter Signed-off-by: zhang Shaowen --- s3tests_boto3/functional/test_s3.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 16a1a32..827409f 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -1409,6 +1409,24 @@ def test_bucket_listv2_continuationtoken(): keys = _get_keys(response) eq(keys, key_names2) +@attr(resource='bucket') +@attr(method='get') +@attr(operation='list keys with list-objects-v2') +@attr(assertion='no pagination, non-empty continuationtoken and startafter') +@attr('list-objects-v2') +def test_bucket_listv2_both_continuationtoken_startafter(): + key_names = ['bar', 'baz', 'foo', 'quxx'] + bucket_name = _create_objects(keys=key_names) + client = get_client() + + response = client.list_objects_v2(Bucket=bucket_name, StartAfter='bar', ContinuationToken='baz') + eq(response['ContinuationToken'], 'baz') + eq(response['StartAfter'], 'bar') + eq(response['IsTruncated'], False) + key_names2 = ['foo', 'quxx'] + keys = _get_keys(response) + eq(keys, key_names2) + @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') From f57910a0141739217b50135002483cefda5343a8 Mon Sep 17 00:00:00 2001 From: zhang Shaowen Date: Thu, 18 Jul 2019 15:06:06 +0800 Subject: [PATCH 3/3] Update the continuation token test case so that it won't fail on aws Signed-off-by: zhang Shaowen --- s3tests_boto3/functional/test_s3.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 827409f..3f7090d 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -1402,11 +1402,14 @@ def test_bucket_listv2_continuationtoken(): bucket_name = _create_objects(keys=key_names) client = get_client() - response = client.list_objects_v2(Bucket=bucket_name, ContinuationToken='baz') - eq(response['ContinuationToken'], 'baz') - eq(response['IsTruncated'], False) - key_names2 = ['foo', 'quxx'] - keys = _get_keys(response) + response1 = client.list_objects_v2(Bucket=bucket_name, MaxKeys=1) + next_continuation_token = response1['NextContinuationToken'] + + response2 = client.list_objects_v2(Bucket=bucket_name, ContinuationToken=next_continuation_token) + eq(response2['ContinuationToken'], next_continuation_token) + eq(response2['IsTruncated'], False) + key_names2 = ['baz', 'foo', 'quxx'] + keys = _get_keys(response2) eq(keys, key_names2) @attr(resource='bucket') @@ -1419,12 +1422,15 @@ def test_bucket_listv2_both_continuationtoken_startafter(): bucket_name = _create_objects(keys=key_names) client = get_client() - response = client.list_objects_v2(Bucket=bucket_name, StartAfter='bar', ContinuationToken='baz') - eq(response['ContinuationToken'], 'baz') - eq(response['StartAfter'], 'bar') - eq(response['IsTruncated'], False) + response1 = client.list_objects_v2(Bucket=bucket_name, StartAfter='bar', MaxKeys=1) + next_continuation_token = response1['NextContinuationToken'] + + response2 = client.list_objects_v2(Bucket=bucket_name, StartAfter='bar', ContinuationToken=next_continuation_token) + eq(response2['ContinuationToken'], next_continuation_token) + eq(response2['StartAfter'], 'bar') + eq(response2['IsTruncated'], False) key_names2 = ['foo', 'quxx'] - keys = _get_keys(response) + keys = _get_keys(response2) eq(keys, key_names2) @attr(resource='bucket')