Skip to content

Commit 012e305

Browse files
[Storage][DataMovement] Fix bugs associated with encoding special characters (Azure#51066)
1 parent 44a7097 commit 012e305

20 files changed

+363
-84
lines changed

sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.DataMovement.Blobs.Files.Shares",
5-
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs.Files.Shares_3cdf992080"
5+
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs.Files.Shares_430413f807"
66
}

sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/tests/StartTransferCopyFromShareDirectoryTestBase.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,25 @@ protected override async Task CreateObjectInSourceAsync(
102102
}
103103
}
104104

105-
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerAsync(BlobServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
106-
=> await DestinationClientBuilder.GetTestContainerAsync(service, containerName);
107-
108-
protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName)
105+
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerOauthAsync(
106+
string containerName = default,
107+
CancellationToken cancellationToken = default)
109108
{
110-
BlobClientOptions options = DestinationClientBuilder.GetOptions();
111-
BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
112-
return oauthService.GetBlobContainerClient(containerName);
109+
BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential);
110+
return await DestinationClientBuilder.GetTestContainerAsync(oauthService, containerName);
113111
}
114112

115-
protected override ShareClient GetOAuthSourceContainerClient(string containerName)
113+
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerAsync(BlobServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
114+
=> await DestinationClientBuilder.GetTestContainerAsync(service, containerName);
115+
116+
protected override async Task<IDisposingContainer<ShareClient>> GetSourceDisposingContainerOauthAsync(
117+
string containerName = default,
118+
CancellationToken cancellationToken = default)
116119
{
117120
ShareClientOptions options = SourceClientBuilder.GetOptions();
118121
options.ShareTokenIntent = ShareTokenIntent.Backup;
119122
ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
120-
return oauthService.GetShareClient(containerName);
123+
return await SourceClientBuilder.GetTestShareAsync(oauthService, containerName);
121124
}
122125

123126
protected override async Task<IDisposingContainer<ShareClient>> GetSourceDisposingContainerAsync(

sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/tests/StartTransferCopyToShareDirectoryTestBase.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ protected override async Task CreateObjectInDestinationAsync(ShareClient contain
9494
}
9595
}
9696

97+
protected override async Task<IDisposingContainer<ShareClient>> GetDestinationDisposingContainerOauthAsync(
98+
string containerName = default,
99+
CancellationToken cancellationToken = default)
100+
{
101+
ShareClientOptions options = DestinationClientBuilder.GetOptions();
102+
options.ShareTokenIntent = ShareTokenIntent.Backup;
103+
ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
104+
return await DestinationClientBuilder.GetTestShareAsync(oauthService, containerName);
105+
}
106+
97107
protected override async Task<IDisposingContainer<ShareClient>> GetDestinationDisposingContainerAsync(ShareServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
98108
=> await DestinationClientBuilder.GetTestShareAsync(service, containerName);
99109

@@ -176,19 +186,12 @@ public ShareClientOptions GetShareOptions()
176186
return InstrumentClientOptions(options);
177187
}
178188

179-
protected override ShareClient GetOAuthDestinationContainerClient(string containerName)
180-
{
181-
ShareClientOptions options = DestinationClientBuilder.GetOptions();
182-
options.ShareTokenIntent = ShareTokenIntent.Backup;
183-
ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
184-
return oauthService.GetShareClient(containerName);
185-
}
186-
187-
protected override BlobContainerClient GetOAuthSourceContainerClient(string containerName)
189+
protected override async Task<IDisposingContainer<BlobContainerClient>> GetSourceDisposingContainerOauthAsync(
190+
string containerName = default,
191+
CancellationToken cancellationToken = default)
188192
{
189-
BlobClientOptions options = SourceClientBuilder.GetOptions();
190-
BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
191-
return oauthService.GetBlobContainerClient(containerName);
193+
BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential);
194+
return await SourceClientBuilder.GetTestContainerAsync(oauthService, containerName);
192195
}
193196

194197
// Blob to File always needs OAuth source container

sdk/storage/Azure.Storage.DataMovement.Blobs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Breaking Changes
88

99
### Bugs Fixed
10+
- Fixed an issue with Copy transfers where if the source file/directory name contained certain special characters, the destination file name would incorrectly contain the encoded version of these characters.
11+
- Fixed an issue with Upload transfers where file/directory names containing certain URL-encoded characters could cause the transfer to fail.
1012

1113
### Other Changes
1214

sdk/storage/Azure.Storage.DataMovement.Blobs/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.DataMovement.Blobs",
5-
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_5f8193db17"
5+
"Tag": "net/storage/Azure.Storage.DataMovement.Blobs_1ebb672122"
66
}

sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StartTransferBlobDirectoryCopyTestBase.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,25 +234,28 @@ await UploadPagesAsync(
234234
}
235235
}
236236

237+
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerOauthAsync(
238+
string containerName = default,
239+
CancellationToken cancellationToken = default)
240+
{
241+
BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential);
242+
return await DestinationClientBuilder.GetTestContainerAsync(oauthService, containerName);
243+
}
244+
237245
protected override async Task<IDisposingContainer<BlobContainerClient>> GetDestinationDisposingContainerAsync(
238246
BlobServiceClient service = null,
239247
string containerName = null,
240248
CancellationToken cancellationToken = default)
241249
=> await DestinationClientBuilder.GetTestContainerAsync(service, containerName);
242250

243-
private BlobContainerClient GetOAuthContainerClient(string containerName)
251+
protected override async Task<IDisposingContainer<BlobContainerClient>> GetSourceDisposingContainerOauthAsync(
252+
string containerName = default,
253+
CancellationToken cancellationToken = default)
244254
{
245-
BlobClientOptions options = SourceClientBuilder.GetOptions();
246-
BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
247-
return oauthService.GetBlobContainerClient(containerName);
255+
BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential);
256+
return await SourceClientBuilder.GetTestContainerAsync(oauthService, containerName);
248257
}
249258

250-
protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName)
251-
=> GetOAuthContainerClient(containerName);
252-
253-
protected override BlobContainerClient GetOAuthSourceContainerClient(string containerName)
254-
=> GetOAuthContainerClient(containerName);
255-
256259
protected override async Task<IDisposingContainer<BlobContainerClient>> GetSourceDisposingContainerAsync(BlobServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)
257260
{
258261
DisposingBlobContainer disposingContainer = await SourceClientBuilder.GetTestContainerAsync(service, containerName);

sdk/storage/Azure.Storage.DataMovement.Files.Shares/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Breaking Changes
88

99
### Bugs Fixed
10+
- Fixed an issue with Copy transfers where if the source file/directory name contained certain special characters, the destination file name would incorrectly contain the encoded version of these characters.
11+
- Fixed an issue with Upload transfers where file/directory names containing certain URL-encoded characters could cause the transfer to fail.
1012

1113
### Other Changes
1214

sdk/storage/Azure.Storage.DataMovement.Files.Shares/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.DataMovement.Files.Shares",
5-
"Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_f6f89a43f9"
5+
"Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_90fc7c3256"
66
}

sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareDirectoryStartTransferCopyTests.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,30 @@ protected override async Task<IDisposingContainer<ShareClient>> GetDestinationDi
8888
CancellationToken cancellationToken = default)
8989
=> await DestinationClientBuilder.GetTestShareAsync(service, containerName, cancellationToken: cancellationToken);
9090

91+
protected override async Task<IDisposingContainer<ShareClient>> GetDestinationDisposingContainerOauthAsync(
92+
string containerName = default,
93+
CancellationToken cancellationToken = default)
94+
{
95+
ShareClientOptions options = DestinationClientBuilder.GetOptions();
96+
options.ShareTokenIntent = ShareTokenIntent.Backup;
97+
ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
98+
return await DestinationClientBuilder.GetTestShareAsync(oauthService, containerName, cancellationToken: cancellationToken);
99+
}
100+
91101
protected override StorageResourceContainer GetDestinationStorageResourceContainer(
92102
ShareClient containerClient,
93103
string prefix,
94104
TransferPropertiesTestType propertiesTestType = default)
95105
=> new ShareDirectoryStorageResourceContainer(containerClient.GetDirectoryClient(prefix), GetShareFileStorageResourceOptions(propertiesTestType));
96106

97-
protected override ShareClient GetOAuthSourceContainerClient(string containerName)
107+
protected override async Task<IDisposingContainer<ShareClient>> GetSourceDisposingContainerOauthAsync(
108+
string containerName = default,
109+
CancellationToken cancellationToken = default)
98110
{
99111
ShareClientOptions options = SourceClientBuilder.GetOptions();
100112
options.ShareTokenIntent = ShareTokenIntent.Backup;
101113
ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
102-
return oauthService.GetShareClient(containerName);
103-
}
104-
105-
protected override ShareClient GetOAuthDestinationContainerClient(string containerName)
106-
{
107-
ShareClientOptions options = DestinationClientBuilder.GetOptions();
108-
options.ShareTokenIntent = ShareTokenIntent.Backup;
109-
ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options);
110-
return oauthService.GetShareClient(containerName);
114+
return await SourceClientBuilder.GetTestShareAsync(oauthService, containerName, cancellationToken: cancellationToken);
111115
}
112116

113117
protected override async Task<IDisposingContainer<ShareClient>> GetSourceDisposingContainerAsync(ShareServiceClient service = null, string containerName = null, CancellationToken cancellationToken = default)

sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Breaking Changes
88

99
### Bugs Fixed
10+
- Fixed an issue with Copy transfers where if the source file/directory name contained certain special characters, the destination file name would incorrectly contain the encoded version of these characters.
11+
- Fixed an issue with Upload transfers where file/directory names containing certain URL-encoded characters could cause the transfer to fail.
1012

1113
### Other Changes
1214

0 commit comments

Comments
 (0)