Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
78abf66
Prepare Storage for release
kasobol-msft May 6, 2020
e7907a4
pr feedback.
kasobol-msft May 6, 2020
58814fc
PR feedback.
kasobol-msft May 6, 2020
1286434
pr feedback.
kasobol-msft May 6, 2020
324afd0
merge upstream/master
kasobol-msft May 15, 2020
b216c89
Merge remote-tracking branch 'upstream/master'
kasobol-msft May 19, 2020
1c9e87d
Merge remote-tracking branch 'upstream/master'
kasobol-msft Jun 2, 2020
712ecda
Merge remote-tracking branch 'upstream/master'
kasobol-msft Jun 4, 2020
ad612b5
merge upstream/master
kasobol-msft Jun 10, 2020
5849bef
master merge
kasobol-msft Jul 7, 2020
1bcba8b
Merge remote-tracking branch 'upstream/master'
kasobol-msft Jul 29, 2020
8a2e048
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 3, 2020
1bf033e
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 8, 2020
b35274e
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 10, 2020
feb0649
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 11, 2020
5974722
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 11, 2020
9252944
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 14, 2020
f90886e
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 20, 2020
3b9b259
Merge remote-tracking branch 'upstream/master'
kasobol-msft Aug 21, 2020
f97e9bd
Merge remote-tracking branch 'upstream/master'
kasobol-msft Sep 1, 2020
ae9d658
make open write work with using.
kasobol-msft Sep 1, 2020
4a24b96
move recordings to right place
kasobol-msft Sep 1, 2020
e970ed7
pr feedback.
kasobol-msft Sep 1, 2020
ed559ba
Merge remote-tracking branch 'upstream/master'
kasobol-msft Sep 1, 2020
f477f9a
Merge remote-tracking branch 'upstream/master'
kasobol-msft Sep 3, 2020
70bac18
Merge remote-tracking branch 'upstream/master'
kasobol-msft Sep 3, 2020
342d763
Merge remote-tracking branch 'upstream/master'
kasobol-msft Sep 8, 2020
4c8ee0b
Merge remote-tracking branch 'upstream/master'
kasobol-msft Sep 9, 2020
7856b23
make specialized clients retrieval mockable.
kasobol-msft Sep 11, 2020
fa28938
pr feedback.
kasobol-msft Sep 11, 2020
d628cec
export api.
kasobol-msft Sep 11, 2020
984ae2b
record mode...
kasobol-msft Sep 11, 2020
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
18 changes: 1 addition & 17 deletions sdk/storage/Azure.Storage.Blobs/src/AppendBlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,23 +1589,7 @@ public static AppendBlobClient GetAppendBlobClient(
this BlobContainerClient client,
string blobName)
{
if (client.ClientSideEncryption != default)
{
throw Errors.ClientSideEncryption.TypeNotSupported(typeof(AppendBlobClient));
}

BlobUriBuilder blobUriBuilder = new BlobUriBuilder(client.Uri)
{
BlobName = blobName
};

return new AppendBlobClient(
blobUriBuilder.ToUri(),
client.Pipeline,
client.Version,
client.ClientDiagnostics,
client.CustomerProvidedKey,
client.EncryptionScope);
return client.GetAppendBlobClientInternal(blobName);
}
}
}
92 changes: 92 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,98 @@ public virtual BlobClient GetBlobClient(string blobName)
EncryptionScope);
}

/// <summary>
/// Create a new <see cref="BlockBlobClient"/> object by
/// concatenating <paramref name="blobName"/> to
/// the end of the <see cref="Uri"/>. The new
/// <see cref="BlockBlobClient"/>
/// uses the same request policy pipeline as the
/// <see cref="BlobContainerClient"/>.
/// </summary>
/// <param name="blobName">The name of the block blob.</param>
/// <returns>A new <see cref="BlockBlobClient"/> instance.</returns>
protected internal virtual BlockBlobClient GetBlockBlobClientInternal(string blobName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a different suffix like Core instead of Internal. I think we have a similar WithSnapshotCore?

{
if (ClientSideEncryption != default)
{
throw Errors.ClientSideEncryption.TypeNotSupported(typeof(BlockBlobClient));
}

BlobUriBuilder blobUriBuilder = new BlobUriBuilder(Uri)
{
BlobName = blobName
};

return new BlockBlobClient(
blobUriBuilder.ToUri(),
Pipeline,
Version,
ClientDiagnostics,
CustomerProvidedKey,
EncryptionScope);
}

/// <summary>
/// Create a new <see cref="AppendBlobClient"/> object by
/// concatenating <paramref name="blobName"/> to
/// the end of the <see cref="BlobContainerClient.Uri"/>. The new
/// <see cref="AppendBlobClient"/>
/// uses the same request policy pipeline as the
/// <see cref="BlobContainerClient"/>.
/// </summary>
/// <param name="blobName">The name of the append blob.</param>
/// <returns>A new <see cref="AppendBlobClient"/> instance.</returns>
protected internal virtual AppendBlobClient GetAppendBlobClientInternal(string blobName)
{
if (ClientSideEncryption != default)
{
throw Errors.ClientSideEncryption.TypeNotSupported(typeof(AppendBlobClient));
}

BlobUriBuilder blobUriBuilder = new BlobUriBuilder(Uri)
{
BlobName = blobName
};

return new AppendBlobClient(
blobUriBuilder.ToUri(),
Pipeline,
Version,
ClientDiagnostics,
CustomerProvidedKey,
EncryptionScope);
}

/// <summary>
/// Create a new <see cref="PageBlobClient"/> object by
/// concatenating <paramref name="blobName"/> to
/// the end of the <see cref="BlobContainerClient.Uri"/>. The new
/// <see cref="PageBlobClient"/>
/// uses the same request policy pipeline as the
/// <see cref="BlobContainerClient"/>.
/// </summary>
/// <param name="blobName">The name of the page blob.</param>
/// <returns>A new <see cref="PageBlobClient"/> instance.</returns>
protected internal virtual PageBlobClient GetPageBlobClientInternal(string blobName)
{
if (ClientSideEncryption != default)
{
throw Errors.ClientSideEncryption.TypeNotSupported(typeof(PageBlobClient));
}

BlobUriBuilder blobUriBuilder = new BlobUriBuilder(Uri)
{
BlobName = blobName
};

return new PageBlobClient(
blobUriBuilder.ToUri(),
Pipeline,
Version,
ClientDiagnostics,
CustomerProvidedKey,
EncryptionScope);
}

/// <summary>
/// Sets the various name fields if they are currently null.
Expand Down
18 changes: 1 addition & 17 deletions sdk/storage/Azure.Storage.Blobs/src/BlockBlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2232,23 +2232,7 @@ public static BlockBlobClient GetBlockBlobClient(
this BlobContainerClient client,
string blobName)
{
if (client.ClientSideEncryption != default)
{
throw Errors.ClientSideEncryption.TypeNotSupported(typeof(BlockBlobClient));
}

BlobUriBuilder blobUriBuilder = new BlobUriBuilder(client.Uri)
{
BlobName = blobName
};

return new BlockBlobClient(
blobUriBuilder.ToUri(),
client.Pipeline,
client.Version,
client.ClientDiagnostics,
client.CustomerProvidedKey,
client.EncryptionScope);
return client.GetBlockBlobClientInternal(blobName);
}
}
}
18 changes: 1 addition & 17 deletions sdk/storage/Azure.Storage.Blobs/src/PageBlobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3114,23 +3114,7 @@ public static PageBlobClient GetPageBlobClient(
this BlobContainerClient client,
string blobName)
{
if (client.ClientSideEncryption != default)
{
throw Errors.ClientSideEncryption.TypeNotSupported(typeof(PageBlobClient));
}

BlobUriBuilder blobUriBuilder = new BlobUriBuilder(client.Uri)
{
BlobName = blobName
};

return new PageBlobClient(
blobUriBuilder.ToUri(),
client.Pipeline,
client.Version,
client.ClientDiagnostics,
client.CustomerProvidedKey,
client.EncryptionScope);
return client.GetPageBlobClientInternal(blobName);
}
}
}
30 changes: 29 additions & 1 deletion sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -17,6 +16,8 @@
using Azure.Storage.Sas;
using Azure.Storage.Test;
using Azure.Storage.Test.Shared;
using Moq;
using Moq.Protected;
using NUnit.Framework;

namespace Azure.Storage.Blobs.Test
Expand Down Expand Up @@ -2512,6 +2513,33 @@ public async Task GetBlobClients_SpecialCharacters(string blobName)
Assert.AreEqual(blobName, pageBlobClientFromConnectionString.Name);
}

[Test]
public void CanMockBlobClientsRetrieval()
{
// Arrange
string blobName = "test";
Mock<BlobContainerClient> containerClientMock = new Mock<BlobContainerClient>();
Mock<BlockBlobClient> blockBlobClientMock = new Mock<BlockBlobClient>();
Mock<AppendBlobClient> appendBlobClientMock = new Mock<AppendBlobClient>();
Mock<PageBlobClient> pageBlobClientMock = new Mock<PageBlobClient>();
containerClientMock.Protected().Setup<BlockBlobClient>("GetBlockBlobClientInternal", blobName).Returns(blockBlobClientMock.Object);
containerClientMock.Protected().Setup<AppendBlobClient>("GetAppendBlobClientInternal", blobName).Returns(appendBlobClientMock.Object);
containerClientMock.Protected().Setup<PageBlobClient>("GetPageBlobClientInternal", blobName).Returns(pageBlobClientMock.Object);

// Act
var blockBlobClient = containerClientMock.Object.GetBlockBlobClient(blobName);
var appendBlobClient = containerClientMock.Object.GetAppendBlobClient(blobName);
var pageBlobClient = containerClientMock.Object.GetPageBlobClient(blobName);

// Assert
Assert.IsNotNull(blockBlobClient);
Assert.AreSame(blockBlobClientMock.Object, blockBlobClient);
Assert.IsNotNull(appendBlobClient);
Assert.AreSame(appendBlobClientMock.Object, appendBlobClient);
Assert.IsNotNull(pageBlobClient);
Assert.AreSame(pageBlobClientMock.Object, pageBlobClient);
}

#region Secondary Storage
[Test]
public async Task ListContainersSegmentAsync_SecondaryStorageFirstRetrySuccessful()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.