diff --git a/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md b/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md index 0d91ca7a11306..8de478fa6b42c 100644 --- a/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## 12.9.0-beta.1 (Unreleased) - +- Fixed bug where BlobBaseClient.CanGenerateSasUri, BlobContainerClient.CanGenerateSasUri, BlobServiceClient.CanGenerateSasUri was not mockable ## 12.8.0 (2021-01-12) - Includes all features from 12.8.0-beta.1 diff --git a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs index 9d44bd7aa6532..3431e75267d21 100644 --- a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs @@ -67,7 +67,7 @@ public BlobContainerClient(System.Uri blobContainerUri, Azure.Core.TokenCredenti public BlobContainerClient(System.Uri blobContainerUri, Azure.Storage.Blobs.BlobClientOptions options = null) { } public BlobContainerClient(System.Uri blobContainerUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Blobs.BlobClientOptions options = null) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual string Name { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response Create(Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, Azure.Storage.Blobs.Models.BlobContainerEncryptionScopeOptions encryptionScopeOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -127,7 +127,7 @@ public BlobServiceClient(System.Uri serviceUri, Azure.Core.TokenCredential crede public BlobServiceClient(System.Uri serviceUri, Azure.Storage.Blobs.BlobClientOptions options = null) { } public BlobServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Blobs.BlobClientOptions options = null) { } public string AccountName { get { throw null; } } - public bool CanGenerateAccountSasUri { get { throw null; } } + public virtual bool CanGenerateAccountSasUri { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response CreateBlobContainer(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateBlobContainerAsync(string blobContainerName, Azure.Storage.Blobs.Models.PublicAccessType publicAccessType = Azure.Storage.Blobs.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -1268,7 +1268,7 @@ public BlobBaseClient(System.Uri blobUri, Azure.Storage.Blobs.BlobClientOptions public BlobBaseClient(System.Uri blobUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Blobs.BlobClientOptions options = null) { } public virtual string AccountName { get { throw null; } } public virtual string BlobContainerName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual string Name { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response AbortCopyFromUri(string copyId, Azure.Storage.Blobs.Models.BlobRequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs index fe9654dafe77a..e3ca16bc424c6 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs @@ -177,7 +177,7 @@ public virtual string Name /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs index b06ae2d86dd9c..41132588e8d80 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs @@ -173,7 +173,7 @@ public virtual string Name /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => SharedKeyCredential != null; #region ctor /// diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs index ea6076b70624e..e6808fb6da0d7 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs @@ -144,7 +144,7 @@ public string AccountName /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateAccountSasUri => SharedKeyCredential != null; + public virtual bool CanGenerateAccountSasUri => SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobProperties.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobProperties.cs index a2af6f7c09cc4..ed237f077cd7a 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobProperties.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobProperties.cs @@ -9,7 +9,7 @@ namespace Azure.Storage.Blobs.Models { /// - /// Propeties of a Blob + /// Properties of a Blob /// public partial class BlobProperties { diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs index 955df322ba208..16493915271be 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs @@ -6051,6 +6051,23 @@ public void CanGenerateSas_WithVersion_False() Assert.IsFalse(versionBlob.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var blob = new Mock(); + blob.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(blob.Object.CanGenerateSasUri); + + // Act + blob.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(blob.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs index df064065d1dbe..95e45fc1d0644 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs @@ -2670,6 +2670,23 @@ public void CanGenerateSas_ClientConstructors() Assert.IsFalse(container5.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var container = new Mock(); + container.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(container.Object.CanGenerateSasUri); + + // Act + container.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(container.Object.CanGenerateSasUri); + } + [Test] public void CanGenerateSas_GetBlobClient() { diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs index 25219388b4807..171c9d7e37acf 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs @@ -972,6 +972,23 @@ public void CanGenerateSas_GetContainerClient() Assert.IsFalse(containerClient5.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Act + var serviceClient = new Mock(); + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(false); + + // Assert + Assert.IsFalse(serviceClient.Object.CanGenerateAccountSasUri); + + // Act + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(true); + + // Assert + Assert.IsTrue(serviceClient.Object.CanGenerateAccountSasUri); + } + [Test] public void GenerateAccountSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/CHANGELOG.md b/sdk/storage/Azure.Storage.Files.DataLake/CHANGELOG.md index 081193c2c2112..cfe24e750c33a 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.Files.DataLake/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## 12.7.0-beta.1 (Unreleased) - +- Fixed bug where DataLakeFileSystemClient.CanGenerateSasUri, DataLakeDirectoryClient.CanGenerateSasUri, DataLakeFileClient.CanGenerateSasUri, DataLakePathClient.CanGenerateSasUri, DataLakeServiceClient.CanGenerateSasUri was not mockable ## 12.6.0 (2021-01-12) - Includes all features from 12.6.0-beta.1 diff --git a/sdk/storage/Azure.Storage.Files.DataLake/api/Azure.Storage.Files.DataLake.netstandard2.0.cs b/sdk/storage/Azure.Storage.Files.DataLake/api/Azure.Storage.Files.DataLake.netstandard2.0.cs index 06948bcad1a80..fef830ec9190d 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/api/Azure.Storage.Files.DataLake.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/api/Azure.Storage.Files.DataLake.netstandard2.0.cs @@ -168,7 +168,7 @@ public DataLakeFileSystemClient(System.Uri fileSystemUri, Azure.Storage.Files.Da public DataLakeFileSystemClient(System.Uri fileSystemUri, Azure.Storage.StorageSharedKeyCredential credential) { } public DataLakeFileSystemClient(System.Uri fileSystemUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Files.DataLake.DataLakeClientOptions options) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual string Name { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response Create(Azure.Storage.Files.DataLake.Models.PublicAccessType publicAccessType = Azure.Storage.Files.DataLake.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -243,7 +243,7 @@ public DataLakePathClient(System.Uri pathUri, Azure.Storage.Files.DataLake.DataL public DataLakePathClient(System.Uri pathUri, Azure.Storage.StorageSharedKeyCredential credential) { } public DataLakePathClient(System.Uri pathUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Files.DataLake.DataLakeClientOptions options) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual string FileSystemName { get { throw null; } } public virtual string Name { get { throw null; } } public virtual string Path { get { throw null; } } @@ -295,7 +295,7 @@ public DataLakeServiceClient(System.Uri serviceUri, Azure.Storage.Files.DataLake public DataLakeServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCredential credential) { } public DataLakeServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Files.DataLake.DataLakeClientOptions options) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateAccountSasUri { get { throw null; } } + public virtual bool CanGenerateAccountSasUri { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response CreateFileSystem(string fileSystemName, Azure.Storage.Files.DataLake.Models.PublicAccessType publicAccessType = Azure.Storage.Files.DataLake.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateFileSystemAsync(string fileSystemName, Azure.Storage.Files.DataLake.Models.PublicAccessType publicAccessType = Azure.Storage.Files.DataLake.Models.PublicAccessType.None, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs index c504f7e7bd209..f21ca7de74b52 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs @@ -26,7 +26,7 @@ namespace Azure.Storage.Files.DataLake public class DataLakeFileClient : DataLakePathClient { /// - /// Gets the maximum number of bytes that can be sent in a call + /// Gets the maximum number of bytes that can be sent in each append call in /// to . /// Supported value is now larger than ; please use /// . @@ -37,8 +37,8 @@ public class DataLakeFileClient : DataLakePathClient : int.MaxValue; // value is larger than can be represented by an int /// - /// Gets the maximum number of bytes that can be sent in a call - /// to . + /// Gets the maximum number of bytes that can be sent in each append call in + /// . /// public virtual long MaxUploadLongBytes => Version < DataLakeClientOptions.ServiceVersion.V2019_12_12 ? Constants.DataLake.Pre_2019_12_12_MaxAppendBytes diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs index 9d9a63f24a836..e2a443cc92f3a 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileSystemClient.cs @@ -137,7 +137,7 @@ public virtual string Name /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs index 53c0441913fd2..48e6dbe50765b 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs @@ -190,7 +190,7 @@ public virtual string Name /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs index cd2ea889a4052..1a84bb3db4dd7 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs @@ -111,7 +111,7 @@ public virtual string AccountName /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateAccountSasUri => SharedKeyCredential != null; + public virtual bool CanGenerateAccountSasUri => SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs index 85db68d33ab43..5286ec6adf2ad 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs @@ -5087,6 +5087,23 @@ public void CanGenerateSas_GetSubDirectoryClient() Assert.IsFalse(subdirectory3.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(directory.Object.CanGenerateSasUri); + + // Act + directory.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(directory.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs index 6611ff455ed57..9df2bb1fc8a72 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs @@ -4800,6 +4800,23 @@ public void CanGenerateSas_ClientConstructors() Assert.IsFalse(file3.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var file = new Mock(); + file.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(file.Object.CanGenerateSasUri); + + // Act + file.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(file.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs index c8fd218e7f3d6..f76752e1705eb 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs @@ -2284,6 +2284,23 @@ public void CanGenerateSas_GetDirectoryClient() Assert.IsFalse(directory3.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var filesystem = new Mock(); + filesystem.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(filesystem.Object.CanGenerateSasUri); + + // Act + filesystem.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(filesystem.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs index c83d2149ef319..9a8cb7ce0b284 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs @@ -193,6 +193,23 @@ public void CanGenerateSas_ClientConstructors() Assert.IsFalse(blob5.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var pathClient = new Mock(); + pathClient.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(pathClient.Object.CanGenerateSasUri); + + // Act + pathClient.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(pathClient.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs index aa354de3df668..679e6735bc040 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs @@ -595,6 +595,23 @@ public void CanGenerateSas_GetFileSystemClient() Assert.IsFalse(fileSystemClient3.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Act + var serviceClient = new Mock(); + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(false); + + // Assert + Assert.IsFalse(serviceClient.Object.CanGenerateAccountSasUri); + + // Act + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(true); + + // Assert + Assert.IsTrue(serviceClient.Object.CanGenerateAccountSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/CHANGELOG.md b/sdk/storage/Azure.Storage.Files.Shares/CHANGELOG.md index 263d3a1955067..f4877c9b11c55 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.Files.Shares/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## 12.7.0-beta.1 (Unreleased) - +- Fixed bug where ShareFileClient.CanGenerateSasUri, ShareDirectoryClient.CanGenerateSasUri, ShareClient.CanGenerateSasUri, ShareServiceClient.CanGenerateSasUri was not mockable ## 12.6.0 (2021-01-12) - Includes all features from 12.5.6-beta.1 diff --git a/sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.netstandard2.0.cs b/sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.netstandard2.0.cs index ba9d61970653d..80875f9314630 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/api/Azure.Storage.Files.Shares.netstandard2.0.cs @@ -9,7 +9,7 @@ public ShareClient(System.Uri shareUri, Azure.AzureSasCredential credential, Azu public ShareClient(System.Uri shareUri, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public ShareClient(System.Uri shareUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual string Name { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response Create(Azure.Storage.Files.Shares.Models.ShareCreateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -116,7 +116,7 @@ public ShareDirectoryClient(System.Uri directoryUri, Azure.AzureSasCredential cr public ShareDirectoryClient(System.Uri directoryUri, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public ShareDirectoryClient(System.Uri directoryUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual string Name { get { throw null; } } public virtual string Path { get { throw null; } } public virtual string ShareName { get { throw null; } } @@ -176,7 +176,7 @@ public ShareFileClient(System.Uri fileUri, Azure.AzureSasCredential credential, public ShareFileClient(System.Uri fileUri, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public ShareFileClient(System.Uri fileUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual string Name { get { throw null; } } public virtual string Path { get { throw null; } } public virtual string ShareName { get { throw null; } } @@ -296,7 +296,7 @@ public ShareServiceClient(System.Uri serviceUri, Azure.AzureSasCredential creden public ShareServiceClient(System.Uri serviceUri, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public ShareServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Files.Shares.ShareClientOptions options = null) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateAccountSasUri { get { throw null; } } + public virtual bool CanGenerateAccountSasUri { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response CreateShare(string shareName, Azure.Storage.Files.Shares.Models.ShareCreateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs index 2aee0f03259d4..ee9653b2b76d5 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs @@ -92,7 +92,7 @@ public virtual string Name /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs index 17e93e0a8c737..13cdf0b982068 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareDirectoryClient.cs @@ -122,7 +122,7 @@ public virtual string Path /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs index 8d4b74c4beba7..661d4037a5a8a 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareFileClient.cs @@ -128,7 +128,7 @@ public virtual string Path /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; //const string fileType = "file"; diff --git a/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs index ee08bebad4809..b1053a297a85d 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/src/ShareServiceClient.cs @@ -75,7 +75,7 @@ public virtual string AccountName /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateAccountSasUri => ClientConfiguration.SharedKeyCredential != null; + public virtual bool CanGenerateAccountSasUri => ClientConfiguration.SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs index 5c6e4f37e0e85..65d5102e0dd64 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs @@ -1276,6 +1276,23 @@ public void CanGenerateSas_GetSubdirectoryClient() Assert.IsTrue(subdirectory4.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(directory.Object.CanGenerateSasUri); + + // Act + directory.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(directory.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs index b3255377ef9ff..cef5da9f19b9d 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs @@ -4045,6 +4045,23 @@ public void CanGenerateSas_ClientConstructors() Assert.IsTrue(directory4.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(directory.Object.CanGenerateSasUri); + + // Act + directory.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(directory.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs index ec8d2aa69a514..28e2ebc47572a 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs @@ -506,6 +506,23 @@ public void CanGenerateSas_GetShareClient() Assert.IsTrue(share4.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Act + var directory = new Mock(); + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(false); + + // Assert + Assert.IsFalse(directory.Object.CanGenerateAccountSasUri); + + // Act + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(true); + + // Assert + Assert.IsTrue(directory.Object.CanGenerateAccountSasUri); + } + [Test] public void GenerateAccountSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs index 456dcd98a50a7..76ba0f170381d 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs @@ -2254,6 +2254,23 @@ public void CanGenerateSas_WithSnapshot_True() Assert.IsTrue(snapshotShare.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(directory.Object.CanGenerateSasUri); + + // Act + directory.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(directory.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Queues/CHANGELOG.md b/sdk/storage/Azure.Storage.Queues/CHANGELOG.md index 9171820aa08ef..3dca75b60bfdf 100644 --- a/sdk/storage/Azure.Storage.Queues/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.Queues/CHANGELOG.md @@ -1,7 +1,7 @@ # Release History ## 12.7.0-beta.1 (Unreleased) - +- Fixed bug where QueueClient.CanGenerateSasUri and QueueServiceClient.CanGenerateSasUri was not mockable ## 12.6.0 (2021-01-12) - Includes all features from 12.6.0-beta.1. diff --git a/sdk/storage/Azure.Storage.Queues/api/Azure.Storage.Queues.netstandard2.0.cs b/sdk/storage/Azure.Storage.Queues/api/Azure.Storage.Queues.netstandard2.0.cs index d9bfe19c478df..ba1dad35e5232 100644 --- a/sdk/storage/Azure.Storage.Queues/api/Azure.Storage.Queues.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.Queues/api/Azure.Storage.Queues.netstandard2.0.cs @@ -10,7 +10,7 @@ public QueueClient(System.Uri queueUri, Azure.Core.TokenCredential credential, A public QueueClient(System.Uri queueUri, Azure.Storage.Queues.QueueClientOptions options = null) { } public QueueClient(System.Uri queueUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Queues.QueueClientOptions options = null) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateSasUri { get { throw null; } } + public virtual bool CanGenerateSasUri { get { throw null; } } public virtual int MaxPeekableMessages { get { throw null; } } public virtual int MessageMaxBytes { get { throw null; } } protected virtual System.Uri MessagesUri { get { throw null; } } @@ -97,7 +97,7 @@ public QueueServiceClient(System.Uri serviceUri, Azure.Core.TokenCredential cred public QueueServiceClient(System.Uri serviceUri, Azure.Storage.Queues.QueueClientOptions options = null) { } public QueueServiceClient(System.Uri serviceUri, Azure.Storage.StorageSharedKeyCredential credential, Azure.Storage.Queues.QueueClientOptions options = null) { } public virtual string AccountName { get { throw null; } } - public bool CanGenerateAccountSasUri { get { throw null; } } + public virtual bool CanGenerateAccountSasUri { get { throw null; } } public virtual System.Uri Uri { get { throw null; } } public virtual Azure.Response CreateQueue(string queueName, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateQueueAsync(string queueName, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs index 67adbae6b976c..84bd28ca1bfb5 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs @@ -136,7 +136,7 @@ public virtual string Name /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; + public virtual bool CanGenerateSasUri => ClientConfiguration.SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs b/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs index 81bbc3dba3d22..7f7e93b9b77e5 100644 --- a/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs +++ b/sdk/storage/Azure.Storage.Queues/src/QueueServiceClient.cs @@ -74,7 +74,7 @@ public virtual string AccountName /// Determines whether the client is able to generate a SAS. /// If the client is authenticated with a . /// - public bool CanGenerateAccountSasUri => ClientConfiguration.SharedKeyCredential != null; + public virtual bool CanGenerateAccountSasUri => ClientConfiguration.SharedKeyCredential != null; #region ctors /// diff --git a/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs b/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs index 1eabd906497cb..776c1332ec362 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs @@ -1406,6 +1406,23 @@ public void CanGenerateSas_ClientConstructors() Assert.IsTrue(container4.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Act + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + + // Assert + Assert.IsFalse(directory.Object.CanGenerateSasUri); + + // Act + directory.Setup(x => x.CanGenerateSasUri).Returns(true); + + // Assert + Assert.IsTrue(directory.Object.CanGenerateSasUri); + } + [Test] public void GenerateSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs index 2d07607da6b8c..5ffab26c364b7 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs @@ -435,6 +435,23 @@ public void CanGenerateSas_GetQueueClient() Assert.IsTrue(queueClient4.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Act + var directory = new Mock(); + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(false); + + // Assert + Assert.IsFalse(directory.Object.CanGenerateAccountSasUri); + + // Act + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(true); + + // Assert + Assert.IsTrue(directory.Object.CanGenerateAccountSasUri); + } + [Test] public void GenerateAccountSas_RequiredParameters() { diff --git a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_Mockable.json b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_MockableAsync.json b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file diff --git a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json new file mode 100644 index 0000000000000..20e5015d169f8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} \ No newline at end of file