diff --git a/tests/integration/group-tests.go b/tests/integration/group-tests.go index 292c0407..6c059122 100644 --- a/tests/integration/group-tests.go +++ b/tests/integration/group-tests.go @@ -169,7 +169,7 @@ func TestGetObject(s *S3Conf) { func TestListObjects(s *S3Conf) { ListObjects_non_existing_bucket(s) ListObjects_with_prefix(s) - ListObject_truncated(s) + ListObjects_truncated(s) ListObjects_invalid_max_keys(s) ListObjects_max_keys_0(s) ListObjects_delimiter(s) @@ -185,6 +185,7 @@ func TestListObjectsV2(s *S3Conf) { ListObjectsV2_both_delimiter_and_prefix(s) ListObjectsV2_single_dir_object_with_delim_and_prefix(s) ListObjectsV2_truncated_common_prefixes(s) + ListObjectsV2_all_objs_max_keys(s) } func TestDeleteObject(s *S3Conf) { @@ -609,7 +610,7 @@ func GetIntTests() IntTests { "GetObject_non_existing_dir_object": GetObject_non_existing_dir_object, "ListObjects_non_existing_bucket": ListObjects_non_existing_bucket, "ListObjects_with_prefix": ListObjects_with_prefix, - "ListObject_truncated": ListObject_truncated, + "ListObjects_truncated": ListObjects_truncated, "ListObjects_invalid_max_keys": ListObjects_invalid_max_keys, "ListObjects_max_keys_0": ListObjects_max_keys_0, "ListObjects_delimiter": ListObjects_delimiter, @@ -622,6 +623,7 @@ func GetIntTests() IntTests { "ListObjectsV2_both_delimiter_and_prefix": ListObjectsV2_both_delimiter_and_prefix, "ListObjectsV2_single_dir_object_with_delim_and_prefix": ListObjectsV2_single_dir_object_with_delim_and_prefix, "ListObjectsV2_truncated_common_prefixes": ListObjectsV2_truncated_common_prefixes, + "ListObjectsV2_all_objs_max_keys": ListObjectsV2_all_objs_max_keys, "DeleteObject_non_existing_object": DeleteObject_non_existing_object, "DeleteObject_name_too_long": DeleteObject_name_too_long, "DeleteObject_non_existing_dir_object": DeleteObject_non_existing_dir_object, diff --git a/tests/integration/tests.go b/tests/integration/tests.go index dd6f02af..f948e750 100644 --- a/tests/integration/tests.go +++ b/tests/integration/tests.go @@ -3676,8 +3676,8 @@ func ListObjects_with_prefix(s *S3Conf) error { }) } -func ListObject_truncated(s *S3Conf) error { - testName := "ListObject_truncated" +func ListObjects_truncated(s *S3Conf) error { + testName := "ListObjects_truncated" return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { maxKeys := int32(2) err := putObjects(s3client, []string{"foo", "bar", "baz"}, bucket) @@ -4163,6 +4163,46 @@ func ListObjectsV2_truncated_common_prefixes(s *S3Conf) error { }) } +func ListObjectsV2_all_objs_max_keys(s *S3Conf) error { + testName := "ListObjectsV2_all_objs_max_keys" + return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { + objs := []string{"bar", "baz", "foo"} + if err := putObjects(s3client, objs, bucket); err != nil { + return err + } + + maxKeys := int32(len(objs)) + + ctx, cancel := context.WithTimeout(context.Background(), shortTimeout) + out, err := s3client.ListObjectsV2(ctx, &s3.ListObjectsV2Input{ + Bucket: &bucket, + MaxKeys: &maxKeys, + }) + cancel() + if err != nil { + return err + } + + if *out.IsTruncated { + return fmt.Errorf("expected the output not to be truncated") + } + if getString(out.NextContinuationToken) != "" { + return fmt.Errorf("expected empty NextContinuationToken, instead got %v", *out.NextContinuationToken) + } + if *out.MaxKeys != maxKeys { + return fmt.Errorf("expected the max-keys to be %v, instead got %v", maxKeys, *out.MaxKeys) + } + + contents := createEmptyObjectsList(objs) + + if !compareObjects(contents, out.Contents) { + return fmt.Errorf("expected the objects list to be %v, instead got %v", contents, out.Contents) + } + + return nil + }) +} + func DeleteObject_non_existing_object(s *S3Conf) error { testName := "DeleteObject_non_existing_object" return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {