Cleanup and fixes (#3273)

* newRequestID() (previously generateUploadID()) returns string than byte array.
* Remove unclear comments and added appropriate comments.
* SHA-256, MD5 Hash functions return Hex/Base64 encoded string than byte array.
* Remove duplicate MD5 hasher functions.
* Rename listObjectsValidateArgs() into validateListObjectsArgs()
* Remove repeated auth check code in all bucket request handlers.
* Remove abbreviated names in bucket-metadata
* Avoid nested if in bucketPolicyMatchStatement()
* Use ioutil.ReadFile() instead of os.Open() and ioutil.ReadAll()
* Set crossDomainXML as constant.
This commit is contained in:
Bala FA
2016-11-21 13:51:05 -08:00
committed by Harshavardhana
parent 71ada9d6f8
commit bef0a50bc1
35 changed files with 267 additions and 616 deletions
+3 -11
View File
@@ -18,8 +18,6 @@ package cmd
import (
"bytes"
"crypto/md5"
"encoding/hex"
"os"
"path/filepath"
"reflect"
@@ -80,9 +78,7 @@ func TestPutObjectPartFaultyDisk(t *testing.T) {
t.Fatal("Unexpected error ", err)
}
md5Writer := md5.New()
md5Writer.Write(data)
md5Hex := hex.EncodeToString(md5Writer.Sum(nil))
md5Hex := getMD5Hash(data)
sha256sum := ""
// Test with faulty disk
@@ -133,9 +129,7 @@ func TestCompleteMultipartUploadFaultyDisk(t *testing.T) {
t.Fatal("Unexpected error ", err)
}
md5Writer := md5.New()
md5Writer.Write(data)
md5Hex := hex.EncodeToString(md5Writer.Sum(nil))
md5Hex := getMD5Hash(data)
sha256sum := ""
if _, err := fs.PutObjectPart(bucketName, objectName, uploadID, 1, 5, bytes.NewReader(data), md5Hex, sha256sum); err != nil {
@@ -185,9 +179,7 @@ func TestListMultipartUploadsFaultyDisk(t *testing.T) {
t.Fatal("Unexpected error ", err)
}
md5Writer := md5.New()
md5Writer.Write(data)
md5Hex := hex.EncodeToString(md5Writer.Sum(nil))
md5Hex := getMD5Hash(data)
sha256sum := ""
if _, err := fs.PutObjectPart(bucketName, objectName, uploadID, 1, 5, bytes.NewReader(data), md5Hex, sha256sum); err != nil {