diff --git a/integration/action-tests.go b/integration/action-tests.go index 10265fd..659a765 100644 --- a/integration/action-tests.go +++ b/integration/action-tests.go @@ -74,6 +74,7 @@ func TestListObjects(s *S3Conf) { ListObjects_invalid_max_keys(s) ListObjects_max_keys_0(s) ListObjects_delimiter(s) + ListObjects_max_keys_none(s) } func TestDeleteObject(s *S3Conf) { diff --git a/integration/tests.go b/integration/tests.go index b03cbf6..54779e4 100644 --- a/integration/tests.go +++ b/integration/tests.go @@ -1509,6 +1509,31 @@ func ListObjects_delimiter(s *S3Conf) { }) } +func ListObjects_max_keys_none(s *S3Conf) { + testName := "ListObjects_max_keys_none" + actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { + err := putObjects(s3client, []string{"foo", "bar", "baz"}, bucket) + if err != nil { + return err + } + + ctx, cancel := context.WithTimeout(context.Background(), shortTimeout) + out, err := s3client.ListObjects(ctx, &s3.ListObjectsInput{ + Bucket: &bucket, + }) + cancel() + if err != nil { + return err + } + + if out.MaxKeys != 1000 { + return fmt.Errorf("expected max-keys to be 1000, instead got %v", out.MaxKeys) + } + + return nil + }) +} + func DeleteObject_non_existing_object(s *S3Conf) { testName := "DeleteObject_non_existing_object" actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { diff --git a/s3api/utils/utils.go b/s3api/utils/utils.go index 45a998b..3ac4f32 100644 --- a/s3api/utils/utils.go +++ b/s3api/utils/utils.go @@ -82,11 +82,11 @@ func SetMetaHeaders(ctx *fiber.Ctx, meta map[string]string) { func ParseUint(str string) (int32, error) { if str == "" { - return -1, nil + return 1000, nil } num, err := strconv.ParseUint(str, 10, 16) if err != nil { - return -1, s3err.GetAPIError(s3err.ErrInvalidMaxKeys) + return 1000, s3err.GetAPIError(s3err.ErrInvalidMaxKeys) } return int32(num), nil } diff --git a/s3api/utils/utils_test.go b/s3api/utils/utils_test.go index d473d0b..c830b36 100644 --- a/s3api/utils/utils_test.go +++ b/s3api/utils/utils_test.go @@ -237,7 +237,7 @@ func TestParseUint(t *testing.T) { args: args{ str: "", }, - want: -1, + want: 1000, wantErr: false, }, { @@ -245,7 +245,7 @@ func TestParseUint(t *testing.T) { args: args{ str: "bla", }, - want: -1, + want: 1000, wantErr: true, }, { @@ -253,9 +253,17 @@ func TestParseUint(t *testing.T) { args: args{ str: "-5", }, - want: -1, + want: 1000, wantErr: true, }, + { + name: "Parse-uint-success", + args: args{ + str: "23", + }, + want: 23, + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {