Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/tests/AppendBlobClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,50 @@ await TestHelper.AssertExpectedExceptionAsync<ArgumentNullException>(
}
}

[Test]
public async Task GetAppendBlobClient_AsciiName()
{
//Arrange
await using DisposingContainer test = await GetTestContainerAsync();
string blobName = GetNewBlobName();

//Act
AppendBlobClient blob = test.Container.GetAppendBlobClient(blobName);
await blob.CreateAsync();

//Assert
List<string> names = new List<string>();
await foreach (BlobItem pathItem in test.Container.GetBlobsAsync())
{
names.Add(pathItem.Name);
}
// Verify the file name exists in the filesystem
Assert.AreEqual(1, names.Count);
Assert.Contains(blobName, names);
}

[Test]
public async Task GetAppendBlobClient_NonAsciiName()
{
//Arrange
await using DisposingContainer test = await GetTestContainerAsync();
string blobName = GetNewNonAsciiBlobName();

//Act
AppendBlobClient blob = test.Container.GetAppendBlobClient(blobName);
await blob.CreateAsync();

//Assert
List<string> names = new List<string>();
await foreach (BlobItem pathItem in test.Container.GetBlobsAsync())
{
names.Add(pathItem.Name);
}
// Verify the file name exists in the filesystem
Assert.AreEqual(1, names.Count);
Assert.Contains(blobName, names);
}

private AppendBlobRequestConditions BuildDestinationAccessConditions(
AccessConditionParameters parameters,
bool lease = false,
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public BlobTestBase(bool async, BlobClientOptions.ServiceVersion serviceVersion,
public string GetNewContainerName() => $"test-container-{Recording.Random.NewGuid()}";
public string GetNewBlobName() => $"test-blob-{Recording.Random.NewGuid()}";
public string GetNewBlockName() => $"test-block-{Recording.Random.NewGuid()}";
public string GetNewNonAsciiBlobName() => $"test-⣩þ‽-{Recording.Random.NewGuid()}";
public string GetNewNonAsciiBlobName() => $"test-⣩þ‽%3A-{Recording.Random.NewGuid()}";

public BlobClientOptions GetOptions(bool parallelRange = false)
{
Expand Down
53 changes: 53 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/tests/BlockBlobClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,59 @@ await blob.UploadAsync(
Assert.AreEqual(blobSize, progress.List[progress.List.Count - 1]);
}


[Test]
public async Task GetBlockBlobClient_AsciiName()
{
//Arrange
await using DisposingContainer test = await GetTestContainerAsync();
string blobName = GetNewBlobName();

//Act
BlockBlobClient blob = test.Container.GetBlockBlobClient(blobName);
var data = GetRandomBuffer(Size);
using (var stream = new MemoryStream(data))
{
await blob.UploadAsync(content: stream);
}

//Assert
List<string> names = new List<string>();
await foreach (BlobItem pathItem in test.Container.GetBlobsAsync())
{
names.Add(pathItem.Name);
}
// Verify the file name exists in the filesystem
Assert.AreEqual(1, names.Count);
Assert.Contains(blobName, names);
}

[Test]
public async Task GetBlockBlobClient_NonAsciiName()
{
//Arrange
await using DisposingContainer test = await GetTestContainerAsync();
string blobName = GetNewNonAsciiBlobName();

//Act
BlockBlobClient blob = test.Container.GetBlockBlobClient(blobName);
var data = GetRandomBuffer(Size);
using (var stream = new MemoryStream(data))
{
await blob.UploadAsync(content: stream);
}

//Assert
List<string> names = new List<string>();
await foreach (BlobItem pathItem in test.Container.GetBlobsAsync())
{
names.Add(pathItem.Name);
}
// Verify the file name exists in the filesystem
Assert.AreEqual(1, names.Count);
Assert.Contains(blobName, names);
}

private RequestConditions BuildRequestConditions(AccessConditionParameters parameters)
=> new RequestConditions
{
Expand Down
44 changes: 44 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/tests/PageBlobClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,50 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
});
}

[Test]
public async Task GetPageBlobClient_AsciiName()
{
//Arrange
await using DisposingContainer test = await GetTestContainerAsync();
string blobName = GetNewBlobName();

//Act
PageBlobClient blob = test.Container.GetPageBlobClient(blobName);
await blob.CreateAsync(Constants.KB);

//Assert
List<string> names = new List<string>();
await foreach (BlobItem pathItem in test.Container.GetBlobsAsync())
{
names.Add(pathItem.Name);
}
// Verify the file name exists in the filesystem
Assert.AreEqual(1, names.Count);
Assert.Contains(blobName, names);
}

[Test]
public async Task GetPageBlobClient_NonAsciiName()
{
//Arrange
await using DisposingContainer test = await GetTestContainerAsync();
string blobName = GetNewNonAsciiBlobName();

//Act
PageBlobClient blob = test.Container.GetPageBlobClient(blobName);
await blob.CreateAsync(Constants.KB);

//Assert
List<string> names = new List<string>();
await foreach (BlobItem pathItem in test.Container.GetBlobsAsync())
{
names.Add(pathItem.Name);
}
// Verify the file name exists in the filesystem
Assert.AreEqual(1, names.Count);
Assert.Contains(blobName, names);
}

private PageBlobRequestConditions BuildAccessConditions(
AccessConditionParameters parameters,
bool lease = false,
Expand Down
Loading