MCPcopy
hub / github.com/minio/minio-go / testSSECEncryptionFPut

Function testSSECEncryptionFPut

functional_tests.go:7221–7329  ·  view source on GitHub ↗

TestEncryptionFPut tests encryption with customer specified encryption keys

()

Source from the content-addressed store, hash-verified

7219
7220// TestEncryptionFPut tests encryption with customer specified encryption keys
7221func testSSECEncryptionFPut() {
7222 // initialize logging params
7223 startTime := time.Now()
7224 testName := getFuncName()
7225 function := "FPutEncryptedObject(bucketName, objectName, filePath, contentType, sse)"
7226 args := map[string]interface{}{
7227 "bucketName": "",
7228 "objectName": "",
7229 "filePath": "",
7230 "contentType": "",
7231 "sse": "",
7232 }
7233
7234 c, err := NewClient(ClientConfig{})
7235 if err != nil {
7236 logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
7237 return
7238 }
7239
7240 // Generate a new random bucket name.
7241 bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
7242 args["bucketName"] = bucketName
7243
7244 // Make a new bucket.
7245 err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
7246 if err != nil {
7247 logError(testName, function, args, startTime, "", "MakeBucket failed", err)
7248 return
7249 }
7250
7251 defer cleanupBucket(bucketName, c)
7252
7253 // Object custom metadata
7254 customContentType := "custom/contenttype"
7255 args["metadata"] = customContentType
7256
7257 testCases := []struct {
7258 buf []byte
7259 }{
7260 {buf: bytes.Repeat([]byte("F"), 0)},
7261 {buf: bytes.Repeat([]byte("F"), 1)},
7262 {buf: bytes.Repeat([]byte("F"), 15)},
7263 {buf: bytes.Repeat([]byte("F"), 16)},
7264 {buf: bytes.Repeat([]byte("F"), 17)},
7265 {buf: bytes.Repeat([]byte("F"), 31)},
7266 {buf: bytes.Repeat([]byte("F"), 32)},
7267 {buf: bytes.Repeat([]byte("F"), 33)},
7268 {buf: bytes.Repeat([]byte("F"), 1024)},
7269 {buf: bytes.Repeat([]byte("F"), 1024*2)},
7270 {buf: bytes.Repeat([]byte("F"), 1024*1024)},
7271 }
7272
7273 const password = "correct horse battery staple" // https://xkcd.com/936/
7274 for i, testCase := range testCases {
7275 // Generate a random object name
7276 objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
7277 args["objectName"] = objectName
7278

Callers 1

mainFunction · 0.85

Calls 14

MakeBucketMethod · 0.95
FPutObjectMethod · 0.95
GetObjectMethod · 0.95
getFuncNameFunction · 0.85
NewClientFunction · 0.85
logErrorFunction · 0.85
cleanupBucketFunction · 0.85
logSuccessFunction · 0.85
LenMethod · 0.80
EqualMethod · 0.80
randStringFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected