-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Truncated S3 "get object" response is reported as error (#3795)
* Add test to ensure S3 truncated response is an error Signed-off-by: Marco Pracucci <[email protected]> * Added missing copyright Signed-off-by: Marco Pracucci <[email protected]> * Upgraded Minio Signed-off-by: Marco Pracucci <[email protected]> * Upgraded Minio again Signed-off-by: Marco Pracucci <[email protected]>
- Loading branch information
Showing
6 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package gcs | ||
|
||
import ( | ||
"context" | ||
"io" | ||
"io/ioutil" | ||
"net/http" | ||
"net/http/httptest" | ||
"os" | ||
"testing" | ||
|
||
"github.com/go-kit/kit/log" | ||
|
||
"github.com/thanos-io/thanos/pkg/testutil" | ||
) | ||
|
||
func TestBucket_Get_ShouldReturnErrorIfServerTruncateResponse(t *testing.T) { | ||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Last-Modified", "Wed, 21 Oct 2015 07:28:00 GMT") | ||
w.Header().Set("Content-Length", "100") | ||
|
||
// Write less bytes than the content length. | ||
_, err := w.Write([]byte("12345")) | ||
testutil.Ok(t, err) | ||
})) | ||
defer srv.Close() | ||
|
||
os.Setenv("STORAGE_EMULATOR_HOST", srv.Listener.Addr().String()) | ||
|
||
cfg := Config{ | ||
Bucket: "test-bucket", | ||
ServiceAccount: "", | ||
} | ||
|
||
bkt, err := NewBucketWithConfig(context.Background(), log.NewNopLogger(), cfg, "test") | ||
testutil.Ok(t, err) | ||
|
||
reader, err := bkt.Get(context.Background(), "test") | ||
testutil.Ok(t, err) | ||
|
||
// We expect an error when reading back. | ||
_, err = ioutil.ReadAll(reader) | ||
testutil.Equals(t, io.ErrUnexpectedEOF, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters