mirror of
https://github.com/versity/versitygw.git
synced 2026-09-29 11:15:36 +00:00
feat: Adds Ownder data in ListObjects(V2) result.
Closes #819 ListObjects returns object owner data in each object entity in the result, while ListObjectsV2 has fetch-owner query param, which indicates if the objects owner data should be fetched. Adds these changes in the gateway to add `Owner` data in `ListObjects` and `ListObjectsV2` result. In aws the objects can be owned by different users in the same bucket. In the gateway all the objects are owned by the bucket owner.
This commit is contained in:
@@ -4815,7 +4815,7 @@ func ListObjects_with_checksum(s *S3Conf) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if !compareObjects(res.Contents, contents) {
|
||||
if !compareObjects(contents, res.Contents) {
|
||||
return fmt.Errorf("expected the objects list to be %v, instead got %v", contents, res.Contents)
|
||||
}
|
||||
|
||||
@@ -4899,6 +4899,38 @@ func ListObjects_nested_dir_file_objs(s *S3Conf) error {
|
||||
})
|
||||
}
|
||||
|
||||
func ListObjects_check_owner(s *S3Conf) error {
|
||||
testName := "ListObjects_check_owner"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
objs, err := putObjects(s3client, []string{"foo", "bar/baz", "quxx/xyz/eee", "abc/", "bcc"}, bucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
res, err := s3client.ListObjects(ctx, &s3.ListObjectsInput{
|
||||
Bucket: &bucket,
|
||||
})
|
||||
cancel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := range res.Contents {
|
||||
res.Contents[i].Owner = &types.Owner{
|
||||
ID: &s.awsID,
|
||||
}
|
||||
}
|
||||
|
||||
if !compareObjects(objs, res.Contents) {
|
||||
return fmt.Errorf("expected the contents to be %v, instead got %v", objs, res.Contents)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func ListObjectsV2_start_after(s *S3Conf) error {
|
||||
testName := "ListObjectsV2_start_after"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
@@ -5290,6 +5322,38 @@ func ListObjectsV2_list_all_objs(s *S3Conf) error {
|
||||
})
|
||||
}
|
||||
|
||||
func ListObjectsV2_with_owner(s *S3Conf) error {
|
||||
testName := "ListObjectsV2_with_owner"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
objs, err := putObjects(s3client, []string{"foo", "bar/baz", "quxx/xyz/eee", "abc/", "bcc"}, bucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
res, err := s3client.ListObjectsV2(ctx, &s3.ListObjectsV2Input{
|
||||
Bucket: &bucket,
|
||||
FetchOwner: getBoolPtr(true),
|
||||
})
|
||||
cancel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := range res.Contents {
|
||||
res.Contents[i].Owner = &types.Owner{
|
||||
ID: &s.awsID,
|
||||
}
|
||||
}
|
||||
|
||||
if !compareObjects(objs, res.Contents) {
|
||||
return fmt.Errorf("expected the contents to be %v, instead got %v", objs, res.Contents)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func ListObjectsV2_with_checksum(s *S3Conf) error {
|
||||
testName := "ListObjectsV2_with_checksum"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
|
||||
Reference in New Issue
Block a user