From 1b1e2d0caa5db6a0133addbb2ebd4036ddfcf894 Mon Sep 17 00:00:00 2001 From: Amanda Nguyen Date: Fri, 29 Jan 2021 00:06:05 -0800 Subject: [PATCH 1/2] Made Storage Client CanGenerateSasUri properties mockable; Fixed some doc typo and details --- sdk/storage/Azure.Storage.Blobs/CHANGELOG.md | 2 +- .../Azure.Storage.Blobs/src/BlobBaseClient.cs | 2 +- .../src/BlobContainerClient.cs | 2 +- .../src/BlobServiceClient.cs | 2 +- .../src/Models/BlobProperties.cs | 2 +- .../tests/BlobBaseClientTests.cs | 32 +++++++++++++++++++ .../tests/ContainerClientTests.cs | 31 ++++++++++++++++++ .../tests/ServiceClientTests.cs | 31 ++++++++++++++++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateAccountSas_Mockable.json | 7 ++++ .../CanGenerateAccountSas_MockableAsync.json | 7 ++++ .../Azure.Storage.Files.DataLake/CHANGELOG.md | 2 +- .../src/DataLakeFileClient.cs | 6 ++-- .../src/DataLakeFileSystemClient.cs | 2 +- .../src/DataLakePathClient.cs | 2 +- .../src/DataLakeServiceClient.cs | 2 +- .../tests/DirectoryClientTests.cs | 30 +++++++++++++++++ .../tests/FileClientTests.cs | 30 +++++++++++++++++ .../tests/FileSystemClientTests.cs | 28 ++++++++++++++++ .../tests/PathClientTests.cs | 30 +++++++++++++++++ .../tests/ServiceClientTests.cs | 31 ++++++++++++++++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateAccountSas_Mockable.json | 7 ++++ .../CanGenerateAccountSas_MockableAsync.json | 7 ++++ .../Azure.Storage.Files.Shares/CHANGELOG.md | 2 +- .../src/ShareClient.cs | 2 +- .../src/ShareDirectoryClient.cs | 2 +- .../src/ShareFileClient.cs | 2 +- .../src/ShareServiceClient.cs | 2 +- .../tests/DirectoryClientTests.cs | 30 +++++++++++++++++ .../tests/FileClientTests.cs | 30 +++++++++++++++++ .../tests/ServiceClientTests.cs | 31 ++++++++++++++++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateAccountSas_Mockable.json | 7 ++++ .../CanGenerateAccountSas_MockableAsync.json | 7 ++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../tests/ShareClientTests.cs | 29 +++++++++++++++++ sdk/storage/Azure.Storage.Queues/CHANGELOG.md | 2 +- .../Azure.Storage.Queues/src/QueueClient.cs | 2 +- .../src/QueueServiceClient.cs | 2 +- .../tests/QueueClientTests.cs | 29 +++++++++++++++++ .../tests/ServiceClientTests.cs | 31 ++++++++++++++++++ .../CanGenerateSas_Mockable.json | 7 ++++ .../CanGenerateSas_MockableAsync.json | 7 ++++ .../CanGenerateAccountSas_Mockable.json | 7 ++++ .../CanGenerateAccountSas_MockableAsync.json | 7 ++++ 60 files changed, 639 insertions(+), 20 deletions(-) create mode 100644 sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_MockableAsync.json create mode 100644 sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json create mode 100644 sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json diff --git a/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md b/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md index 0d91ca7a1130..8de478fa6b42 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/src/BlobBaseClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs index fe9654dafe77..e3ca16bc424c 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 bce659de7a9b..cc8bc5395d2e 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs @@ -164,7 +164,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 7576d91ad0ef..33dfc7c6e5bc 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs @@ -141,7 +141,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 a2af6f7c09cc..ed237f077cd7 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 b05a0e79de64..c0b62157380a 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs @@ -6051,6 +6051,38 @@ public void CanGenerateSas_WithVersion_False() Assert.IsFalse(versionBlob.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); + + // Act + var blob = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(blob.Object.CanGenerateSasUri); + + // Arrange + var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); + var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); + string connectionString = storageConnectionString.ToString(true); + + // Act + var blob2 = new Mock(connectionString, + GetNewContainerName(), + GetNewBlobName()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(blob2.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 7333c3109b65..8dab7d38cc3f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs @@ -2670,6 +2670,37 @@ public void CanGenerateSas_ClientConstructors() Assert.IsFalse(container5.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); + + // Act + var container = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(container.Object.CanGenerateSasUri); + + // Arrange + var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); + var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); + string connectionString = storageConnectionString.ToString(true); + + // Act + var container2 = new Mock(connectionString, + GetNewContainerName()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(container2.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 9fb2e4fa7eae..b8b097ec769f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs @@ -12,6 +12,7 @@ using Azure.Storage.Sas; using Azure.Storage.Test; using Azure.Storage.Test.Shared; +using Moq; using NUnit.Framework; namespace Azure.Storage.Blobs.Test @@ -843,6 +844,36 @@ public void CanGenerateSas_GetContainerClient() Assert.IsFalse(containerClient5.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); + + // Act + var service = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(service.Object.CanGenerateAccountSasUri); + + // Arrange + var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); + var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); + string connectionString = storageConnectionString.ToString(true); + + // Act + var service2 = new Mock(connectionString) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(service2.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 000000000000..45b1451dbd13 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T13:31:30.2020707-08:00", + "RandomSeed": "1261611442" + } +} \ 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 000000000000..d95190f0a04a --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T13:26:45.4061650-08:00", + "RandomSeed": "897269400" + } +} \ 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 000000000000..4ffcaca2801d --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T13:39:09.4428756-08:00", + "RandomSeed": "319652072" + } +} \ 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 000000000000..41ea8f0b2c00 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T13:39:09.6232680-08:00", + "RandomSeed": "564511178" + } +} \ 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 000000000000..7e987c1910a8 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T13:41:34.0423483-08:00", + "RandomSeed": "575371005" + } +} \ 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 000000000000..1d039963ee46 --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T13:41:34.2416945-08:00", + "RandomSeed": "390310824" + } +} \ 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 081193c2c211..cfe24e750c33 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/src/DataLakeFileClient.cs b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs index c504f7e7bd20..f21ca7de74b5 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 b15d4a8063cc..5048deae2192 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 6dbd3b0c051e..2e6a66a302be 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 e7b58c8d6520..62bd9bbfcbc4 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeServiceClient.cs @@ -110,7 +110,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 91bb6386383f..4acd86af98e2 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs @@ -13,6 +13,7 @@ using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; using TestConstants = Azure.Storage.Test.TestConstants; @@ -5086,6 +5087,35 @@ public void CanGenerateSas_GetSubDirectoryClient() Assert.IsFalse(subdirectory3.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + string fileSystemName = GetNewFileSystemName(); + string path = GetNewDirectoryName(); + var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + fileSystemName + "/" + path); + + // Act + var directory = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(directory.Object.CanGenerateSasUri); + + // Act + var directory2 = new Mock(blobEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(directory2.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 52bd573e9ee1..5f3522147a2f 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs @@ -15,6 +15,7 @@ using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; namespace Azure.Storage.Files.DataLake.Tests @@ -4799,6 +4800,35 @@ public void CanGenerateSas_ClientConstructors() Assert.IsFalse(file3.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + string fileSystemName = GetNewFileSystemName(); + string path = GetNewFileName(); + var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + fileSystemName + "/" + path); + + // Act + var file = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(file.Object.CanGenerateSasUri); + + // Act + var file2 = new Mock(blobEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(file2.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 d3e349cc92f5..30fac94e7c7e 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs @@ -12,6 +12,7 @@ using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; namespace Azure.Storage.Files.DataLake.Tests @@ -2157,6 +2158,33 @@ public void CanGenerateSas_GetDirectoryClient() Assert.IsFalse(directory3.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account); + + // Act + var filesystem = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(filesystem.Object.CanGenerateSasUri); + + // Act + var filesystem2 = new Mock(blobEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(filesystem2.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 0a3237025850..689a8fed6b3e 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs @@ -8,6 +8,7 @@ using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; namespace Azure.Storage.Files.DataLake.Tests @@ -192,6 +193,35 @@ public void CanGenerateSas_ClientConstructors() Assert.IsFalse(blob5.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + string fileSystemName = GetNewFileSystemName(); + string path = GetNewFileName(); + var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + fileSystemName + "/" + path); + + // Act + var pathClient = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(pathClient.Object.CanGenerateSasUri); + + // Act + var pathClient2 = new Mock(blobEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(pathClient2.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 9feed2a0f92e..8584da42c66a 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs @@ -12,6 +12,7 @@ using Azure.Storage.Files.DataLake.Models; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; namespace Azure.Storage.Files.DataLake.Tests @@ -401,6 +402,36 @@ public void CanGenerateSas_GetFileSystemClient() Assert.IsFalse(fileSystemClient3.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); + + // Act + var serviceClient = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(serviceClient.Object.CanGenerateAccountSasUri); + + // Arrange + var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); + var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); + string connectionString = storageConnectionString.ToString(true); + + // Act + var serviceClient2 = new Mock(connectionString) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(serviceClient2.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 000000000000..0562ef9a111b --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T14:55:16.1475833-08:00", + "RandomSeed": "945849689" + } +} \ 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 000000000000..e5cad1a66990 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T14:55:16.3289390-08:00", + "RandomSeed": "1218038813" + } +} \ 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 000000000000..450818c4253d --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:00:15.1021883-08:00", + "RandomSeed": "746727861" + } +} \ 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 000000000000..dcea8473295b --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:00:15.3237165-08:00", + "RandomSeed": "1704344659" + } +} \ 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 000000000000..43a7c95ddc4c --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:04:38.6023146-08:00", + "RandomSeed": "1911415986" + } +} \ 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 000000000000..0ef37d66c3b6 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/FileSystemClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:04:38.7811205-08:00", + "RandomSeed": "357297309" + } +} \ 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 000000000000..fdba64b9c151 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:08:14.9613727-08:00", + "RandomSeed": "739257340" + } +} \ 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 000000000000..742c5431f0ac --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/PathClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:08:15.2188284-08:00", + "RandomSeed": "947307214" + } +} \ 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 000000000000..4149f42e7ed7 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:09:41.2781705-08:00", + "RandomSeed": "622190333" + } +} \ 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 000000000000..ba0825f05c65 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:09:41.4262694-08:00", + "RandomSeed": "784371140" + } +} \ 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 263d3a195506..f4877c9b11c5 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/src/ShareClient.cs b/sdk/storage/Azure.Storage.Files.Shares/src/ShareClient.cs index 56fc8184e162..e8b13547ccd1 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 e1972108d7f5..48c51287c3c9 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 332a7195ffb9..a16c7620527c 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 113cdae924b4..accaa317dd47 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 67a2bc1543b4..e4e5b687cdfa 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs @@ -11,6 +11,7 @@ using Azure.Storage.Files.Shares.Models; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; namespace Azure.Storage.Files.Shares.Tests @@ -1275,6 +1276,35 @@ public void CanGenerateSas_GetSubdirectoryClient() Assert.IsTrue(subdirectory4.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + string shareName = GetNewShareName(); + string path = GetNewDirectoryName(); + var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + shareName + "/" + path); + + // Act + var directory = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(directory.Object.CanGenerateSasUri); + + // Act + var directory2 = new Mock(blobEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(directory2.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 84cc56c29df5..6c8eb09eb826 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs @@ -16,6 +16,7 @@ using Azure.Storage.Test; using Azure.Storage.Test.Shared; using BenchmarkDotNet.Toolchains.Roslyn; +using Moq; using NUnit.Framework; namespace Azure.Storage.Files.Shares.Tests @@ -4044,6 +4045,35 @@ public void CanGenerateSas_ClientConstructors() Assert.IsTrue(directory4.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + string shareName = GetNewShareName(); + string path = GetNewFileName(); + var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + shareName + "/" + path); + + // Act + var file = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(file.Object.CanGenerateSasUri); + + // Act + var file2 = new Mock(blobEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(file2.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 9b047faa19bf..e0df3e156254 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs @@ -9,6 +9,7 @@ using Azure.Storage.Files.Shares.Models; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; namespace Azure.Storage.Files.Shares.Tests @@ -505,6 +506,36 @@ public void CanGenerateSas_GetShareClient() Assert.IsTrue(share4.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); + + // Act + var service = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(service.Object.CanGenerateAccountSasUri); + + // Arrange + var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); + var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); + string connectionString = storageConnectionString.ToString(true); + + // Act + var service2 = new Mock(connectionString) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(service2.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 000000000000..c9893c53424c --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:12:27.9526123-08:00", + "RandomSeed": "1363570676" + } +} \ 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 000000000000..8379e2775bd5 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/DirectoryClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:12:28.1241218-08:00", + "RandomSeed": "1466599197" + } +} \ 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 000000000000..6d58926b9bb6 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:14:33.1547996-08:00", + "RandomSeed": "1182122472" + } +} \ 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 000000000000..cc5d8c7310bb --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/FileClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T15:14:33.2207069-08:00", + "RandomSeed": "1433136520" + } +} \ 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 000000000000..b3296a497667 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:11:56.7415018-08:00", + "RandomSeed": "1553740258" + } +} \ 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 000000000000..d136ba129004 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:11:56.9088086-08:00", + "RandomSeed": "1627094290" + } +} \ 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 000000000000..900883d0e631 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:08:01.7638656-08:00", + "RandomSeed": "1088945660" + } +} \ 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 000000000000..c357fe19f2a1 --- /dev/null +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/SessionRecords/ShareClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:08:01.9526145-08:00", + "RandomSeed": "139605392" + } +} \ 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 6213505f7647..56146b45edb7 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs @@ -15,6 +15,7 @@ using NUnit.Framework; using System.Threading; using Azure.Identity; +using Moq; namespace Azure.Storage.Files.Shares.Tests { @@ -2253,6 +2254,34 @@ public void CanGenerateSas_WithSnapshot_True() Assert.IsTrue(snapshotShare.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + string shareName = GetNewShareName(); + var fileEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + shareName); + + // Act + var share = new Mock(fileEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(share.Object.CanGenerateSasUri); + + // Act + var share2 = new Mock(fileEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(share2.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 9171820aa08e..3dca75b60bfd 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/src/QueueClient.cs b/sdk/storage/Azure.Storage.Queues/src/QueueClient.cs index 1398eccc3a2b..c5ebe86c6fa8 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 172fe630bc44..f6d4d1e3a140 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 353c6555f7fb..698f9e2992b2 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs @@ -14,6 +14,7 @@ using Azure.Core.TestFramework; using System.Buffers.Text; using System.Text; +using Moq; namespace Azure.Storage.Queues.Test { @@ -1405,6 +1406,34 @@ public void CanGenerateSas_ClientConstructors() Assert.IsTrue(container4.CanGenerateSasUri); } + [Test] + public void CanGenerateSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + string queueName = GetNewQueueName(); + var fileEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + queueName); + + // Act + var queue = new Mock(fileEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(queue.Object.CanGenerateSasUri); + + // Act + var queue2 = new Mock(fileEndpoint, + constants.Sas.SharedKeyCredential, + GetOptions()) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(queue2.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 6753188156a9..835838fca63f 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs @@ -11,6 +11,7 @@ using Azure.Storage.Queues.Tests; using Azure.Storage.Sas; using Azure.Storage.Test; +using Moq; using NUnit.Framework; namespace Azure.Storage.Queues.Test @@ -434,6 +435,36 @@ public void CanGenerateSas_GetQueueClient() Assert.IsTrue(queueClient4.CanGenerateSasUri); } + [Test] + public void CanGenerateAccountSas_Mockable() + { + // Arrange + var constants = new TestConstants(this); + var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); + + // Act + var service = new Mock(blobEndpoint, GetOptions()) + { + CallBase = true + }; + // Assert + Assert.IsFalse(service.Object.CanGenerateAccountSasUri); + + // Arrange + var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); + var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); + string connectionString = storageConnectionString.ToString(true); + + // Act + var service2 = new Mock(connectionString) + { + CallBase = true + }; + + // Assert + Assert.IsTrue(service2.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 000000000000..b4c4ce8677f0 --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:21:20.5015269-08:00", + "RandomSeed": "1212146696" + } +} \ 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 000000000000..5ca8beb10c76 --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:21:20.6969658-08:00", + "RandomSeed": "384857815" + } +} \ 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 000000000000..914b3de51015 --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:21:20.7064421-08:00", + "RandomSeed": "1509389236" + } +} \ 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 000000000000..f8794e8b253a --- /dev/null +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -0,0 +1,7 @@ +{ + "Entries": [], + "Variables": { + "DateTimeOffsetNow": "2021-01-28T23:21:20.7672834-08:00", + "RandomSeed": "1477476359" + } +} \ No newline at end of file From 7969dcce96d4718d73c1e387c7b6808729f0352a Mon Sep 17 00:00:00 2001 From: Amanda Nguyen Date: Fri, 29 Jan 2021 15:32:43 -0800 Subject: [PATCH 2/2] PR comments update test to actually test mockability --- .../api/Azure.Storage.Blobs.netstandard2.0.cs | 6 ++--- .../tests/BlobBaseClientTests.cs | 25 ++++--------------- .../tests/ContainerClientTests.cs | 24 ++++-------------- .../tests/ServiceClientTests.cs | 25 +++++-------------- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateAccountSas_Mockable.json | 5 +--- .../CanGenerateAccountSas_MockableAsync.json | 5 +--- ...e.Storage.Files.DataLake.netstandard2.0.cs | 6 ++--- .../tests/DirectoryClientTests.cs | 22 ++++------------ .../tests/FileClientTests.cs | 22 ++++------------ .../tests/FileSystemClientTests.cs | 20 ++++----------- .../tests/PathClientTests.cs | 22 ++++------------ .../tests/ServiceClientTests.cs | 23 ++++------------- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateAccountSas_Mockable.json | 5 +--- .../CanGenerateAccountSas_MockableAsync.json | 5 +--- ...ure.Storage.Files.Shares.netstandard2.0.cs | 8 +++--- .../tests/DirectoryClientTests.cs | 22 ++++------------ .../tests/FileClientTests.cs | 24 +++++------------- .../tests/ServiceClientTests.cs | 25 +++++-------------- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateAccountSas_Mockable.json | 5 +--- .../CanGenerateAccountSas_MockableAsync.json | 5 +--- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../tests/ShareClientTests.cs | 23 +++++------------ .../Azure.Storage.Queues.netstandard2.0.cs | 4 +-- .../tests/QueueClientTests.cs | 23 +++++------------ .../tests/ServiceClientTests.cs | 25 +++++-------------- .../CanGenerateSas_Mockable.json | 5 +--- .../CanGenerateSas_MockableAsync.json | 5 +--- .../CanGenerateAccountSas_Mockable.json | 5 +--- .../CanGenerateAccountSas_MockableAsync.json | 5 +--- 46 files changed, 116 insertions(+), 373 deletions(-) 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 9d44bd7aa653..3431e75267d2 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/tests/BlobBaseClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs index 0f9579410c76..16493915271b 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs @@ -6054,33 +6054,18 @@ public void CanGenerateSas_WithVersion_False() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); - // Act - var blob = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var blob = new Mock(); + blob.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert Assert.IsFalse(blob.Object.CanGenerateSasUri); - // Arrange - var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); - var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); - string connectionString = storageConnectionString.ToString(true); - // Act - var blob2 = new Mock(connectionString, - GetNewContainerName(), - GetNewBlobName()) - { - CallBase = true - }; + blob.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(blob2.Object.CanGenerateSasUri); + Assert.IsTrue(blob.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs index 1ae67e859318..95e45fc1d064 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs @@ -2673,32 +2673,18 @@ public void CanGenerateSas_ClientConstructors() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); - // Act - var container = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var container = new Mock(); + container.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert Assert.IsFalse(container.Object.CanGenerateSasUri); - // Arrange - var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); - var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); - string connectionString = storageConnectionString.ToString(true); - // Act - var container2 = new Mock(connectionString, - GetNewContainerName()) - { - CallBase = true - }; + container.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(container2.Object.CanGenerateSasUri); + Assert.IsTrue(container.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs index 4c2342a50d06..171c9d7e37ac 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs @@ -975,31 +975,18 @@ public void CanGenerateSas_GetContainerClient() [Test] public void CanGenerateAccountSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); - // Act - var service = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; - // Assert - Assert.IsFalse(service.Object.CanGenerateAccountSasUri); + var serviceClient = new Mock(); + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(false); - // Arrange - var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); - var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); - string connectionString = storageConnectionString.ToString(true); + // Assert + Assert.IsFalse(serviceClient.Object.CanGenerateAccountSasUri); // Act - var service2 = new Mock(connectionString) - { - CallBase = true - }; + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(true); // Assert - Assert.IsTrue(service2.Object.CanGenerateAccountSasUri); + Assert.IsTrue(serviceClient.Object.CanGenerateAccountSasUri); } [Test] 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 index 45b1451dbd13..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_Mockable.json +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_Mockable.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T13:31:30.2020707-08:00", - "RandomSeed": "1261611442" - } + "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 index d95190f0a04a..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_MockableAsync.json +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobBaseClientTests/CanGenerateSas_MockableAsync.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T13:26:45.4061650-08:00", - "RandomSeed": "897269400" - } + "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 index 4ffcaca2801d..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_Mockable.json +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_Mockable.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T13:39:09.4428756-08:00", - "RandomSeed": "319652072" - } + "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 index 41ea8f0b2c00..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_MockableAsync.json +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ContainerClientTests/CanGenerateSas_MockableAsync.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T13:39:09.6232680-08:00", - "RandomSeed": "564511178" - } + "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 index 7e987c1910a8..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T13:41:34.0423483-08:00", - "RandomSeed": "575371005" - } + "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 index 1d039963ee46..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json +++ b/sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T13:41:34.2416945-08:00", - "RandomSeed": "390310824" - } + "Variables": {} } \ No newline at end of file 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 06948bcad1a8..fef830ec9190 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/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs index d3d07eb91fb8..5286ec6adf2a 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs @@ -5090,30 +5090,18 @@ public void CanGenerateSas_GetSubDirectoryClient() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - string fileSystemName = GetNewFileSystemName(); - string path = GetNewDirectoryName(); - var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + fileSystemName + "/" + path); - // Act - var directory = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert Assert.IsFalse(directory.Object.CanGenerateSasUri); // Act - var directory2 = new Mock(blobEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + directory.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(directory2.Object.CanGenerateSasUri); + Assert.IsTrue(directory.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs index b2c1c23b361c..9df2bb1fc8a7 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs @@ -4803,30 +4803,18 @@ public void CanGenerateSas_ClientConstructors() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - string fileSystemName = GetNewFileSystemName(); - string path = GetNewFileName(); - var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + fileSystemName + "/" + path); - // Act - var file = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var file = new Mock(); + file.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert Assert.IsFalse(file.Object.CanGenerateSasUri); // Act - var file2 = new Mock(blobEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + file.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(file2.Object.CanGenerateSasUri); + Assert.IsTrue(file.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs index 0ece8cd76ba8..f76752e1705e 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs @@ -2287,28 +2287,18 @@ public void CanGenerateSas_GetDirectoryClient() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account); - // Act - var filesystem = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var filesystem = new Mock(); + filesystem.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert Assert.IsFalse(filesystem.Object.CanGenerateSasUri); // Act - var filesystem2 = new Mock(blobEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + filesystem.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(filesystem2.Object.CanGenerateSasUri); + Assert.IsTrue(filesystem.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs index cb83d7066f87..9a8cb7ce0b28 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs @@ -196,30 +196,18 @@ public void CanGenerateSas_ClientConstructors() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - string fileSystemName = GetNewFileSystemName(); - string path = GetNewFileName(); - var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + fileSystemName + "/" + path); - // Act - var pathClient = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var pathClient = new Mock(); + pathClient.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert Assert.IsFalse(pathClient.Object.CanGenerateSasUri); // Act - var pathClient2 = new Mock(blobEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + pathClient.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(pathClient2.Object.CanGenerateSasUri); + Assert.IsTrue(pathClient.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs index b2339c5d6f73..679e6735bc04 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs @@ -598,31 +598,18 @@ public void CanGenerateSas_GetFileSystemClient() [Test] public void CanGenerateAccountSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); - // Act - var serviceClient = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var serviceClient = new Mock(); + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(false); + // Assert Assert.IsFalse(serviceClient.Object.CanGenerateAccountSasUri); - // Arrange - var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); - var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); - string connectionString = storageConnectionString.ToString(true); - // Act - var serviceClient2 = new Mock(connectionString) - { - CallBase = true - }; + serviceClient.Setup(x => x.CanGenerateAccountSasUri).Returns(true); // Assert - Assert.IsTrue(serviceClient2.Object.CanGenerateAccountSasUri); + Assert.IsTrue(serviceClient.Object.CanGenerateAccountSasUri); } [Test] 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 index 0562ef9a111b..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T14:55:16.1475833-08:00", - "RandomSeed": "945849689" - } + "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 index e5cad1a66990..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T14:55:16.3289390-08:00", - "RandomSeed": "1218038813" - } + "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 index 450818c4253d..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:00:15.1021883-08:00", - "RandomSeed": "746727861" - } + "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 index dcea8473295b..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:00:15.3237165-08:00", - "RandomSeed": "1704344659" - } + "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 index 43a7c95ddc4c..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:04:38.6023146-08:00", - "RandomSeed": "1911415986" - } + "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 index 0ef37d66c3b6..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:04:38.7811205-08:00", - "RandomSeed": "357297309" - } + "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 index fdba64b9c151..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:08:14.9613727-08:00", - "RandomSeed": "739257340" - } + "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 index 742c5431f0ac..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:08:15.2188284-08:00", - "RandomSeed": "947307214" - } + "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 index 4149f42e7ed7..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:09:41.2781705-08:00", - "RandomSeed": "622190333" - } + "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 index ba0825f05c65..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:09:41.4262694-08:00", - "RandomSeed": "784371140" - } + "Variables": {} } \ No newline at end of file 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 ba9d61970653..80875f931463 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/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs index e29a9d80da69..65d5102e0dd6 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs @@ -1279,30 +1279,18 @@ public void CanGenerateSas_GetSubdirectoryClient() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - string shareName = GetNewShareName(); - string path = GetNewDirectoryName(); - var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + shareName + "/" + path); - // Act - var directory = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert Assert.IsFalse(directory.Object.CanGenerateSasUri); // Act - var directory2 = new Mock(blobEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + directory.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(directory2.Object.CanGenerateSasUri); + Assert.IsTrue(directory.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs index a413a9d155f3..cef5da9f19b9 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs @@ -4048,30 +4048,18 @@ public void CanGenerateSas_ClientConstructors() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - string shareName = GetNewShareName(); - string path = GetNewFileName(); - var blobEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + shareName + "/" + path); - // Act - var file = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert - Assert.IsFalse(file.Object.CanGenerateSasUri); + Assert.IsFalse(directory.Object.CanGenerateSasUri); // Act - var file2 = new Mock(blobEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + directory.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(file2.Object.CanGenerateSasUri); + Assert.IsTrue(directory.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs index d19e3c2ccafa..28e2ebc47572 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ServiceClientTests.cs @@ -509,31 +509,18 @@ public void CanGenerateSas_GetShareClient() [Test] public void CanGenerateAccountSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); - // Act - var service = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; - // Assert - Assert.IsFalse(service.Object.CanGenerateAccountSasUri); + var directory = new Mock(); + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(false); - // Arrange - var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); - var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); - string connectionString = storageConnectionString.ToString(true); + // Assert + Assert.IsFalse(directory.Object.CanGenerateAccountSasUri); // Act - var service2 = new Mock(connectionString) - { - CallBase = true - }; + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(true); // Assert - Assert.IsTrue(service2.Object.CanGenerateAccountSasUri); + Assert.IsTrue(directory.Object.CanGenerateAccountSasUri); } [Test] 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 index c9893c53424c..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:12:27.9526123-08:00", - "RandomSeed": "1363570676" - } + "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 index 8379e2775bd5..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:12:28.1241218-08:00", - "RandomSeed": "1466599197" - } + "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 index 6d58926b9bb6..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:14:33.1547996-08:00", - "RandomSeed": "1182122472" - } + "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 index cc5d8c7310bb..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T15:14:33.2207069-08:00", - "RandomSeed": "1433136520" - } + "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 index b3296a497667..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:11:56.7415018-08:00", - "RandomSeed": "1553740258" - } + "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 index d136ba129004..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:11:56.9088086-08:00", - "RandomSeed": "1627094290" - } + "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 index 900883d0e631..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:08:01.7638656-08:00", - "RandomSeed": "1088945660" - } + "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 index c357fe19f2a1..20e5015d169f 100644 --- 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 @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:08:01.9526145-08:00", - "RandomSeed": "139605392" - } + "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 30f140d658ab..76ba0f170381 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs @@ -2257,29 +2257,18 @@ public void CanGenerateSas_WithSnapshot_True() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - string shareName = GetNewShareName(); - var fileEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + shareName); - // Act - var share = new Mock(fileEndpoint, GetOptions()) - { - CallBase = true - }; + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert - Assert.IsFalse(share.Object.CanGenerateSasUri); + Assert.IsFalse(directory.Object.CanGenerateSasUri); // Act - var share2 = new Mock(fileEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + directory.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(share2.Object.CanGenerateSasUri); + Assert.IsTrue(directory.Object.CanGenerateSasUri); } [Test] 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 d9bfe19c478d..ba1dad35e523 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/tests/QueueClientTests.cs b/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs index 1a83d69d2f8b..776c1332ec36 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs @@ -1409,29 +1409,18 @@ public void CanGenerateSas_ClientConstructors() [Test] public void CanGenerateSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - string queueName = GetNewQueueName(); - var fileEndpoint = new Uri("http://127.0.0.1/" + constants.Sas.Account + "/" + queueName); - // Act - var queue = new Mock(fileEndpoint, GetOptions()) - { - CallBase = true - }; + var directory = new Mock(); + directory.Setup(x => x.CanGenerateSasUri).Returns(false); + // Assert - Assert.IsFalse(queue.Object.CanGenerateSasUri); + Assert.IsFalse(directory.Object.CanGenerateSasUri); // Act - var queue2 = new Mock(fileEndpoint, - constants.Sas.SharedKeyCredential, - GetOptions()) - { - CallBase = true - }; + directory.Setup(x => x.CanGenerateSasUri).Returns(true); // Assert - Assert.IsTrue(queue2.Object.CanGenerateSasUri); + Assert.IsTrue(directory.Object.CanGenerateSasUri); } [Test] diff --git a/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs index 5be8f00822be..5ffab26c364b 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs @@ -438,31 +438,18 @@ public void CanGenerateSas_GetQueueClient() [Test] public void CanGenerateAccountSas_Mockable() { - // Arrange - var constants = new TestConstants(this); - var blobEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account); - // Act - var service = new Mock(blobEndpoint, GetOptions()) - { - CallBase = true - }; - // Assert - Assert.IsFalse(service.Object.CanGenerateAccountSasUri); + var directory = new Mock(); + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(false); - // Arrange - var blobSecondaryEndpoint = new Uri("https://127.0.0.1/" + constants.Sas.Account + "-secondary"); - var storageConnectionString = new StorageConnectionString(constants.Sas.SharedKeyCredential, blobStorageUri: (blobEndpoint, blobSecondaryEndpoint)); - string connectionString = storageConnectionString.ToString(true); + // Assert + Assert.IsFalse(directory.Object.CanGenerateAccountSasUri); // Act - var service2 = new Mock(connectionString) - { - CallBase = true - }; + directory.Setup(x => x.CanGenerateAccountSasUri).Returns(true); // Assert - Assert.IsTrue(service2.Object.CanGenerateAccountSasUri); + Assert.IsTrue(directory.Object.CanGenerateAccountSasUri); } [Test] 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 index b4c4ce8677f0..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_Mockable.json +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_Mockable.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:21:20.5015269-08:00", - "RandomSeed": "1212146696" - } + "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 index 5ca8beb10c76..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_MockableAsync.json +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/QueueClientTests/CanGenerateSas_MockableAsync.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:21:20.6969658-08:00", - "RandomSeed": "384857815" - } + "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 index 914b3de51015..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_Mockable.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:21:20.7064421-08:00", - "RandomSeed": "1509389236" - } + "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 index f8794e8b253a..20e5015d169f 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json +++ b/sdk/storage/Azure.Storage.Queues/tests/SessionRecords/ServiceClientTests/CanGenerateAccountSas_MockableAsync.json @@ -1,7 +1,4 @@ { "Entries": [], - "Variables": { - "DateTimeOffsetNow": "2021-01-28T23:21:20.7672834-08:00", - "RandomSeed": "1477476359" - } + "Variables": {} } \ No newline at end of file