Fix storage class related issues (#5322)

- Add storage class metadata validation for request header
- Change storage class header values to be consistent with AWS S3
- Refactor internal method to take only the reqd argument
This commit is contained in:
Nitish Tiwari
2017-12-27 10:06:16 +05:30
committed by Harshavardhana
parent f25ec31565
commit 545a9e4a82
11 changed files with 117 additions and 37 deletions

View File

@@ -801,6 +801,8 @@ func testAPIPutObjectHandler(obj ObjectLayer, instanceType, bucketName string, a
copySourceHeader.Set("X-Amz-Copy-Source", "somewhere")
invalidMD5Header := http.Header{}
invalidMD5Header.Set("Content-Md5", "42")
inalidStorageClassHeader := http.Header{}
inalidStorageClassHeader.Set(amzStorageClass, "INVALID")
addCustomHeaders := func(req *http.Request, customHeaders http.Header) {
for k, values := range customHeaders {
@@ -895,6 +897,18 @@ func testAPIPutObjectHandler(obj ObjectLayer, instanceType, bucketName string, a
fault: MissingContentLength,
expectedRespStatus: http.StatusLengthRequired,
},
// Test case - 7.
// Test Case with invalid header key X-Amz-Storage-Class
{
bucketName: bucketName,
objectName: objectName,
headers: inalidStorageClassHeader,
data: bytesData,
dataLen: len(bytesData),
accessKey: credentials.AccessKey,
secretKey: credentials.SecretKey,
expectedRespStatus: http.StatusBadRequest,
},
}
// Iterating over the cases, fetching the object validating the response.
for i, testCase := range testCases {