(c *minio.Client, bucketName string, sseSrc, sseDst encrypt.ServerSide)
| 9747 | } |
| 9748 | |
| 9749 | func testEncryptedCopyObjectWrapper(c *minio.Client, bucketName string, sseSrc, sseDst encrypt.ServerSide) { |
| 9750 | // initialize logging params |
| 9751 | startTime := time.Now() |
| 9752 | testName := getFuncNameLoc(2) |
| 9753 | function := "CopyObject(destination, source)" |
| 9754 | args := map[string]interface{}{} |
| 9755 | args["testName"] = testName |
| 9756 | var srcEncryption, dstEncryption encrypt.ServerSide |
| 9757 | |
| 9758 | // Make a new bucket in 'us-east-1' (source bucket). |
| 9759 | err := c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"}) |
| 9760 | if err != nil { |
| 9761 | logError(testName, function, args, startTime, "", "MakeBucket failed", err) |
| 9762 | return |
| 9763 | } |
| 9764 | |
| 9765 | defer cleanupBucket(bucketName, c) |
| 9766 | |
| 9767 | // 1. create an sse-c encrypted object to copy by uploading |
| 9768 | const srcSize = 1024 * 1024 |
| 9769 | buf := bytes.Repeat([]byte("abcde"), srcSize) // gives a buffer of 5MiB |
| 9770 | |
| 9771 | // Calculate the CRC32C checksum for the object |
| 9772 | meta := map[string]string{} |
| 9773 | h := minio.ChecksumCRC32C.Hasher() |
| 9774 | h.Reset() |
| 9775 | h.Write(buf) |
| 9776 | meta[minio.ChecksumCRC32C.Key()] = base64.StdEncoding.EncodeToString(h.Sum(nil)) |
| 9777 | |
| 9778 | _, err = c.PutObject(context.Background(), bucketName, "srcObject", bytes.NewReader(buf), int64(len(buf)), minio.PutObjectOptions{ |
| 9779 | ServerSideEncryption: sseSrc, |
| 9780 | DisableMultipart: true, |
| 9781 | DisableContentSha256: true, |
| 9782 | UserMetadata: meta, |
| 9783 | }) |
| 9784 | if err != nil { |
| 9785 | logError(testName, function, args, startTime, "", "PutObject call failed", err) |
| 9786 | return |
| 9787 | } |
| 9788 | |
| 9789 | if sseSrc != nil && sseSrc.Type() != encrypt.S3 { |
| 9790 | srcEncryption = sseSrc |
| 9791 | } |
| 9792 | |
| 9793 | // 2. copy object and change encryption key |
| 9794 | src := minio.CopySrcOptions{ |
| 9795 | Bucket: bucketName, |
| 9796 | Object: "srcObject", |
| 9797 | Encryption: srcEncryption, |
| 9798 | } |
| 9799 | args["source"] = src |
| 9800 | |
| 9801 | dst := minio.CopyDestOptions{ |
| 9802 | Bucket: bucketName, |
| 9803 | Object: "dstObject", |
| 9804 | Encryption: sseDst, |
| 9805 | } |
| 9806 | args["destination"] = dst |
no test coverage detected