feat: Closes #282, created a new integration test group and test cases for posix specific behaviours testing

This commit is contained in:
jonaustin09
2023-10-11 08:17:10 -07:00
committed by Ben McClelland
parent a3357ac7c6
commit 52674ab0c5
4 changed files with 65 additions and 24 deletions
+5
View File
@@ -73,6 +73,11 @@ func initTestCommands() []*cli.Command {
Description: `Runs all the available tests to test the full flow of the gateway.`,
Action: getAction(integration.TestFullFlow),
},
{
Name: "posix",
Usage: "Tests posix specific features",
Action: getAction(integration.TestPosix),
},
{
Name: "bench",
Usage: "Runs download/upload performance test on the gateway",
@@ -49,8 +49,6 @@ func TestDeleteBucket(s *S3Conf) {
func TestPutObject(s *S3Conf) {
PutObject_non_existing_bucket(s)
PutObject_special_chars(s)
PutObject_existing_dir_obj(s)
PutObject_obj_parent_is_file(s)
PutObject_invalid_long_tags(s)
PutObject_success(s)
}
@@ -217,3 +215,10 @@ func TestFullFlow(s *S3Conf) {
TestPutBucketAcl(s)
TestGetBucketAcl(s)
}
func TestPosix(s *S3Conf) {
PutObject_overwrite_dir_obj(s)
PutObject_overwrite_file_obj(s)
PutObject_dir_obj_with_data(s)
CreateMultipartUpload_dir_obj(s)
}
+48 -22
View File
@@ -1035,28 +1035,6 @@ func PutObject_special_chars(s *S3Conf) {
})
}
func PutObject_existing_dir_obj(s *S3Conf) {
testName := "PutObject_existing_dir_obj"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
err := putObjects(s3client, []string{"foo/bar", "foo"}, bucket)
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrExistingObjectIsDirectory)); err != nil {
return err
}
return nil
})
}
func PutObject_obj_parent_is_file(s *S3Conf) {
testName := "PutObject_obj_parent_is_file"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
err := putObjects(s3client, []string{"foo", "foo/bar/"}, bucket)
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrObjectParentIsFile)); err != nil {
return err
}
return nil
})
}
func PutObject_invalid_long_tags(s *S3Conf) {
testName := "PutObject_invalid_long_tags"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
@@ -3869,3 +3847,51 @@ func TestPerformance(s *S3Conf, upload, download bool, files int, objectSize int
return nil
}
// Posix related tests
func PutObject_overwrite_dir_obj(s *S3Conf) {
testName := "PutObject_overwrite_dir_obj"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
err := putObjects(s3client, []string{"foo/", "foo"}, bucket)
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrExistingObjectIsDirectory)); err != nil {
return err
}
return nil
})
}
func PutObject_overwrite_file_obj(s *S3Conf) {
testName := "PutObject_overwrite_file_obj"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
err := putObjects(s3client, []string{"foo", "foo/"}, bucket)
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrObjectParentIsFile)); err != nil {
return err
}
return nil
})
}
func PutObject_dir_obj_with_data(s *S3Conf) {
testName := "PutObject_dir_obj_with_data"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
_, _, err := putObjectWithData(int64(20), &s3.PutObjectInput{
Bucket: &bucket,
Key: getPtr("obj/"),
}, s3client)
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrDirectoryObjectContainsData)); err != nil {
return err
}
return nil
})
}
func CreateMultipartUpload_dir_obj(s *S3Conf) {
testName := "CreateMultipartUpload_dir_obj"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
_, err := createMp(s3client, bucket, "obj/")
if err := checkApiErr(err, s3err.GetAPIError(s3err.ErrDirectoryObjectContainsData)); err != nil {
return err
}
return nil
})
}
+5
View File
@@ -849,6 +849,11 @@ func (c S3ApiController) CreateActions(ctx *fiber.Ctx) error {
key = strings.Join([]string{key, keyEnd}, "/")
}
path := ctx.Path()
if path[len(path)-1:] == "/" && key[len(key)-1:] != "/" {
key = key + "/"
}
var restoreRequest s3.RestoreObjectInput
if ctx.Request().URI().QueryArgs().Has("restore") {
err := xml.Unmarshal(ctx.Body(), &restoreRequest)