fix: add integeration tests

This commit is contained in:
mu-adnan
2026-08-29 12:06:50 +05:00
parent 6121d52778
commit 072081508d
2 changed files with 60 additions and 0 deletions
+58
View File
@@ -976,6 +976,64 @@ func PostObject_success_with_meta_properties(s *S3Conf) error {
})
}
func PostObject_default_content_type(s *S3Conf) error {
testName := "PostObject_default_content_type"
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
for _, tt := range []struct {
key string
policyConditions []any
extraFields map[string]string
}{
{
key: "omitted-content-type",
},
{
key: "empty-content-type",
policyConditions: []any{
[]any{"starts-with", "$Content-Type", ""},
},
extraFields: map[string]string{
"Content-Type": "",
},
},
} {
resp, err := sendPostObject(PostRequestConfig{
bucket: bucket,
key: tt.key,
s3Conf: s,
fileContent: []byte("dummy data"),
policyConditions: tt.policyConditions,
extraFields: tt.extraFields,
})
if err != nil {
return err
}
if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s: expected status code to be 204, instead got %d",
tt.key, resp.StatusCode)
}
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
out, err := s3client.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: &bucket,
Key: &tt.key,
})
cancel()
if err != nil {
return err
}
if getString(out.ContentType) != defaultContentType {
return fmt.Errorf("%s: expected default %s Content-Type, instead got %s",
tt.key, defaultContentType, getString(out.ContentType))
}
}
return nil
})
}
func PostObject_invalid_website_redirect_location(s *S3Conf) error {
testName := "PostObject_invalid_website_redirect_location"
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
+2
View File
@@ -2033,6 +2033,7 @@ func TestPostObject(ts *TestState) {
ts.Run(PostObject_success_status_201)
ts.Run(PostObject_should_ignore_anything_after_file)
ts.Run(PostObject_success_with_meta_properties)
ts.Run(PostObject_default_content_type)
ts.Run(PostObject_invalid_website_redirect_location)
ts.Run(PostObject_invalid_tagging)
ts.Run(PostObject_success_with_tagging)
@@ -3494,6 +3495,7 @@ func GetIntTests() IntTests {
"PostObject_success_status_201": PostObject_success_status_201,
"PostObject_should_ignore_anything_after_file": PostObject_should_ignore_anything_after_file,
"PostObject_success_with_meta_properties": PostObject_success_with_meta_properties,
"PostObject_default_content_type": PostObject_default_content_type,
"PostObject_invalid_website_redirect_location": PostObject_invalid_website_redirect_location,
"PostObject_invalid_tagging": PostObject_invalid_tagging,
"PostObject_success_with_tagging": PostObject_success_with_tagging,