When object whose size is greater than 5G is uploaded using presigned POST we should return error. (#3033)

fixes #2961
This commit is contained in:
Krishna Srinivas
2016-10-22 21:35:01 +05:30
committed by Harshavardhana
parent e51be73ac7
commit 5999a23d3e
6 changed files with 65 additions and 1 deletions
+23
View File
@@ -17,6 +17,8 @@
package cmd
import (
"io/ioutil"
"strings"
"testing"
)
@@ -113,3 +115,24 @@ func TestIsValidObjectName(t *testing.T) {
}
}
}
// Tests limitReader
func TestLimitReader(t *testing.T) {
testCases := []struct {
data string
maxLen int64
err error
}{
{"1234567890", 15, nil},
{"1234567890", 10, nil},
{"1234567890", 5, errDataTooLarge},
}
for i, test := range testCases {
r := strings.NewReader(test.data)
_, err := ioutil.ReadAll(limitReader(r, test.maxLen))
if err != test.err {
t.Fatalf("test %d failed: expected %v, got %v", i+1, test.err, err)
}
}
}