(c *minio.Client, bucketName string, sseSrc, sseDst encrypt.ServerSide)
| 9643 | } |
| 9644 | |
| 9645 | func testEncryptedCopyObjectWrapper(c *minio.Client, bucketName string, sseSrc, sseDst encrypt.ServerSide) { |
| 9646 | // initialize logging params |
| 9647 | startTime := time.Now() |
| 9648 | testName := getFuncNameLoc(2) |
| 9649 | function := "CopyObject(destination, source)" |
| 9650 | args := map[string]interface{}{} |
| 9651 | args["testName"] = testName |
| 9652 | var srcEncryption, dstEncryption encrypt.ServerSide |
| 9653 | |
| 9654 | // Make a new bucket in 'us-east-1' (source bucket). |
| 9655 | err := c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"}) |
| 9656 | if err != nil { |
| 9657 | logError(testName, function, args, startTime, "", "MakeBucket failed", err) |
| 9658 | return |
| 9659 | } |
| 9660 | |
| 9661 | defer cleanupBucket(bucketName, c) |
| 9662 | |
| 9663 | // 1. create an sse-c encrypted object to copy by uploading |
| 9664 | const srcSize = 1024 * 1024 |
| 9665 | buf := bytes.Repeat([]byte("abcde"), srcSize) // gives a buffer of 5MiB |
| 9666 | |
| 9667 | // Calculate the CRC32C checksum for the object |
| 9668 | meta := map[string]string{} |
| 9669 | h := minio.ChecksumCRC32C.Hasher() |
| 9670 | h.Reset() |
| 9671 | h.Write(buf) |
| 9672 | meta[minio.ChecksumCRC32C.Key()] = base64.StdEncoding.EncodeToString(h.Sum(nil)) |
| 9673 | |
| 9674 | _, err = c.PutObject(context.Background(), bucketName, "srcObject", bytes.NewReader(buf), int64(len(buf)), minio.PutObjectOptions{ |
| 9675 | ServerSideEncryption: sseSrc, |
| 9676 | DisableMultipart: true, |
| 9677 | DisableContentSha256: true, |
| 9678 | UserMetadata: meta, |
| 9679 | }) |
| 9680 | if err != nil { |
| 9681 | logError(testName, function, args, startTime, "", "PutObject call failed", err) |
| 9682 | return |
| 9683 | } |
| 9684 | |
| 9685 | if sseSrc != nil && sseSrc.Type() != encrypt.S3 { |
| 9686 | srcEncryption = sseSrc |
| 9687 | } |
| 9688 | |
| 9689 | // 2. copy object and change encryption key |
| 9690 | src := minio.CopySrcOptions{ |
| 9691 | Bucket: bucketName, |
| 9692 | Object: "srcObject", |
| 9693 | Encryption: srcEncryption, |
| 9694 | } |
| 9695 | args["source"] = src |
| 9696 | |
| 9697 | dst := minio.CopyDestOptions{ |
| 9698 | Bucket: bucketName, |
| 9699 | Object: "dstObject", |
| 9700 | Encryption: sseDst, |
| 9701 | } |
| 9702 | args["destination"] = dst |
no test coverage detected