@@ -565,6 +565,62 @@ func (s *BlockBlobUnrecordedTestsSuite) TestStageBlockFromURLWithCRC64() {
565565 testcommon .ValidateBlobErrorCode (_require , err , bloberror .CRC64Mismatch )
566566}
567567
568+ func (s * BlockBlobUnrecordedTestsSuite ) TestStageBlockFromURLWithRequestIntent () {
569+ _require := require .New (s .T ())
570+ testName := s .T ().Name ()
571+ svcClient , err := testcommon .GetServiceClient (s .T (), testcommon .TestAccountDefault , nil )
572+ _require .NoError (err )
573+ containerName := testcommon .GenerateContainerName (testName )
574+ containerClient := testcommon .CreateNewContainer (context .Background (), _require , containerName , svcClient )
575+ defer testcommon .DeleteContainer (context .Background (), _require , containerClient )
576+
577+ contentSize := 4 * 1024 // 4 KB
578+ r , _ := testcommon .GetDataAndReader (testName , contentSize )
579+ rsc := streaming .NopCloser (r )
580+
581+ srcBlob := containerClient .NewBlockBlobClient ("src" + testcommon .GenerateBlobName (testName ))
582+ destBlob := containerClient .NewBlockBlobClient ("dst" + testcommon .GenerateBlobName (testName ))
583+
584+ // Prepare source bbClient for copy.
585+ _ , err = srcBlob .Upload (context .Background (), rsc , nil )
586+ _require .NoError (err )
587+
588+ // Get source blob url with SAS for StageFromURL.
589+ srcBlobParts , _ := blob .ParseURL (srcBlob .URL ())
590+ sharedKeyCredential , err := testcommon .GetGenericSharedKeyCredential (testcommon .TestAccountDefault )
591+ _require .NoError (err )
592+ perms := sas.BlobPermissions {Read : true }
593+
594+ srcBlobParts .SAS , err = sas.BlobSignatureValues {
595+ Protocol : sas .ProtocolHTTPS , // Users MUST use HTTPS (not HTTP)
596+ ExpiryTime : time .Now ().UTC ().Add (48 * time .Hour ), // 48-hours before expiration
597+ ContainerName : srcBlobParts .ContainerName ,
598+ BlobName : srcBlobParts .BlobName ,
599+ Permissions : perms .String (),
600+ }.SignWithSharedKey (sharedKeyCredential )
601+ _require .NoError (err )
602+
603+ srcBlobURLWithSAS := srcBlobParts .String ()
604+
605+ // Stage blocks from URL.
606+ blockIDs := testcommon .GenerateBlockIDsList (2 )
607+ requestIntent := blob .FileShareTokenIntentBackup
608+
609+ opts := blockblob.StageBlockFromURLOptions {
610+ FileRequestIntent : & requestIntent ,
611+ }
612+
613+ stageResponse , err := destBlob .StageBlockFromURL (context .Background (), blockIDs [0 ], srcBlobURLWithSAS , & opts )
614+ _require .NoError (err )
615+ _require .NotNil (stageResponse )
616+
617+ // Check block list.
618+ blockList , err := destBlob .GetBlockList (context .Background (), blockblob .BlockListTypeAll , nil )
619+ _require .NoError (err )
620+ _require .NotNil (blockList .BlockList )
621+ _require .Nil (blockList .BlockList .CommittedBlocks )
622+ }
623+
568624//
569625// func (s *BlockBlobUnrecordedTestsSuite) TestCopyBlockBlobFromURL() {
570626// _require := require.New(s.T())
@@ -1180,6 +1236,33 @@ func (s *BlockBlobUnrecordedTestsSuite) TestPutBlobFromURLWithHeaders() {
11801236 _require .EqualValues (resp .Metadata , testcommon .BasicMetadata )
11811237}
11821238
1239+ func (s * BlockBlobUnrecordedTestsSuite ) TestPutBlobFromURLWithIntent () {
1240+ _require := require .New (s .T ())
1241+ testName := s .T ().Name ()
1242+ svcClient , err := testcommon .GetServiceClient (s .T (), testcommon .TestAccountDefault , nil )
1243+ _require .NoError (err )
1244+
1245+ requestIntent := blob .FileShareTokenIntentBackup
1246+
1247+ containerClient , _ , destBlob , srcBlobURLWithSAS , _ := setUpPutBlobFromURLTest (testName , _require , svcClient )
1248+ defer testcommon .DeleteContainer (context .Background (), _require , containerClient )
1249+
1250+ options := blockblob.UploadBlobFromURLOptions {
1251+ Tags : testcommon .BasicBlobTagsMap ,
1252+ HTTPHeaders : & testcommon .BasicHeaders ,
1253+ Metadata : testcommon .BasicMetadata ,
1254+ FileRequestIntent : & requestIntent ,
1255+ }
1256+
1257+ pbResp , err := destBlob .UploadBlobFromURL (context .Background (), srcBlobURLWithSAS , & options )
1258+ _require .NotNil (pbResp )
1259+ _require .NoError (err )
1260+
1261+ // Check dest and source properties
1262+ _ , err = destBlob .GetProperties (context .Background (), nil )
1263+ _require .NoError (err )
1264+ }
1265+
11831266func (s * BlockBlobUnrecordedTestsSuite ) TestPutBlobFromUrlWithCPK () {
11841267 _require := require .New (s .T ())
11851268 testName := s .T ().Name ()
0 commit comments