@@ -2423,6 +2423,57 @@ func (s *BlockBlobRecordedTestsSuite) TestCommitBlockListWithCRC64() {
2423
2423
_require .Error (err , bloberror .UnsupportedChecksum )
2424
2424
}
2425
2425
2426
+ func (s * BlockBlobUnrecordedTestsSuite ) TestCopyBlockBlobFromURLWithEncryptionScope () {
2427
+ _require := require .New (s .T ())
2428
+ testName := s .T ().Name ()
2429
+ svcClient , err := testcommon .GetServiceClient (s .T (), testcommon .TestAccountDefault , nil )
2430
+ _require .NoError (err )
2431
+
2432
+ containerName := testcommon .GenerateContainerName (testName )
2433
+ containerClient := testcommon .CreateNewContainer (context .Background (), _require , containerName , svcClient )
2434
+ defer testcommon .DeleteContainer (context .Background (), _require , containerClient )
2435
+
2436
+ // set up source blob
2437
+ const contentSize = 4 * 1024 * 1024 // 4 MB
2438
+ contentReader , _ := testcommon .GetDataAndReader (testName , contentSize )
2439
+
2440
+ srcBlob := containerClient .NewBlockBlobClient (testcommon .GenerateBlobName (testName ))
2441
+ _ , err = srcBlob .Upload (context .Background (), streaming .NopCloser (contentReader ), nil )
2442
+ _require .Nil (err )
2443
+
2444
+ // Get source blob url with SAS for StageFromURL.
2445
+ credential , err := testcommon .GetGenericSharedKeyCredential (testcommon .TestAccountDefault )
2446
+ _require .Nil (err )
2447
+
2448
+ sasQueryParams , err := sas.AccountSignatureValues {
2449
+ Protocol : sas .ProtocolHTTPS ,
2450
+ ExpiryTime : time .Now ().UTC ().Add (48 * time .Hour ), // 48-hours before expiration,
2451
+ Permissions : to .Ptr (sas.AccountPermissions {Read : true , List : true }).String (),
2452
+ ResourceTypes : to .Ptr (sas.AccountResourceTypes {Container : true , Object : true }).String (),
2453
+ }.SignWithSharedKey (credential )
2454
+ _require .Nil (err )
2455
+
2456
+ srcBlobParts , _ := blob .ParseURL (srcBlob .URL ())
2457
+ srcBlobParts .SAS = sasQueryParams
2458
+ srcBlobURLWithSAS := srcBlobParts .String ()
2459
+
2460
+ destBlobName := testcommon .GenerateBlobName (testName )
2461
+ destBlob := containerClient .NewBlockBlobClient (testcommon .GenerateBlobName (destBlobName ))
2462
+
2463
+ encryptionScope , err := testcommon .GetRequiredEnv (testcommon .EncryptionScopeEnvVar )
2464
+ _require .Nil (err )
2465
+ cpk := blob.CPKScopeInfo {
2466
+ EncryptionScope : to .Ptr (encryptionScope ),
2467
+ }
2468
+ copyBlockBlobFromURLOptions := blob.CopyFromURLOptions {
2469
+ CPKScopeInfo : & cpk ,
2470
+ }
2471
+ resp , err := destBlob .CopyFromURL (context .Background (), srcBlobURLWithSAS , & copyBlockBlobFromURLOptions )
2472
+ _require .Nil (err )
2473
+ _require .Equal (* resp .CopyStatus , "success" )
2474
+ _require .Equal (* resp .EncryptionScope , encryptionScope )
2475
+ }
2476
+
2426
2477
func (s * BlockBlobUnrecordedTestsSuite ) TestSetTierOnCopyBlockBlobFromURL () {
2427
2478
_require := require .New (s .T ())
2428
2479
testName := s .T ().Name ()
0 commit comments