Skip to content

Commit

Permalink
enable empty body test for presign
Browse files Browse the repository at this point in the history
  • Loading branch information
skotambkar committed Nov 20, 2020
1 parent b542d1b commit 8db7d37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions service/internal/integrationtest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/wafv2 v0.29.0
github.com/aws/aws-sdk-go-v2/service/workspaces v0.29.0
github.com/awslabs/smithy-go v0.3.1-0.20201120010914-c02b9493fe20
github.com/google/go-cmp v0.5.2
)

go 1.15
Expand Down
18 changes: 10 additions & 8 deletions service/internal/integrationtest/s3/presign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ func TestInteg_PresignURL(t *testing.T) {
"nil-body": {
expectedSignedHeader: http.Header{},
},
// TODO: fix PutObject with an empty body returning 501
// "empty-body": {
// body: bytes.NewReader([]byte("")),
// expectedSignedHeader: http.Header{
// "content-type": {"application/octet-stream"},
// },
// },
"empty-body": {
body: bytes.NewReader([]byte("")),
expectedSignedHeader: http.Header{
"content-type": {"application/octet-stream"},
},
},
}

for name, c := range cases {
Expand Down Expand Up @@ -72,7 +71,7 @@ func TestInteg_PresignURL(t *testing.T) {

presignRequest, err := presignerClient.PresignPutObject(ctx, putObjectInput)
if err != nil {
t.Errorf("expect no error, got %v", err)
t.Fatalf("expect no error, got %v", err)
}

for k, v := range c.expectedSignedHeader {
Expand Down Expand Up @@ -146,6 +145,9 @@ func sendHTTPRequest(presignRequest *v4.PresignedHTTPRequest, body io.Reader) (*
// assign the request body if not nil
if body != nil {
req.Body = ioutil.NopCloser(body)
if req.ContentLength == 0 {
req.Body = nil
}
}

// Upload the object to S3.
Expand Down

0 comments on commit 8db7d37

Please sign in to comment.