mirror of
https://github.com/versity/versitygw.git
synced 2026-05-31 08:06:20 +00:00
Merge pull request #776 from versity/copy-object-with-starting-slash
feat: Added an integration test to cover the case to CopyObject with …
This commit is contained in:
@@ -499,6 +499,7 @@ func TestAccessControl(s *S3Conf) {
|
||||
AccessControl_bucket_ownership_to_user(s)
|
||||
AccessControl_root_PutBucketAcl(s)
|
||||
AccessControl_user_PutBucketAcl_with_policy_access(s)
|
||||
AccessControl_copy_object_with_starting_slash_for_user(s)
|
||||
}
|
||||
|
||||
type IntTests map[string]func(s *S3Conf) error
|
||||
@@ -808,5 +809,6 @@ func GetIntTests() IntTests {
|
||||
"AccessControl_bucket_ownership_to_user": AccessControl_bucket_ownership_to_user,
|
||||
"AccessControl_root_PutBucketAcl": AccessControl_root_PutBucketAcl,
|
||||
"AccessControl_user_PutBucketAcl_with_policy_access": AccessControl_user_PutBucketAcl_with_policy_access,
|
||||
"AccessControl_copy_object_with_starting_slash_for_user": AccessControl_copy_object_with_starting_slash_for_user,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9876,6 +9876,47 @@ func AccessControl_user_PutBucketAcl_with_policy_access(s *S3Conf) error {
|
||||
}, withOwnership(types.ObjectOwnershipBucketOwnerPreferred))
|
||||
}
|
||||
|
||||
func AccessControl_copy_object_with_starting_slash_for_user(s *S3Conf) error {
|
||||
testName := "AccessControl_copy_object_with_starting_slash_for_user"
|
||||
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
|
||||
obj := "my-obj"
|
||||
if err := putObjects(s3client, []string{obj}, bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
usr := user{
|
||||
access: "grt1",
|
||||
secret: "grt1secret",
|
||||
role: "user",
|
||||
}
|
||||
|
||||
if err := changeBucketsOwner(s, []string{bucket}, usr.access); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
copySource := fmt.Sprintf("/%v/%v", bucket, obj)
|
||||
meta := map[string]string{
|
||||
"key1": "val1",
|
||||
}
|
||||
|
||||
userClient := getUserS3Client(usr, s)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
|
||||
_, err := userClient.CopyObject(ctx, &s3.CopyObjectInput{
|
||||
Bucket: &bucket,
|
||||
Key: &obj,
|
||||
CopySource: ©Source,
|
||||
Metadata: meta,
|
||||
MetadataDirective: types.MetadataDirectiveReplace,
|
||||
})
|
||||
cancel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// IAM related tests
|
||||
// multi-user iam tests
|
||||
func IAM_user_access_denied(s *S3Conf) error {
|
||||
|
||||
Reference in New Issue
Block a user