diff --git a/sdk/storage/Azure.Storage.Blobs.Batch/assets.json b/sdk/storage/Azure.Storage.Blobs.Batch/assets.json index a82847cd8dacf..1e9a6b8b7ca8c 100644 --- a/sdk/storage/Azure.Storage.Blobs.Batch/assets.json +++ b/sdk/storage/Azure.Storage.Blobs.Batch/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.Blobs.Batch", - "Tag": "net/storage/Azure.Storage.Blobs.Batch_34b0b578dc" + "Tag": "net/storage/Azure.Storage.Blobs.Batch_91b5e838a2" } diff --git a/sdk/storage/Azure.Storage.Blobs.ChangeFeed/assets.json b/sdk/storage/Azure.Storage.Blobs.ChangeFeed/assets.json index aa65517b06a2c..004f1cc89330f 100644 --- a/sdk/storage/Azure.Storage.Blobs.ChangeFeed/assets.json +++ b/sdk/storage/Azure.Storage.Blobs.ChangeFeed/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.Blobs.ChangeFeed", - "Tag": "net/storage/Azure.Storage.Blobs.ChangeFeed_198f5277c7" + "Tag": "net/storage/Azure.Storage.Blobs.ChangeFeed_83537f1c55" } diff --git a/sdk/storage/Azure.Storage.Blobs.ChangeFeed/tests/ChangeFeedTestBase.cs b/sdk/storage/Azure.Storage.Blobs.ChangeFeed/tests/ChangeFeedTestBase.cs index d41bd8539b214..5feed45e60cad 100644 --- a/sdk/storage/Azure.Storage.Blobs.ChangeFeed/tests/ChangeFeedTestBase.cs +++ b/sdk/storage/Azure.Storage.Blobs.ChangeFeed/tests/ChangeFeedTestBase.cs @@ -90,7 +90,7 @@ public async Task GetTestContainerAsync( if (publicAccessType == default) { - publicAccessType = premium ? PublicAccessType.None : PublicAccessType.BlobContainer; + publicAccessType = PublicAccessType.None; } BlobContainerClient container = InstrumentClient(service.GetBlobContainerClient(containerName)); diff --git a/sdk/storage/Azure.Storage.Blobs/assets.json b/sdk/storage/Azure.Storage.Blobs/assets.json index ed50b4446fc0d..65d82fdcb5979 100644 --- a/sdk/storage/Azure.Storage.Blobs/assets.json +++ b/sdk/storage/Azure.Storage.Blobs/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.Blobs", - "Tag": "net/storage/Azure.Storage.Blobs_62a8c8fa29" + "Tag": "net/storage/Azure.Storage.Blobs_b8e4c4ca1e" } diff --git a/sdk/storage/Azure.Storage.Blobs/tests/AppendBlobClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/AppendBlobClientTests.cs index 5b3237f9ece46..ca888ef89301d 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/AppendBlobClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/AppendBlobClientTests.cs @@ -85,7 +85,7 @@ public void Ctor_TokenAuth_Http() // Act TestHelper.AssertExpectedException( - () => new AppendBlobClient(httpUri, Tenants.GetOAuthCredential()), + () => new AppendBlobClient(httpUri, TestEnvironment.Credential), new ArgumentException("Cannot use TokenCredential without HTTPS.")); } @@ -176,7 +176,7 @@ public async Task Ctor_DefaultAudience() AppendBlobClient aadBlob = InstrumentClient(new AppendBlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -185,6 +185,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -204,7 +205,7 @@ public async Task Ctor_CustomAudience() AppendBlobClient aadBlob = InstrumentClient(new AppendBlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -213,6 +214,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -232,7 +234,7 @@ public async Task Ctor_StorageAccountAudience() AppendBlobClient aadBlob = InstrumentClient(new AppendBlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -575,7 +577,7 @@ public async Task CreateAsync_EncryptionScopeAccountSAS() public async Task CreateAsync_EncryptionScopeIdentitySAS() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(TestEnvironment.Credential); await using DisposingContainer test = await GetTestContainerAsync(oauthService); Response userDelegationKey = await oauthService.GetUserDelegationKeyAsync( @@ -1291,8 +1293,6 @@ public async Task AppendBlockFromUriAsync_Min() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -1310,7 +1310,9 @@ public async Task AppendBlockFromUriAsync_Min() }; // Act - Response response = await destBlob.AppendBlockFromUriAsync(sourceBlob.Uri, options); + Response response = await destBlob.AppendBlockFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options); // Ensure that we grab the whole ETag value from the service without removing the quotes Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\""); @@ -1428,8 +1430,6 @@ public async Task AppendBlockFromUriAsync_EncryptionScope() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -1449,7 +1449,7 @@ public async Task AppendBlockFromUriAsync_EncryptionScope() // Act Response response = await destBlob.AppendBlockFromUriAsync( - sourceBlob.Uri, + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options); Assert.AreEqual(TestConfigDefault.EncryptionScope, response.Value.EncryptionScope); @@ -1462,8 +1462,6 @@ public async Task AppendBlockFromUriAsync_Range() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(4 * Constants.KB); using (var stream = new MemoryStream(data)) @@ -1482,7 +1480,7 @@ public async Task AppendBlockFromUriAsync_Range() // Act await destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options); // Assert @@ -1500,8 +1498,6 @@ public async Task AppendBlockFromUriAsync_MD5() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -1520,7 +1516,7 @@ public async Task AppendBlockFromUriAsync_MD5() // Act await destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options); } } @@ -1531,8 +1527,6 @@ public async Task AppendBlockFromUriAsync_MD5_Fail() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -1552,7 +1546,7 @@ public async Task AppendBlockFromUriAsync_MD5_Fail() // Act await TestHelper.AssertExpectedExceptionAsync( destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options), actualException => Assert.AreEqual("Md5Mismatch", actualException.ErrorCode) ); @@ -1583,8 +1577,6 @@ public async Task AppendBlockFromUriAsync_AccessConditions() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(7); using (var stream = new MemoryStream(data)) @@ -1614,7 +1606,7 @@ public async Task AppendBlockFromUriAsync_AccessConditions() // Act await destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options); } } @@ -1643,8 +1635,6 @@ public async Task AppendBlockFromUriAsync_AccessConditionsFail() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(7); using (var stream = new MemoryStream(data)) @@ -1674,7 +1664,7 @@ public async Task AppendBlockFromUriAsync_AccessConditionsFail() // Act await TestHelper.AssertExpectedExceptionAsync( destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options), actualException => Assert.IsTrue(true) ); @@ -1689,8 +1679,6 @@ public async Task AppendBlockFromUriAsync_IfTags() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using Stream stream = new MemoryStream(data); @@ -1721,7 +1709,7 @@ public async Task AppendBlockFromUriAsync_IfTags() // Act await destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options); } @@ -1732,8 +1720,6 @@ public async Task AppendBlockFromUriAsync_IfTagsFailed() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using Stream stream = new MemoryStream(data); @@ -1759,19 +1745,20 @@ public async Task AppendBlockFromUriAsync_IfTagsFailed() // Act await TestHelper.AssertExpectedExceptionAsync( destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options), e => Assert.AreEqual("ConditionNotMet", e.ErrorCode)); } [RecordedTest] + // Net462 is sending the source SAS expiry unencoded to the service, while net6 and net7 sending it encoded. + // Both are valid, but make this test non-recordable. + [LiveOnly] public async Task AppendBlockFromUriAsync_NonAsciiSourceUri() { await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -1790,7 +1777,7 @@ public async Task AppendBlockFromUriAsync_NonAsciiSourceUri() // Act await destBlob.AppendBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options); } } @@ -1801,7 +1788,7 @@ await destBlob.AppendBlockFromUriAsync( public async Task AppendBlockFromUriAsync_SourceBearerToken() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -1836,7 +1823,7 @@ public async Task AppendBlockFromUriAsync_SourceBearerToken() public async Task AppendBlockFromUriAsync_SourceBearerTokenFail() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -1874,8 +1861,6 @@ public async Task AppendBlockFromUriAsync_NullOptions() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -1888,7 +1873,8 @@ public async Task AppendBlockFromUriAsync_NullOptions() await destBlob.CreateIfNotExistsAsync(); // Act - Response response = await destBlob.AppendBlockFromUriAsync(sourceBlob.Uri); + Response response = await destBlob.AppendBlockFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Ensure that we grab the whole ETag value from the service without removing the quotes Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\""); @@ -2146,7 +2132,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewSharedKeyCredentials(), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new BlobClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new BlobClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new BlobClientOptions()).Object; } private AppendBlobRequestConditions BuildDestinationAccessConditions( diff --git a/sdk/storage/Azure.Storage.Blobs/tests/Azure.Storage.Blobs.Tests.csproj b/sdk/storage/Azure.Storage.Blobs/tests/Azure.Storage.Blobs.Tests.csproj index f595e82c15fff..e2384ae78c802 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/Azure.Storage.Blobs.Tests.csproj +++ b/sdk/storage/Azure.Storage.Blobs/tests/Azure.Storage.Blobs.Tests.csproj @@ -16,7 +16,7 @@ - + diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs index 31ad90420436e..8363d568f7db7 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs @@ -144,7 +144,7 @@ public void Ctor_TokenAuth_Http() // Act TestHelper.AssertExpectedException( - () => new BlobBaseClient(httpUri, Tenants.GetOAuthCredential()), + () => new BlobBaseClient(httpUri, TestEnvironment.Credential), new ArgumentException("Cannot use TokenCredential without HTTPS.")); } @@ -204,7 +204,7 @@ public async Task Ctor_AzureSasCredential() public async Task Ctor_AzureSasCredential_UserDelegationSAS() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync(oauthService); var client = test.Container.GetBlobClient(GetNewBlobName()); await client.UploadAsync(new MemoryStream()); @@ -266,7 +266,7 @@ public async Task Ctor_DefaultAudience() BlobBaseClient aadBlob = InstrumentClient(new BlobBaseClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -275,6 +275,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -298,7 +299,7 @@ public async Task Ctor_CustomAudience() BlobBaseClient aadBlob = InstrumentClient(new BlobBaseClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -307,6 +308,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -330,7 +332,7 @@ public async Task Ctor_StorageAccountAudience() BlobBaseClient aadBlob = InstrumentClient(new BlobBaseClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -2563,7 +2565,6 @@ public async Task StartCopyFromUriAsync_OperationAbort() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.Blob); var data = GetRandomBuffer(8 * Constants.MB); BlockBlobClient srcBlob = InstrumentClient(test.Container.GetBlockBlobClient(GetNewBlobName())); @@ -2577,7 +2578,8 @@ public async Task StartCopyFromUriAsync_OperationAbort() { BlockBlobClient destBlob = InstrumentClient(destTest.Container.GetBlockBlobClient(GetNewBlobName())); - CopyFromUriOperation operation = await destBlob.StartCopyFromUriAsync(srcBlob.Uri); + CopyFromUriOperation operation = await destBlob.StartCopyFromUriAsync( + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Act try @@ -2605,7 +2607,6 @@ public async Task AbortCopyFromUriAsync() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.Blob); var data = GetRandomBuffer(8 * Constants.MB); BlockBlobClient srcBlob = InstrumentClient(test.Container.GetBlockBlobClient(GetNewBlobName())); @@ -2619,7 +2620,8 @@ public async Task AbortCopyFromUriAsync() { BlockBlobClient destBlob = InstrumentClient(destTest.Container.GetBlockBlobClient(GetNewBlobName())); - Operation operation = await destBlob.StartCopyFromUriAsync(srcBlob.Uri); + Operation operation = await destBlob.StartCopyFromUriAsync( + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Act try @@ -2687,7 +2689,6 @@ public async Task AbortCopyFromUriAsync_Lease() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.Blob); var data = GetRandomBuffer(8 * Constants.MB); BlockBlobClient srcBlob = InstrumentClient(test.Container.GetBlockBlobClient(GetNewBlobName())); @@ -2709,7 +2710,7 @@ public async Task AbortCopyFromUriAsync_Lease() Response leaseResponse = await lease.AcquireAsync(duration); Operation operation = await destBlob.StartCopyFromUriAsync( - source: srcBlob.Uri, + source: srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), destinationConditions: new BlobRequestConditions { LeaseId = leaseResponse.Value.LeaseId }); // Act @@ -2737,7 +2738,6 @@ public async Task AbortCopyFromUriAsync_LeaseFail() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.Blob); var data = GetRandomBuffer(8 * Constants.MB); BlockBlobClient srcBlob = InstrumentClient(test.Container.GetBlockBlobClient(GetNewBlobName())); @@ -2754,7 +2754,8 @@ public async Task AbortCopyFromUriAsync_LeaseFail() await destBlob.UploadAsync(stream); } - Operation operation = await destBlob.StartCopyFromUriAsync(source: srcBlob.Uri); + Operation operation = await destBlob.StartCopyFromUriAsync( + source: srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); var leaseId = Recording.Random.NewGuid().ToString(); @@ -2810,6 +2811,8 @@ public async Task SyncCopyFromUriAsync() // Arrange BlobBaseClient srcBlob = await GetNewBlobClient(test.Container); + Uri srcBlobSasUri = srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)); + srcBlob = InstrumentClient(new BlobBaseClient(srcBlobSasUri, GetOptions())); BlockBlobClient destBlob = InstrumentClient(test.Container.GetBlockBlobClient(GetNewBlobName())); // Act @@ -2843,7 +2846,8 @@ public async Task SyncCopyFromUriAsync_EncryptionScope() await sourceBlob.UploadAsync(stream); // Act - Response response = await destBlob.SyncCopyFromUriAsync(sourceBlob.Uri); + Response response = await destBlob.SyncCopyFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Assert Assert.AreEqual(TestConfigDefault.EncryptionScope, response.Value.EncryptionScope); @@ -2899,7 +2903,8 @@ public async Task SyncCopyFromUriAsync_Tags() }; // Act - Response copyResponse = await destBlob.SyncCopyFromUriAsync(srcBlob.Uri, options); + Response copyResponse = await destBlob.SyncCopyFromUriAsync( + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options); // Assert Response response = await destBlob.GetTagsAsync(); @@ -2923,7 +2928,7 @@ public async Task SyncCopyFromUriAsync_Metadata() // Act await destBlob.SyncCopyFromUriAsync( - source: srcBlob.Uri, + source: srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options); // Assert @@ -2955,7 +2960,7 @@ public async Task SyncCopyFromUriAsync_Source_AccessConditions() // Act Response response = await destBlob.SyncCopyFromUriAsync( - source: srcBlob.Uri, + source: srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options); // Assert @@ -3028,7 +3033,7 @@ public async Task SyncCopyFromUriAsync_Destination_AccessConditions() // Act Response response = await destBlob.SyncCopyFromUriAsync( - source: srcBlob.Uri, + source: srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options); // Assert @@ -3100,7 +3105,7 @@ public async Task SyncCopyFromUriAsync_IfTags() // Act Response copyResponse = await destBlob.SyncCopyFromUriAsync( - srcBlob.Uri, + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options); } @@ -3124,7 +3129,7 @@ public async Task SyncCopyFromUriAsync_IfTagsFailed() // Act await TestHelper.AssertExpectedExceptionAsync( destBlob.SyncCopyFromUriAsync( - srcBlob.Uri, + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options), e => Assert.AreEqual("ConditionNotMet", e.ErrorCode)); } @@ -3170,7 +3175,7 @@ public async Task SyncCopyFromUriAsync_AccessTier_Cold() // Act await destBlob.SyncCopyFromUriAsync( - srcBlob.Uri, + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options); Response response = await destBlob.GetPropertiesAsync(); @@ -3226,7 +3231,8 @@ public async Task SyncCopyFromUriAsync_VersionId() BlockBlobClient destBlob = InstrumentClient(test.Container.GetBlockBlobClient(GetNewBlobName())); // Act - Response response = await destBlob.SyncCopyFromUriAsync(srcBlob.Uri); + Response response = await destBlob.SyncCopyFromUriAsync( + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Assert Assert.IsNotNull(response.Value.VersionId); @@ -3237,7 +3243,7 @@ public async Task SyncCopyFromUriAsync_VersionId() public async Task SyncCopyFromUri_SourceBearerToken() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -3275,7 +3281,7 @@ public async Task SyncCopyFromUri_SourceBearerToken() public async Task SyncCopyFromUri_SourceBearerTokenFail() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -3587,7 +3593,7 @@ await TestHelper.AssertExpectedExceptionAsync( public async Task DeleteAsync_VersionIdentitySAS() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync(oauthService); AppendBlobClient blob = InstrumentClient(test.Container.GetAppendBlobClient(GetNewBlobName())); Response createResponse = await blob.CreateAsync(); @@ -3618,7 +3624,7 @@ public async Task DeleteAsync_VersionIdentitySAS() public async Task DeleteAsync_VersionInvalidSAS() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync(oauthService); AppendBlobClient blob = InstrumentClient(test.Container.GetAppendBlobClient(GetNewBlobName())); Response createResponse = await blob.CreateAsync(); @@ -3676,7 +3682,7 @@ public async Task DeleteAsync_VersionBlobSAS(BlobSasPermissions blobSasPermissio public async Task DeleteAsync_VersionBlobIdentitySAS(BlobSasPermissions blobSasPermissions) { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync(oauthService); AppendBlobClient blob = InstrumentClient(test.Container.GetAppendBlobClient(GetNewBlobName())); Response createResponse = await blob.CreateAsync(); @@ -3733,7 +3739,7 @@ public async Task DeleteAsync_VersionContainerSAS(BlobContainerSasPermissions bl public async Task DeleteAsync_VersionContainerIdentitySAS(BlobContainerSasPermissions blobContainerSasPermissions) { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync(oauthService); AppendBlobClient blob = InstrumentClient(test.Container.GetAppendBlobClient(GetNewBlobName())); Response createResponse = await blob.CreateAsync(); @@ -4254,7 +4260,7 @@ public async Task GetPropertiesAsync_ContainerSAS() [RecordedTest] public async Task GetPropertiesAsync_ContainerIdentitySAS() { - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); var containerName = GetNewContainerName(); var blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -4417,7 +4423,7 @@ public async Task GetPropertiesAsync_BlobSasWithContentHeaders() [RecordedTest] public async Task GetPropertiesAsync_BlobIdentitySAS() { - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); var containerName = GetNewContainerName(); var blobName = GetNewBlobName(); @@ -4538,7 +4544,7 @@ public async Task GetPropertiesAsync_SnapshotSAS_Using_BlobClient() [RecordedTest] public async Task GetPropertiesAsync_SnapshotIdentitySAS() { - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); var containerName = GetNewContainerName(); var blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -6417,7 +6423,7 @@ await TestHelper.AssertExpectedExceptionAsync( [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_12_12)] public async Task GetSetTagsAsync_BlobIdentityTagSas() { - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -6452,7 +6458,7 @@ public async Task GetSetTagsAsync_BlobIdentityTagSas() [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_12_12)] public async Task GetSetTagsAsync_InvalidBlobIdentitySas() { - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -6527,7 +6533,7 @@ await TestHelper.AssertExpectedExceptionAsync( [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_12_12)] public async Task GetSetTagsAsync_ContainerIdentityTagSas() { - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -6561,7 +6567,7 @@ public async Task GetSetTagsAsync_ContainerIdentityTagSas() [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_12_12)] public async Task GetSetTagsAsync_InvalidContainerIdentitySas() { - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -7822,7 +7828,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewSharedKeyCredentials(), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new BlobClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new BlobClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new BlobClientOptions()).Object; } [RecordedTest] diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs index 2d9d9478d2eff..4511dfd4920ef 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobClientTests.cs @@ -104,7 +104,7 @@ public void Ctor_TokenAuth_Http() // Act TestHelper.AssertExpectedException( - () => new BlobClient(httpUri, Tenants.GetOAuthCredential()), + () => new BlobClient(httpUri, TestEnvironment.Credential), new ArgumentException("Cannot use TokenCredential without HTTPS.")); } @@ -218,7 +218,7 @@ public async Task Ctor_DefaultAudience() BlobClient aadBlob = InstrumentClient(new BlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -227,6 +227,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -250,7 +251,7 @@ public async Task Ctor_CustomAudience() BlobClient aadBlob = InstrumentClient(new BlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -259,6 +260,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -282,7 +284,7 @@ public async Task Ctor_StorageAccountAudience() BlobClient aadBlob = InstrumentClient(new BlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -1522,7 +1524,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewSharedKeyCredentials(), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new BlobClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new BlobClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new BlobClientOptions()).Object; } } } diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobSasBuilderTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobSasBuilderTests.cs index 2a81a2561d259..19696136cbccd 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobSasBuilderTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobSasBuilderTests.cs @@ -478,7 +478,7 @@ private BlobSasBuilder BuildBlobSasBuilder(bool includeBlob, bool includeSnapsho public async Task BlobSasBuilder_PreauthorizedAgentObjectId() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string preauthorizedAgentGuid = Recording.Random.NewGuid().ToString(); @@ -516,7 +516,7 @@ public async Task BlobSasBuilder_PreauthorizedAgentObjectId() public async Task BlobSasBuilder_CorrelationId() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); await using DisposingContainer test = await GetTestContainerAsync(service: oauthService, containerName: containerName); diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobSasTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobSasTests.cs index caa43a5fa0c62..aa9dc7241b3eb 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobSasTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobSasTests.cs @@ -54,7 +54,7 @@ public async Task BlobSas_AllPermissions() public async Task BlobIdentitySas_AllPermissions() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -119,7 +119,7 @@ public async Task BlobVersionSas_AllPermissions() public async Task BlobVersionIdentitySas_AllPermissions() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -189,7 +189,7 @@ public async Task BlobSnapshotSas_AllPermissions() public async Task BlobSnapshotIdentitySas_AllPermissions() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); @@ -253,7 +253,7 @@ public async Task ContainerSas_AllPermissions() public async Task ContainerIdentitySas_AllPermissions() { // Arrange - BlobServiceClient oauthService = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient oauthService = GetServiceClient_OAuth(); string containerName = GetNewContainerName(); string blobName = GetNewBlobName(); await using DisposingContainer test = await GetTestContainerAsync(containerName: containerName, service: oauthService); diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs index 52c994a5b9a13..1a6a1aefcb6e5 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobTestBase.cs @@ -93,13 +93,16 @@ private BlobServiceClient GetServiceClientFromOauthConfig(TenantConfiguration co return InstrumentClient( new BlobServiceClient( new Uri(config.BlobServiceEndpoint), - Tenants.GetOAuthCredential(config), + TestEnvironment.Credential, options)); } public BlobServiceClient GetServiceClient_OauthAccount_TenantDiscovery() => GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, true); + public BlobServiceClient GetServiceClient_OAuth() + => BlobsClientBuilder.GetServiceClient_OAuth(TestEnvironment.Credential); + public BlobClientOptions GetFaultyBlobConnectionOptions( int raiseAt = default, Exception raise = default, @@ -173,16 +176,13 @@ public Security.KeyVault.Keys.KeyClient GetKeyClient_TargetKeyClient() public TokenCredential GetTokenCredential_TargetKeyClient() => GetKeyClientTokenCredential(TestConfigurations.DefaultTargetKeyVault); - private static Security.KeyVault.Keys.KeyClient GetKeyClient(KeyVaultConfiguration config) + private Security.KeyVault.Keys.KeyClient GetKeyClient(KeyVaultConfiguration config) => new Security.KeyVault.Keys.KeyClient( new Uri(config.VaultEndpoint), GetKeyClientTokenCredential(config)); - private static TokenCredential GetKeyClientTokenCredential(KeyVaultConfiguration config) - => new Identity.ClientSecretCredential( - config.ActiveDirectoryTenantId, - config.ActiveDirectoryApplicationId, - config.ActiveDirectoryApplicationSecret); + private TokenCredential GetKeyClientTokenCredential(KeyVaultConfiguration config) + => TestEnvironment.Credential; public BlobServiceClient GetServiceClient_BlobServiceSas_Container( string containerName, diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobTestEnvironment.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobTestEnvironment.cs index 69bc1fff7dbe0..55e207ee978b9 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobTestEnvironment.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobTestEnvironment.cs @@ -28,8 +28,7 @@ private async Task DoesOAuthWorkAsync() for (int i = 0; i < 10; i++) { BlobServiceClient serviceClient = new BlobServiceClient( - new Uri(TestConfigurations.DefaultTargetOAuthTenant.BlobServiceEndpoint), - GetOAuthCredential(TestConfigurations.DefaultTargetOAuthTenant)); + new Uri(TestConfigurations.DefaultTargetOAuthTenant.BlobServiceEndpoint), Credential); await serviceClient.GetPropertiesAsync(); var containerName = Guid.NewGuid().ToString(); var containerClient = serviceClient.GetBlobContainerClient(containerName); diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlockBlobClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlockBlobClientTests.cs index c81ebac7c123c..65b2103005cc1 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlockBlobClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlockBlobClientTests.cs @@ -89,7 +89,7 @@ public void Ctor_TokenAuth_Http() // Act TestHelper.AssertExpectedException( - () => new BlockBlobClient(httpUri, Tenants.GetOAuthCredential()), + () => new BlockBlobClient(httpUri, TestEnvironment.Credential), new ArgumentException("Cannot use TokenCredential without HTTPS.")); } @@ -610,7 +610,9 @@ public async Task StageBlockFromUriAsync_Min() // Act await RetryAsync( - async () => await destBlob.StageBlockFromUriAsync(sourceBlob.Uri, ToBase64(GetNewBlockName())), + async () => await destBlob.StageBlockFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + ToBase64(GetNewBlockName())), _retryStageBlockFromUri); } @@ -708,7 +710,9 @@ public async Task StageBlockFromUriAsync_CPK() // Act await RetryAsync( - async () => await destBlob.StageBlockFromUriAsync(sourceBlob.Uri, ToBase64(GetNewBlockName())), + async () => await destBlob.StageBlockFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + ToBase64(GetNewBlockName())), _retryStageBlockFromUri); } @@ -733,7 +737,7 @@ public async Task StageBlockFromUriAsync_EncryptionScope() // Act Response response = await destBlob.StageBlockFromUriAsync( - sourceBlob.Uri, + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), ToBase64(GetNewBlockName())); // Assert @@ -765,7 +769,7 @@ public async Task StageBlockFromUriAsync_Range() // Act await RetryAsync( async () => await destBlob.StageBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), base64BlockId: ToBase64(GetNewBlockName()), options: options), _retryStageBlockFromUri); @@ -800,7 +804,7 @@ public async Task StageBlockFromUriAsync_MD5() // Act await RetryAsync( async () => await destBlob.StageBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), base64BlockId: ToBase64(GetNewBlockName()), options: options), _retryStageBlockFromUri); @@ -832,7 +836,7 @@ public async Task StageBlockFromUriAsync_MD5_Fail() await TestHelper.AssertExpectedExceptionAsync( RetryAsync( async () => await destBlob.StageBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), base64BlockId: ToBase64(GetNewBlockName()), options: options), _retryStageBlockFromUri), @@ -873,7 +877,7 @@ public async Task StageBlockFromUriAsync_Lease() // Act await RetryAsync( async () => await destBlob.StageBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), base64BlockId: ToBase64(GetNewBlockName()), options: options), _retryStageBlockFromUri); @@ -913,7 +917,7 @@ public async Task StageBlockFromUriAsync_Lease_Fail() await TestHelper.AssertExpectedExceptionAsync( RetryAsync( async () => await destBlob.StageBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), base64BlockId: ToBase64(GetNewBlockName()), options: options), _retryStageBlockFromUri), @@ -951,7 +955,7 @@ public async Task StageBlockFromUriAsync_SourceAccessConditions() // Act await RetryAsync( async () => await destBlob.StageBlockFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), base64BlockId: ToBase64(GetNewBlockName()), options: options), _retryStageBlockFromUri); @@ -998,6 +1002,9 @@ await TestHelper.AssertExpectedExceptionAsync( } [RecordedTest] + // Net462 is sending the source SAS expiry unencoded to the service, while net6 and net7 sending it encoded. + // Both are valid, but make this test non-recordable. + [LiveOnly] public async Task StageBlockFromUriAsync_NonAsciiSourceUri() { await using DisposingContainer test = await GetTestContainerAsync(); @@ -1016,7 +1023,9 @@ public async Task StageBlockFromUriAsync_NonAsciiSourceUri() // Act await RetryAsync( - async () => await destBlob.StageBlockFromUriAsync(sourceBlob.Uri, ToBase64(GetNewBlockName())), + async () => await destBlob.StageBlockFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + ToBase64(GetNewBlockName())), _retryStageBlockFromUri); } @@ -1025,7 +1034,7 @@ await RetryAsync( public async Task StageBlockFromUriAsync_SourceBearerToken() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -1064,7 +1073,7 @@ await RetryAsync( public async Task StageBlockFromUriAsync_SourceBearerTokenFail() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(TestEnvironment.Credential); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -2767,7 +2776,8 @@ public async Task SyncUploadFromUriAsync() await sourceBlob.UploadAsync(stream, uploadOptions); // Act - Response uploadResponse = await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri); + Response uploadResponse = await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Assert Assert.AreNotEqual(default(ETag), uploadResponse.Value.ETag); @@ -2856,7 +2866,7 @@ public async Task SyncUploadFromUriAsync_SourceErrorAndStatusCode() // Act await TestHelper.AssertExpectedExceptionAsync( - destBlob.SyncUploadFromUriAsync(sourceBlob.Uri), + destBlob.SyncUploadFromUriAsync(sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))), e => { Assert.IsTrue(e.Message.Contains("CopySourceStatusCode: 409")); @@ -2899,7 +2909,9 @@ public async Task SyncUploadFromUriAsync_OverwriteSourceBlobProperties() }; // Act - await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options); + await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options); // Assert @@ -2948,7 +2960,9 @@ public async Task SyncUploadFromUriAsync_DestinationAccessConditions() }; // Act - await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options); + await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options); // Assert @@ -2988,7 +3002,9 @@ public async Task SyncUploadFromUriAsync_DestinationAccessConditionsFailed() // Act await TestHelper.AssertExpectedExceptionAsync( - destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options), + destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options), e => Assert.IsTrue(BlobErrorCode.TargetConditionNotMet.ToString() == e.ErrorCode || BlobErrorCode.ConditionNotMet.ToString() == e.ErrorCode)); } @@ -3019,7 +3035,9 @@ public async Task SyncUploadFromUriAsync_SourceAccessConditions() }; // Act - await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options); + await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options); // Assert @@ -3098,7 +3116,9 @@ public async Task SyncUploadFromUriAsync_IfTags() }; // Act - await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options); + await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options); // Assert @@ -3137,7 +3157,9 @@ public async Task SyncUploadFromUriAsync_IfTagsFailed() // Act await TestHelper.AssertExpectedExceptionAsync( - destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options), + destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options), e => Assert.AreEqual(BlobErrorCode.ConditionNotMet.ToString(), e.ErrorCode)); } @@ -3170,7 +3192,9 @@ public async Task SyncUploadFromUriAsync_Lease() }; // Act - await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options); + await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options); // Assert @@ -3208,7 +3232,9 @@ public async Task SyncUploadFromUriAsync_LeaseFailed() // Act await TestHelper.AssertExpectedExceptionAsync( - destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options), + destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options), e => Assert.AreEqual(BlobErrorCode.LeaseNotPresentWithBlobOperation.ToString(), e.ErrorCode)); } @@ -3231,7 +3257,8 @@ public async Task SyncUploadFromUriAsync_CPK() await sourceBlob.UploadAsync(stream); // Act - Response response = await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri); + Response response = await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Assert Assert.AreEqual(customerProvidedKey.EncryptionKeyHash, response.Value.EncryptionKeySha256); @@ -3254,7 +3281,8 @@ public async Task SyncUploadFromUriAsync_EncryptionScope() await sourceBlob.UploadAsync(stream); // Act - Response response = await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri); + Response response = await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1))); // Assert Assert.AreEqual(TestConfigDefault.EncryptionScope, response.Value.EncryptionScope); @@ -3282,7 +3310,8 @@ public async Task SyncUploadFromUriAsync_ContentMd5() }; // Act - Response response = await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options); + Response response = await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options: options); // Assert Assert.AreEqual(sourceContentMd5, response.Value.ContentHash); @@ -3312,7 +3341,9 @@ public async Task SyncUploadFromUriAsync_ContentMd5Failed() // Act await TestHelper.AssertExpectedExceptionAsync( - destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options: options), + destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options: options), e => Assert.AreEqual(BlobErrorCode.Md5Mismatch.ToString(), e.ErrorCode)); } @@ -3332,7 +3363,9 @@ public async Task SyncUploadFromUriAsync_Overwrite() await sourceBlob.UploadAsync(stream); // Act - await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, overwrite: true); + await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + overwrite: true); // Assert @@ -3361,7 +3394,9 @@ public async Task SyncUploadFromUriAsync_OverwriteFailed() // Act await TestHelper.AssertExpectedExceptionAsync( - destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, overwrite: false), + destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + overwrite: false), e => Assert.AreEqual(BlobErrorCode.BlobAlreadyExists.ToString(), e.ErrorCode)); } @@ -3370,7 +3405,7 @@ await TestHelper.AssertExpectedExceptionAsync( public async Task SyncUploadFromUriAsync_SourceBearerToken() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(TestEnvironment.Credential); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -3405,7 +3440,7 @@ await destBlob.SyncUploadFromUriAsync( public async Task SyncUploadFromUriAsync_SourceBearerTokenFail() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -3519,7 +3554,8 @@ public async Task SyncUploadFromUriAsync_AccessTier_Cold() }; // Act - await destBlob.SyncUploadFromUriAsync(sourceBlob.Uri, options); + await destBlob.SyncUploadFromUriAsync( + sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), options); // Assert Response response = await destBlob.GetPropertiesAsync(); @@ -3574,7 +3610,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewSharedKeyCredentials(), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new BlobClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new BlobClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new BlobClientOptions()).Object; } private RequestConditions BuildRequestConditions(AccessConditionParameters parameters) diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ClientBuilderExtensions.cs b/sdk/storage/Azure.Storage.Blobs/tests/ClientBuilderExtensions.cs index b9b484f3acf28..5a3cb6859e03c 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ClientBuilderExtensions.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ClientBuilderExtensions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Azure.Core; using Azure.Storage.Blobs.Models; using Azure.Storage.Blobs.Specialized; using Azure.Storage.Test.Shared; @@ -54,8 +55,8 @@ public static BlobServiceClient GetServiceClient_PreviewAccount_SharedKey(this B public static BlobServiceClient GetServiceClient_PremiumBlobAccount_SharedKey(this BlobsClientBuilder clientBuilder) => clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigPremiumBlob); - public static BlobServiceClient GetServiceClient_OAuth(this BlobsClientBuilder clientBuilder) - => clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth); + public static BlobServiceClient GetServiceClient_OAuth(this BlobsClientBuilder clientBuilder, TokenCredential tokenCredential) + => clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, tokenCredential); public static BlobServiceClient GetServiceClient_OAuthAccount_SharedKey(this BlobsClientBuilder clientBuilder) => clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigOAuth); @@ -82,7 +83,7 @@ public static async Task GetTestContainerAsync( if (publicAccessType == default) { - publicAccessType = premium ? PublicAccessType.None : PublicAccessType.BlobContainer; + publicAccessType = PublicAccessType.None; } BlobContainerClient container = clientBuilder.AzureCoreRecordedTestBase.InstrumentClient(service.GetBlobContainerClient(containerName)); diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs index db55dddffc336..9b7aa6ef6cdef 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs @@ -262,7 +262,7 @@ public void Ctor_TokenAuth_Http() // Act TestHelper.AssertExpectedException( - () => new BlobContainerClient(httpUri, Tenants.GetOAuthCredential()), + () => new BlobContainerClient(httpUri, TestEnvironment.Credential), new ArgumentException("Cannot use TokenCredential without HTTPS.")); } @@ -347,7 +347,7 @@ public async Task Ctor_DefaultAudience() BlobContainerClient aadContainer = InstrumentClient(new BlobContainerClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -356,6 +356,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -371,7 +372,7 @@ public async Task Ctor_CustomAudience() BlobContainerClient aadContainer = InstrumentClient(new BlobContainerClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -380,6 +381,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -395,7 +397,7 @@ public async Task Ctor_StorageAccountAudience() BlobContainerClient aadContainer = InstrumentClient(new BlobContainerClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -494,7 +496,7 @@ public async Task CreateAsync_WithOauth() { // Arrange var containerName = GetNewContainerName(); - BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient service = GetServiceClient_OAuth(); BlobContainerClient container = InstrumentClient(service.GetBlobContainerClient(containerName)); try @@ -635,6 +637,7 @@ public async Task CreateAsync_EncryptionScopeOptions() } [RecordedTest] + [PlaybackOnly("Public access disabled on live tests accounts")] public async Task CreateAsync_PublicAccess() { // Arrange @@ -1259,7 +1262,6 @@ public async Task GetAccessPolicyAsync_EmptyAccessPolicy() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - PublicAccessType publicAccessType = PublicAccessType.BlobContainer; BlobSignedIdentifier[] signedIdentifiers = new[] { new BlobSignedIdentifier @@ -1271,7 +1273,6 @@ public async Task GetAccessPolicyAsync_EmptyAccessPolicy() // Act Response response = await test.Container.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers ); @@ -1303,12 +1304,10 @@ public async Task SetAccessPolicyAsync() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - PublicAccessType publicAccessType = PublicAccessType.BlobContainer; BlobSignedIdentifier[] signedIdentifiers = BuildSignedIdentifiers(); // Act Response response = await test.Container.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers ); @@ -1318,7 +1317,6 @@ public async Task SetAccessPolicyAsync() Assert.AreEqual(response.Value.ETag.ToString(), $"\"{response.GetRawResponse().Headers.ETag}\""); Response propertiesResponse = await test.Container.GetPropertiesAsync(); - Assert.AreEqual(publicAccessType, propertiesResponse.Value.PublicAccess); Response getPolicyResponse = await test.Container.GetAccessPolicyAsync(); Assert.AreEqual(1, getPolicyResponse.Value.SignedIdentifiers.Count()); @@ -1523,7 +1521,6 @@ public async Task SetAccessPolicyAsync_AccessConditions() BlobServiceClient service = GetServiceClient_SharedKey(); BlobContainerClient container = InstrumentClient(service.GetBlobContainerClient(GetNewContainerName())); await container.CreateIfNotExistsAsync(); - PublicAccessType publicAccessType = PublicAccessType.BlobContainer; BlobSignedIdentifier[] signedIdentifiers = BuildSignedIdentifiers(); parameters.LeaseId = await SetupContainerLeaseCondition(container, parameters.LeaseId, garbageLeaseId); BlobRequestConditions accessConditions = BuildContainerAccessConditions( @@ -1533,7 +1530,6 @@ public async Task SetAccessPolicyAsync_AccessConditions() // Act Response response = await container.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers, conditions: accessConditions ); @@ -1577,7 +1573,6 @@ public async Task SetAccessPolicyAsync_InvalidPermissionOrder() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - PublicAccessType publicAccessType = PublicAccessType.BlobContainer; BlobSignedIdentifier[] signedIdentifiers = new[] { new BlobSignedIdentifier @@ -1594,13 +1589,11 @@ public async Task SetAccessPolicyAsync_InvalidPermissionOrder() // Act await test.Container.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers ); // Assert Response propertiesResponse = await test.Container.GetPropertiesAsync(); - Assert.AreEqual(publicAccessType, propertiesResponse.Value.PublicAccess); Response response = await test.Container.GetAccessPolicyAsync(); Assert.AreEqual(1, response.Value.SignedIdentifiers.Count()); @@ -4058,7 +4051,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewSharedKeyCredentials(), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new BlobClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new BlobClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new BlobClientOptions()).Object; } #region Secondary Storage diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ImmutableStorageWithVersioningTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ImmutableStorageWithVersioningTests.cs index 76d4079eb33cf..3eac647db9cf8 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ImmutableStorageWithVersioningTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ImmutableStorageWithVersioningTests.cs @@ -6,16 +6,18 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using Azure.Core; using Azure.Core.TestFramework; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Storage; +using Azure.ResourceManager.Storage.Models; using Azure.Storage.Blobs.Models; using Azure.Storage.Blobs.Specialized; using Azure.Storage.Blobs.Tests; using Azure.Storage.Sas; using Azure.Storage.Test; using Azure.Storage.Test.Shared; -using Azure.Storage.Tests.Shared; -using Microsoft.Azure.Management.Storage; -using Microsoft.Rest; using NUnit.Framework; namespace Azure.Storage.Blobs.Test @@ -29,7 +31,8 @@ public ImmutableStorageWithVersioningTests(bool async, BlobClientOptions.Service // The container is shared by all tests in this class private string _containerName; - private StorageManagementClient _storageManagementClient; + private BlobContainerResource _container; + //private StorageManagementClient _storageManagementClient; private BlobContainerClient _containerClient; @@ -39,21 +42,28 @@ public async Task GlobalSetUp() if (Mode != RecordedTestMode.Playback) { _containerName = Guid.NewGuid().ToString(); - var configuration = TestConfigurations.DefaultTargetOAuthTenant; - - string subscriptionId = configuration.SubscriptionId; - string[] scopes = new string[] { "https://management.azure.com/.default" }; - string token = await GetAuthToken(scopes, configuration); - TokenCredentials tokenCredentials = new TokenCredentials(token); - _storageManagementClient = new StorageManagementClient(tokenCredentials) { SubscriptionId = subscriptionId }; - - await _storageManagementClient.BlobContainers.CreateAsync( - resourceGroupName: configuration.ResourceGroupName, - accountName: configuration.AccountName, - containerName: _containerName, - new Microsoft.Azure.Management.Storage.Models.BlobContainer( - publicAccess: Microsoft.Azure.Management.Storage.Models.PublicAccess.Container, - immutableStorageWithVersioning: new Microsoft.Azure.Management.Storage.Models.ImmutableStorageWithVersioning(true))); + TenantConfiguration configuration = TestConfigurations.DefaultTargetOAuthTenant; + + try + { + ArmClient armClient = new ArmClient(TestEnvironment.Credential); + SubscriptionResource subscription = armClient.GetSubscriptionResource(new ResourceIdentifier($"/subscriptions/{configuration.SubscriptionId}")); + ResourceGroupResource resourceGroup = await subscription.GetResourceGroupAsync(configuration.ResourceGroupName); + StorageAccountResource storageAccount = await resourceGroup.GetStorageAccountAsync(configuration.AccountName); + BlobServiceResource blobService = storageAccount.GetBlobService(); + BlobContainerCollection blobContainerCollection = blobService.GetBlobContainers(); + BlobContainerData blobContainerData = new BlobContainerData(); + blobContainerData.ImmutableStorageWithVersioning = new ImmutableStorageWithVersioning + { + IsEnabled = true + }; + ArmOperation blobContainerCreateOperation = await blobContainerCollection.CreateOrUpdateAsync(WaitUntil.Completed, _containerName, blobContainerData); + _container = blobContainerCreateOperation.Value; + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } return; } } @@ -70,8 +80,8 @@ public async Task GlobalTearDown() { if (Mode != RecordedTestMode.Playback) { - var configuration = TestConfigurations.DefaultTargetOAuthTenant; - var containerClient = new BlobServiceClient( + TenantConfiguration configuration = TestConfigurations.DefaultTargetOAuthTenant; + BlobContainerClient containerClient = new BlobServiceClient( new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint), new StorageSharedKeyCredential(Tenants.TestConfigOAuth.AccountName, Tenants.TestConfigOAuth.AccountKey)) @@ -93,10 +103,7 @@ public async Task GlobalTearDown() await blobClient.DeleteIfExistsAsync(); } - await _storageManagementClient.BlobContainers.DeleteAsync( - resourceGroupName: configuration.ResourceGroupName, - accountName: configuration.AccountName, - containerName: _containerName); + await _container.DeleteAsync(WaitUntil.Completed); } } @@ -490,7 +497,7 @@ await TestHelper.AssertExpectedExceptionAsync( blob.SetImmutabilityPolicyAsync( immutabilityPolicy: immutabilityPolicy, conditions: conditions), - e => Assert.AreEqual(BlobErrorCode.ConditionNotMet.ToString(), e.ErrorCode)); + e => Assert.AreEqual("ConditionNotMet", e.ErrorCode)); } [Test] @@ -825,7 +832,9 @@ public async Task SyncCopyFromUri_ImmutableStorageWithVersioning() }; // Act - await destBlob.SyncCopyFromUriAsync(srcBlob.Uri, options); + await destBlob.SyncCopyFromUriAsync( + srcBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + options); // Assert Response propertiesResponse = await destBlob.GetPropertiesAsync(); diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskFixture.cs b/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskFixture.cs index 3b0e08f68d55d..7ac4260b93a84 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskFixture.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskFixture.cs @@ -43,10 +43,7 @@ public override async Task SetUp() { _config = TestConfigurations.DefaultTargetManagedDisk; - TokenCredential tokenCredentials = new Identity.ClientSecretCredential( - _config.ActiveDirectoryTenantId, _config.ActiveDirectoryApplicationId, _config.ActiveDirectoryApplicationSecret); - - ArmClient client = new ArmClient(tokenCredentials, _config.SubsriptionId); + ArmClient client = new ArmClient(Environment.Credential, _config.SubsriptionId); SubscriptionResource subscription = await client.GetDefaultSubscriptionAsync(); _resourceGroup = await subscription.GetResourceGroups().GetAsync(_config.ResourceGroupName); var disks = await _resourceGroup.GetManagedDisks().GetAllAsync().ToListAsync(); diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskTests.cs index 699ce95fc6a8c..2441b09c9559c 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ManagedDiskTests.cs @@ -38,10 +38,10 @@ public void Setup() } [Test] - [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/30035")] public async Task CanDiffPagesBetweenSnapshots() { // Arrange + Setup(); var snapshot1Client = InstrumentClient(new PageBlobClient(snapshot1SASUri, GetOptions())); var snapshot2Client = InstrumentClient(new PageBlobClient(snapshot2SASUri, GetOptions())); @@ -74,6 +74,7 @@ public async Task CanDiffPagesBetweenSnapshots() public async Task GetManagedDiskPageRangesDiffAsync_Error() { // Arrange + Setup(); var snapshot1Client = InstrumentClient(new PageBlobClient(snapshot1SASUri, GetOptions())); // Act @@ -90,6 +91,7 @@ await TestHelper.AssertExpectedExceptionAsync( [Test] public async Task GetManagedDiskPageRangesDiffAsync_AccessConditions() { + Setup(); var snapshot2Client = InstrumentClient(new PageBlobClient(snapshot2SASUri, GetOptions())); foreach (var parameters in Reduced_AccessConditions_Data) @@ -114,6 +116,7 @@ public async Task GetManagedDiskPageRangesDiffAsync_AccessConditions() [Test] public async Task GetManagedDiskPageRangesDiffAsync_AccessConditionsFail() { + Setup(); var snapshot2Client = InstrumentClient(new PageBlobClient(snapshot2SASUri, GetOptions())); foreach (var parameters in Reduced_AccessConditions_Fail_Data) { diff --git a/sdk/storage/Azure.Storage.Blobs/tests/PageBlobClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/PageBlobClientTests.cs index 18f52e1630904..d85f694346f9c 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/PageBlobClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/PageBlobClientTests.cs @@ -92,7 +92,7 @@ public void Ctor_TokenAuth_Http() // Act TestHelper.AssertExpectedException( - () => new PageBlobClient(httpUri, Tenants.GetOAuthCredential()), + () => new PageBlobClient(httpUri, TestEnvironment.Credential), new ArgumentException("Cannot use TokenCredential without HTTPS.")); } @@ -166,7 +166,7 @@ public async Task Ctor_DefaultAudience() PageBlobClient aadBlob = InstrumentClient(new PageBlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -175,6 +175,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -194,7 +195,7 @@ public async Task Ctor_CustomAudience() PageBlobClient aadBlob = InstrumentClient(new PageBlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -203,6 +204,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -222,7 +224,7 @@ public async Task Ctor_StorageAccountAudience() PageBlobClient aadBlob = InstrumentClient(new PageBlobClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -3001,7 +3003,7 @@ public async Task StartCopyIncrementalAsync_Error() // Act await TestHelper.AssertExpectedExceptionAsync( blob.StartCopyIncrementalAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), // dummy snapshot value. snapshot: "2019-03-29T18:12:15.6608647Z"), e => @@ -3072,7 +3074,6 @@ public async Task StartCopyIncrementalAsync_AccessConditionsFail() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); var data = GetRandomBuffer(Constants.KB); var expectedData = new byte[4 * Constants.KB]; data.CopyTo(expectedData, 0); @@ -3094,7 +3095,7 @@ public async Task StartCopyIncrementalAsync_AccessConditionsFail() PageBlobClient blob = InstrumentClient(test.Container.GetPageBlobClient(GetNewBlobName())); Operation operation = await blob.StartCopyIncrementalAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), snapshot: snapshot); await operation.WaitForCompletionAsync(); parameters.NoneMatch = await SetupBlobMatchCondition(blob, parameters.NoneMatch); @@ -3344,9 +3345,6 @@ public async Task UploadPagesFromUriAsync_Min() { await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -3361,7 +3359,7 @@ public async Task UploadPagesFromUriAsync_Min() // Act Response response = await destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range); @@ -3489,8 +3487,6 @@ public async Task UploadPagesFromUriAsync_EncryptionScope() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using var stream = new MemoryStream(data); @@ -3505,7 +3501,7 @@ public async Task UploadPagesFromUriAsync_EncryptionScope() // Act Response response = await destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range); @@ -3519,8 +3515,6 @@ public async Task UploadPagesFromUriAsync_Range() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(4 * Constants.KB); using (var stream = new MemoryStream(data)) @@ -3535,7 +3529,7 @@ public async Task UploadPagesFromUriAsync_Range() // Act await destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: new HttpRange(2 * Constants.KB, 2 * Constants.KB), range: range); @@ -3554,7 +3548,6 @@ public async Task UploadPagesFromUriAsync_MD5() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); var data = GetRandomBuffer(Constants.KB); @@ -3575,7 +3568,7 @@ public async Task UploadPagesFromUriAsync_MD5() // Act await destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range, options: options); @@ -3588,8 +3581,6 @@ public async Task UploadPagesFromUriAsync_MD5_Fail() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -3610,7 +3601,7 @@ public async Task UploadPagesFromUriAsync_MD5_Fail() // Act await TestHelper.AssertExpectedExceptionAsync( destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range, options: options), @@ -3646,8 +3637,6 @@ public async Task UploadPagesFromUriAsync_AccessConditions() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -3679,7 +3668,7 @@ public async Task UploadPagesFromUriAsync_AccessConditions() // Act await destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range, options: options); @@ -3688,6 +3677,9 @@ await destBlob.UploadPagesFromUriAsync( } [RecordedTest] + // Net462 is sending the source SAS expiry unencoded to the service, while net6 and net7 sending it encoded. + // Both are valid, but make this test non-recordable. + [LiveOnly] public async Task UploadPagesFromUriAsync_NonAsciiSourceUri() { await using DisposingContainer test = await GetTestContainerAsync(); @@ -3695,9 +3687,6 @@ public async Task UploadPagesFromUriAsync_NonAsciiSourceUri() // Arrange var data = GetRandomBuffer(Constants.KB); - // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - using (var stream = new MemoryStream(data)) { PageBlobClient sourceBlob = InstrumentClient(test.Container.GetPageBlobClient(GetNewNonAsciiBlobName())); @@ -3710,7 +3699,7 @@ public async Task UploadPagesFromUriAsync_NonAsciiSourceUri() // Act await destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range); } @@ -3742,8 +3731,6 @@ public async Task UploadPagesFromUriAsync_AccessConditionsFail() await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); - var data = GetRandomBuffer(Constants.KB); using (var stream = new MemoryStream(data)) @@ -3775,7 +3762,7 @@ public async Task UploadPagesFromUriAsync_AccessConditionsFail() // Act await TestHelper.AssertExpectedExceptionAsync( destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range, options: options), @@ -3789,10 +3776,8 @@ await TestHelper.AssertExpectedExceptionAsync( [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_12_12)] public async Task UploadPagesFromUriAsync_IfTags() { - await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); + await using DisposingContainer test = await GetTestContainerAsync(); var data = GetRandomBuffer(Constants.KB); @@ -3825,7 +3810,7 @@ public async Task UploadPagesFromUriAsync_IfTags() // Act await destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range, options: options); @@ -3835,10 +3820,8 @@ await destBlob.UploadPagesFromUriAsync( [ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2019_12_12)] public async Task UploadPagesFromUriAsync_IfTagsFailed() { - await using DisposingContainer test = await GetTestContainerAsync(); // Arrange - - await test.Container.SetAccessPolicyAsync(PublicAccessType.BlobContainer); + await using DisposingContainer test = await GetTestContainerAsync(); var data = GetRandomBuffer(Constants.KB); @@ -3866,7 +3849,7 @@ public async Task UploadPagesFromUriAsync_IfTagsFailed() // Act await TestHelper.AssertExpectedExceptionAsync( destBlob.UploadPagesFromUriAsync( - sourceUri: sourceBlob.Uri, + sourceUri: sourceBlob.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), sourceRange: range, range: range, options: options), @@ -3878,7 +3861,7 @@ await TestHelper.AssertExpectedExceptionAsync( public async Task UploadPagesFromUriAsync_SourceBearerToken() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -3918,7 +3901,7 @@ await destBlob.UploadPagesFromUriAsync( public async Task UploadPagesFromUriAsync_SourceBearerTokenFail() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -4148,7 +4131,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewSharedKeyCredentials(), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new BlobClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new BlobClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new BlobClientOptions()).Object; } [RecordedTest] diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs index 05b25ee26d1ab..66f6dd5ee9748 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs @@ -87,7 +87,7 @@ public void Ctor_TokenAuth_Http() // Act TestHelper.AssertExpectedException( - () => new BlobServiceClient(httpUri, Tenants.GetOAuthCredential()), + () => new BlobServiceClient(httpUri, TestEnvironment.Credential), new ArgumentException("Cannot use TokenCredential without HTTPS.")); } @@ -183,7 +183,7 @@ public async Task Ctor_DefaultAudience() BlobServiceClient aadService = InstrumentClient(new BlobServiceClient( new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -192,6 +192,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -202,7 +203,7 @@ public async Task Ctor_CustomAudience() BlobServiceClient aadService = InstrumentClient(new BlobServiceClient( new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -211,6 +212,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -221,7 +223,7 @@ public async Task Ctor_StorageAccountAudience() BlobServiceClient aadService = InstrumentClient(new BlobServiceClient( new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -664,7 +666,7 @@ public async Task GetStatisticsAsync() public async Task GetUserDelegationKey() { // Arrange - BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient service = GetServiceClient_OAuth(); // Act Response response = await service.GetUserDelegationKeyAsync(startsOn: null, expiresOn: Recording.UtcNow.AddHours(1)); @@ -689,7 +691,7 @@ await TestHelper.AssertExpectedExceptionAsync( public async Task GetUserDelegationKey_ArgumentException() { // Arrange - BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient service = GetServiceClient_OAuth(); // Act await TestHelper.AssertExpectedExceptionAsync( @@ -1260,7 +1262,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewSharedKeyCredentials(), new BlobClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new BlobClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new BlobClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new BlobClientOptions()).Object; } } } diff --git a/sdk/storage/Azure.Storage.Common/assets.json b/sdk/storage/Azure.Storage.Common/assets.json index b9ef2aaf4a108..8e6565c272d3e 100644 --- a/sdk/storage/Azure.Storage.Common/assets.json +++ b/sdk/storage/Azure.Storage.Common/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.Common", - "Tag": "net/storage/Azure.Storage.Common_bb1a2d2669" + "Tag": "net/storage/Azure.Storage.Common_f61db9baba" } diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/ClientBuilder.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/ClientBuilder.cs index 9155ca33a5ed5..a5f589c0f1470 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/ClientBuilder.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/ClientBuilder.cs @@ -137,11 +137,12 @@ public TServiceClient GetServiceClientFromSharedKeyConfig(TenantConfiguration co public TServiceClient GetServiceClientFromOauthConfig( TenantConfiguration config, + TokenCredential tokenCredential, TServiceClientOptions options = default) => AzureCoreRecordedTestBase.InstrumentClient( _getServiceClientTokenCredential( new Uri(GetEndpoint(config)), - Tenants.GetOAuthCredential(config), + tokenCredential, options ?? GetOptions())); public TServiceClientOptions GetOptions(bool parallelRange = false) diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/KeyVaultConfiguration.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/KeyVaultConfiguration.cs index aa329692928b3..f3d6f00710c4a 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/KeyVaultConfiguration.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/KeyVaultConfiguration.cs @@ -12,10 +12,6 @@ public class KeyVaultConfiguration { public string VaultName { get; private set; } public string VaultEndpoint { get; private set; } - public string ActiveDirectoryApplicationId { get; private set; } - public string ActiveDirectoryTenantId { get; private set; } - public string ActiveDirectoryApplicationSecret { get; private set; } - public string ActiveDirectoryAuthEndpoint { get; private set; } /// /// Parse an XML representation into a TenantConfiguration value. @@ -30,10 +26,6 @@ public static KeyVaultConfiguration Parse(XElement tenant) { VaultName = Get("VaultName"), VaultEndpoint = Get("VaultEndpoint"), - ActiveDirectoryApplicationId = Get("ActiveDirectoryApplicationId"), - ActiveDirectoryApplicationSecret = Get("ActiveDirectoryApplicationSecret"), - ActiveDirectoryTenantId = Get("ActiveDirectoryTenantId"), - ActiveDirectoryAuthEndpoint = Get("ActiveDirectoryAuthEndpoint") }; } } diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/ManagedDiskConfiguration.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/ManagedDiskConfiguration.cs index 3015ea5cbbba7..26152688b02bf 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/ManagedDiskConfiguration.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/ManagedDiskConfiguration.cs @@ -15,12 +15,6 @@ public class ManagedDiskConfiguration public string SubsriptionId { get; private set; } - public string ActiveDirectoryApplicationId { get; private set; } - - public string ActiveDirectoryApplicationSecret { get; private set; } - - public string ActiveDirectoryTenantId { get; private set; } - public string Location { get; private set; } public static ManagedDiskConfiguration Parse(XElement tenant) @@ -34,9 +28,6 @@ public static ManagedDiskConfiguration Parse(XElement tenant) ResourceGroupName = Get("ResourceGroupName"), SubsriptionId = Get("SubsriptionId"), Location = Get("Location"), - ActiveDirectoryApplicationId = Get("ActiveDirectoryApplicationId"), - ActiveDirectoryApplicationSecret = Get("ActiveDirectoryApplicationSecret"), - ActiveDirectoryTenantId = Get("ActiveDirectoryTenantId"), }; } } diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/SampleTest.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/SampleTest.cs index fab870de5c55b..aa103dc16f56a 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/SampleTest.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/SampleTest.cs @@ -46,26 +46,6 @@ public abstract class SampleTest /// public Uri StorageAccountFileUri => new Uri(TestConfigurations.DefaultTargetTenant.FileServiceEndpoint); - /// - /// Get an Active Directory Tenant ID to use from our test settings. - /// - public string ActiveDirectoryTenantId => TestConfigurations.DefaultTargetOAuthTenant.ActiveDirectoryTenantId; - - /// - /// Get an Active Directory Application ID to use from our test settings. - /// - public string ActiveDirectoryApplicationId => TestConfigurations.DefaultTargetOAuthTenant.ActiveDirectoryApplicationId; - - /// - /// Get an Active Directory Application Secret to use from our test settings. - /// - public string ActiveDirectoryApplicationSecret => TestConfigurations.DefaultTargetOAuthTenant.ActiveDirectoryApplicationSecret; - - /// - /// Get an Active Directory Auth Endpoint to use from our test settings. - /// - public Uri ActiveDirectoryAuthEndpoint => new Uri(TestConfigurations.DefaultTargetOAuthTenant.ActiveDirectoryAuthEndpoint); - /// /// Get a blob endpoint associated with our AD application from our test settings. /// diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs index a2050b43d9963..d48936904d7c2 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestBase.cs @@ -385,18 +385,10 @@ public async Task GetAuthToken(string[] scopes = default, TenantConfigur return "auth token"; } - tenantConfiguration ??= Tenants.TestConfigOAuth; - - IConfidentialClientApplication application = ConfidentialClientApplicationBuilder.Create(tenantConfiguration.ActiveDirectoryApplicationId) - .WithAuthority(AzureCloudInstance.AzurePublic, tenantConfiguration.ActiveDirectoryTenantId) - .WithClientSecret(tenantConfiguration.ActiveDirectoryApplicationSecret) - .Build(); - scopes ??= new string[] { "https://storage.azure.com/.default" }; - - AcquireTokenForClientParameterBuilder result = application.AcquireTokenForClient(scopes); - AuthenticationResult authenticationResult = await result.ExecuteAsync(); - return authenticationResult.AccessToken; + TokenRequestContext tokenRequestContext = new TokenRequestContext(scopes); + AccessToken accessToken = await TestEnvironment.Credential.GetTokenAsync(tokenRequestContext, CancellationToken.None); + return accessToken.Token; } public string CreateRandomDirectory(string parentPath, string directoryName = default) diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestEnvironment.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestEnvironment.cs index db13300df437b..4716aaabe69d4 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestEnvironment.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/StorageTestEnvironment.cs @@ -10,13 +10,5 @@ namespace Azure.Storage.Test.Shared { public class StorageTestEnvironment : TestEnvironment { - protected TokenCredential GetOAuthCredential(TenantConfiguration tenantConfiguration) - { - return new ClientSecretCredential( - tenantConfiguration.ActiveDirectoryTenantId, - tenantConfiguration.ActiveDirectoryApplicationId, - tenantConfiguration.ActiveDirectoryApplicationSecret, - new TokenCredentialOptions() { AuthorityHost = new Uri(tenantConfiguration.ActiveDirectoryAuthEndpoint) }); - } } } diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfiguration.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfiguration.cs index c7869136511a7..63ccb445a1f42 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfiguration.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfiguration.cs @@ -41,10 +41,6 @@ static TenantConfiguration() public string FileServiceSecondaryEndpoint { get; private set; } public string QueueServiceSecondaryEndpoint { get; private set; } public string TableServiceSecondaryEndpoint { get; private set; } - public string ActiveDirectoryApplicationId { get; private set; } - public string ActiveDirectoryApplicationSecret { get; private set; } - public string ActiveDirectoryTenantId { get; private set; } - public string ActiveDirectoryAuthEndpoint { get; private set; } public TenantType TenantType { get; private set; } public string ConnectionString { get; private set; } public string EncryptionScope { get; private set; } @@ -103,12 +99,6 @@ public static string Serialize(TenantConfiguration config, bool sanitize = true) config.FileServiceSecondaryEndpoint, config.QueueServiceSecondaryEndpoint, config.TableServiceSecondaryEndpoint, - config.ActiveDirectoryApplicationId, - !sanitize ? - config.ActiveDirectoryApplicationSecret : - SanitizeValue, - config.ActiveDirectoryTenantId, - config.ActiveDirectoryAuthEndpoint, config.TenantType.ToString(), !sanitize ? config.ConnectionString : @@ -158,15 +148,11 @@ public static TenantConfiguration Parse(string text) FileServiceSecondaryEndpoint = values[12], QueueServiceSecondaryEndpoint = values[13], TableServiceSecondaryEndpoint = values[14], - ActiveDirectoryApplicationId = values[15], - ActiveDirectoryApplicationSecret = values[16], - ActiveDirectoryTenantId = values[17], - ActiveDirectoryAuthEndpoint = values[18], - TenantType = ParseTenantType(values[19]), - ConnectionString = values[20], - EncryptionScope = values[21], - ResourceGroupName = values[22], - SubscriptionId = values[23] + TenantType = ParseTenantType(values[15]), + ConnectionString = values[16], + EncryptionScope = values[17], + ResourceGroupName = values[18], + SubscriptionId = values[19] }; } @@ -197,10 +183,6 @@ public static TenantConfiguration Parse(XElement tenant) FileSecurePortOverride = Get("FileSecurePortOverride"), QueueSecurePortOverride = Get("QueueSecurePortOverride"), TableSecurePortOverride = Get("TableSecurePortOverride"), - ActiveDirectoryApplicationId = Get("ActiveDirectoryApplicationId"), - ActiveDirectoryApplicationSecret = Get("ActiveDirectoryApplicationSecret"), - ActiveDirectoryTenantId = Get("ActiveDirectoryTenantId"), - ActiveDirectoryAuthEndpoint = Get("ActiveDirectoryAuthEndpoint"), ConnectionString = Get("ConnectionString"), EncryptionScope = Get("EncryptionScope"), ResourceGroupName = Get("ResourceGroupName"), diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfigurationBuilder.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfigurationBuilder.cs index 28fe3b221d9a9..4febb10d98b0d 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfigurationBuilder.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/TenantConfigurationBuilder.cs @@ -134,25 +134,6 @@ public StorageSharedKeyCredential GetNewHnsSharedKeyCredentials() TestConfigHierarchicalNamespace.AccountName, TestConfigHierarchicalNamespace.AccountKey); - public TokenCredential GetOAuthCredential() => - GetOAuthCredential(TestConfigOAuth); - - public TokenCredential GetOAuthCredential(TenantConfiguration config) => - GetOAuthCredential( - config.ActiveDirectoryTenantId, - config.ActiveDirectoryApplicationId, - config.ActiveDirectoryApplicationSecret, - new Uri(config.ActiveDirectoryAuthEndpoint)); - - public TokenCredential GetOAuthCredential(string tenantId, string appId, string secret, Uri authorityHost) => - Mode == RecordedTestMode.Playback ? - (TokenCredential)new StorageTestTokenCredential() : - new ClientSecretCredential( - tenantId, - appId, - secret, - new TokenCredentialOptions() { AuthorityHost = authorityHost }); - /// /// Get or create a test configuration tenant to use with our tests. /// diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/TestConfigurationsTemplate.xml b/sdk/storage/Azure.Storage.Common/tests/Shared/TestConfigurationsTemplate.xml index 46814daace44a..39fb972fb4efd 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/TestConfigurationsTemplate.xml +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/TestConfigurationsTemplate.xml @@ -13,181 +13,166 @@ - + ProductionTenant Cloud - [ACCOUNT] - [ACCOUNT-KEY] - http://[ACCOUNT].blob.core.windows.net - http://[ACCOUNT].queue.core.windows.net - http://[ACCOUNT].table.core.windows.net - http://[ACCOUNT].file.core.windows.net - http://[ACCOUNT]-secondary.blob.core.windows.net - http://[ACCOUNT]-secondary.queue.core.windows.net - http://[ACCOUNT]-secondary.file.core.windows.net - http://[ACCOUNT]-secondary.table.core.windows.net - DefaultEndpointsProtocol=https;AccountName=[ACCOUNT];AccountKey=[ACCOUNT-KEY];EndpointSuffix=core.windows.net - [encryption scope] + ACCOUNT + ACCOUNT-KEY + http://ACCOUNT.blob.core.windows.net + http://ACCOUNT.queue.core.windows.net + http://ACCOUNT.table.core.windows.net + http://ACCOUNT.file.core.windows.net + http://ACCOUNT-secondary.blob.core.windows.net + http://ACCOUNT-secondary.queue.core.windows.net + http://ACCOUNT-secondary.file.core.windows.net + http://ACCOUNT-secondary.table.core.windows.net + DefaultEndpointsProtocol=https;AccountName=ACCOUNT;AccountKey=ACCOUNT-KEY;EndpointSuffix=core.windows.net + encryption scope - + SecondaryTenant Cloud - [RAGRS-ACCOUNT] - [RAGRS-ACCOUNT-KEY] - http://[RAGRS-ACCOUNT].blob.core.windows.net - http://[RAGRS-ACCOUNT].queue.core.windows.net - http://[RAGRS-ACCOUNT].table.core.windows.net - http://[RAGRS-ACCOUNT].file.core.windows.net - http://[RAGRS-ACCOUNT]-secondary.blob.core.windows.net - http://[RAGRS-ACCOUNT]-secondary.queue.core.windows.net - http://[RAGRS-ACCOUNT]-secondary.file.core.windows.net - http://[RAGRS-ACCOUNT]-secondary.table.core.windows.net + RAGRS-ACCOUNT + RAGRS-ACCOUNT-KEY + http://RAGRS-ACCOUNT.blob.core.windows.net + http://RAGRS-ACCOUNT.queue.core.windows.net + http://RAGRS-ACCOUNT.table.core.windows.net + http://RAGRS-ACCOUNT.file.core.windows.net + http://RAGRS-ACCOUNT-secondary.blob.core.windows.net + http://RAGRS-ACCOUNT-secondary.queue.core.windows.net + http://RAGRS-ACCOUNT-secondary.file.core.windows.net + http://RAGRS-ACCOUNT-secondary.table.core.windows.net - + OAuthTenant Cloud - [OAUTH-ACCOUNT] - [OAUTH-ACCOUNT-KEY] - [OAUTH-RESOURCE-GROUP-NAME] - [OAUTH-SUBSCRIPTION-ID] + OAUTH-ACCOUNT + OAUTH-ACCOUNT-KEY + OAUTH-RESOURCE-GROUP-NAME + OAUTH-SUBSCRIPTION-ID - [ActiveDirectoryApplicationId] - [ActiveDirectoryApplicationSecret] - [ActiveDirectoryTenantId] - https://login.microsoftonline.com/ - - http://[OAUTH-ACCOUNT].blob.core.windows.net - http://[OAUTH-ACCOUNT].queue.core.windows.net - http://[OAUTH-ACCOUNT].table.core.windows.net - http://[OAUTH-ACCOUNT].file.core.windows.net - http://[OAUTH-ACCOUNT]-secondary.blob.core.windows.net - http://[OAUTH-ACCOUNT]-secondary.queue.core.windows.net - http://[OAUTH-ACCOUNT]-secondary.file.core.windows.net - http://[OAUTH-ACCOUNT]-secondary.table.core.windows.net + http://OAUTH-ACCOUNT.blob.core.windows.net + http://OAUTH-ACCOUNT.queue.core.windows.net + http://OAUTH-ACCOUNT.table.core.windows.net + http://OAUTH-ACCOUNT.file.core.windows.net + http://OAUTH-ACCOUNT-secondary.blob.core.windows.net + http://OAUTH-ACCOUNT-secondary.queue.core.windows.net + http://OAUTH-ACCOUNT-secondary.file.core.windows.net + http://OAUTH-ACCOUNT-secondary.table.core.windows.net - + PremiumBlobTenant Cloud - [PREMIUM-ACCOUNT] - [PREMIUM-ACCOUNT-KEY] - http://[PREMIUM-ACCOUNT].blob.core.windows.net - http://[PREMIUM-ACCOUNT].queue.core.windows.net - http://[PREMIUM-ACCOUNT].table.core.windows.net - http://[PREMIUM-ACCOUNT].file.core.windows.net - http://[PREMIUM-ACCOUNT]-secondary.blob.core.windows.net - http://[PREMIUM-ACCOUNT]-secondary.queue.core.windows.net - http://[PREMIUM-ACCOUNT]-secondary.file.core.windows.net - http://[PREMIUM-ACCOUNT]-secondary.table.core.windows.net + PREMIUM-ACCOUNT + PREMIUM-ACCOUNT-KEY + http://PREMIUM-ACCOUNT.blob.core.windows.net + http://PREMIUM-ACCOUNT.queue.core.windows.net + http://PREMIUM-ACCOUNT.table.core.windows.net + http://PREMIUM-ACCOUNT.file.core.windows.net + http://PREMIUM-ACCOUNT-secondary.blob.core.windows.net + http://PREMIUM-ACCOUNT-secondary.queue.core.windows.net + http://PREMIUM-ACCOUNT-secondary.file.core.windows.net + http://PREMIUM-ACCOUNT-secondary.table.core.windows.net - + NamespaceTenant Cloud - [NAMESPACE-ACCOUNT] - [NAMESPACE-ACCOUNT-KEY] + NAMESPACE-ACCOUNT + NAMESPACE-ACCOUNT-KEY - [ActiveDirectoryApplicationId] - [ActiveDirectoryApplicationSecret] - [ActiveDirectoryTenantId] - https://login.microsoftonline.com/ - - http://[NAMESPACE-ACCOUNT].blob.core.windows.net - http://[NAMESPACE-ACCOUNT].queue.core.windows.net - http://[NAMESPACE-ACCOUNT].table.core.windows.net - http://[NAMESPACE-ACCOUNT].file.core.windows.net - http://[NAMESPACE-ACCOUNT]-secondary.blob.core.windows.net - http://[NAMESPACE-ACCOUNT]-secondary.queue.core.windows.net - http://[NAMESPACE-ACCOUNT]-secondary.file.core.windows.net - http://[NAMESPACE-ACCOUNT]-secondary.table.core.windows.net + http://NAMESPACE-ACCOUNT.blob.core.windows.net + http://NAMESPACE-ACCOUNT.queue.core.windows.net + http://NAMESPACE-ACCOUNT.table.core.windows.net + http://NAMESPACE-ACCOUNT.file.core.windows.net + http://NAMESPACE-ACCOUNT-secondary.blob.core.windows.net + http://NAMESPACE-ACCOUNT-secondary.queue.core.windows.net + http://NAMESPACE-ACCOUNT-secondary.file.core.windows.net + http://NAMESPACE-ACCOUNT-secondary.table.core.windows.net + DefaultEndpointsProtocol=https;AccountName=ACCOUNT;AccountKey=ACCOUNT-KEY;EndpointSuffix=core.windows.net + encryption scope - + ManagedDiskTenant Cloud - [ACCOUNT] - [ACCOUNT-KEY] + ACCOUNT + ACCOUNT-KEY - http://[ACCOUNT].blob.core.windows.net - http://[ACCOUNT].queue.core.windows.net - http://[ACCOUNT].table.core.windows.net - http://[ACCOUNT].file.core.windows.net - http://[ACCOUNT]-secondary.blob.core.windows.net - http://[ACCOUNT]-secondary.queue.core.windows.net - http://[ACCOUNT]-secondary.file.core.windows.net - http://[ACCOUNT]-secondary.table.core.windows.net + http://ACCOUNT.blob.core.windows.net + http://ACCOUNT.queue.core.windows.net + http://ACCOUNT.table.core.windows.net + http://ACCOUNT.file.core.windows.net + http://ACCOUNT-secondary.blob.core.windows.net + http://ACCOUNT-secondary.queue.core.windows.net + http://ACCOUNT-secondary.file.core.windows.net + http://ACCOUNT-secondary.table.core.windows.net - + SoftDeleteTenant Cloud - [ACCOUNT] - [ACCOUNT-KEY] + ACCOUNT + ACCOUNT-KEY - http://[ACCOUNT].blob.core.windows.net - http://[ACCOUNT].queue.core.windows.net - http://[ACCOUNT].table.core.windows.net - http://[ACCOUNT].file.core.windows.net - http://[ACCOUNT]-secondary.blob.core.windows.net - http://[ACCOUNT]-secondary.queue.core.windows.net - http://[ACCOUNT]-secondary.file.core.windows.net - http://[ACCOUNT]-secondary.table.core.windows.net + http://ACCOUNT.blob.core.windows.net + http://ACCOUNT.queue.core.windows.net + http://ACCOUNT.table.core.windows.net + http://ACCOUNT.file.core.windows.net + http://ACCOUNT-secondary.blob.core.windows.net + http://ACCOUNT-secondary.queue.core.windows.net + http://ACCOUNT-secondary.file.core.windows.net + http://ACCOUNT-secondary.table.core.windows.net - + PremiumFileTenant Cloud - [ACCOUNT] - [ACCOUNT-KEY] + ACCOUNT + ACCOUNT-KEY - http://[ACCOUNT].blob.core.windows.net - http://[ACCOUNT].queue.core.windows.net - http://[ACCOUNT].table.core.windows.net - http://[ACCOUNT].file.core.windows.net - http://[ACCOUNT]-secondary.blob.core.windows.net - http://[ACCOUNT]-secondary.queue.core.windows.net - http://[ACCOUNT]-secondary.file.core.windows.net - http://[ACCOUNT]-secondary.table.core.windows.net + http://ACCOUNT.blob.core.windows.net + http://ACCOUNT.queue.core.windows.net + http://ACCOUNT.table.core.windows.net + http://ACCOUNT.file.core.windows.net + http://ACCOUNT-secondary.blob.core.windows.net + http://ACCOUNT-secondary.queue.core.windows.net + http://ACCOUNT-secondary.file.core.windows.net + http://ACCOUNT-secondary.table.core.windows.net ClientsideEncryptionKeyvault - https://[KEYVAULT NAME].vault.azure.net/ - [ActiveDirectoryApplicationId] - [ActiveDirectoryTenantId] - [ActiveDirectoryApplicationSecret] - https://login.microsoftonline.com/ + https://KEYVAULT NAME.vault.azure.net/ DefaultManagedDisk - [DISK NAME PREFIX] - [RESOURECE GROUP NAME] - [SubscriptionId] - [Location] - [ActiveDirectoryApplicationId] - [ActiveDirectoryApplicationSecret] - [ActiveDirectoryTenantId] + DISK NAME PREFIX + RESOURCE GROUP NAME + SubscriptionId + Location diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/assets.json b/sdk/storage/Azure.Storage.DataMovement.Blobs/assets.json index dd04f26a79a05..145d6241cb6a4 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/assets.json +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.DataMovement.Blobs", - "Tag": "net/storage/Azure.Storage.DataMovement.Blobs_db329f90cd" + "Tag": "net/storage/Azure.Storage.DataMovement.Blobs_602492e0c7" } diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ClientBuilderExtensions.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ClientBuilderExtensions.cs index 4e5c1d03ac65c..9972cb30afe75 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ClientBuilderExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ClientBuilderExtensions.cs @@ -51,7 +51,7 @@ public static async Task GetTestContainerAsync( if (publicAccessType == default) { - publicAccessType = premium ? PublicAccessType.None : PublicAccessType.BlobContainer; + publicAccessType = PublicAccessType.None; } BlobContainerClient container = clientBuilder.AzureCoreRecordedTestBase.InstrumentClient(service.GetBlobContainerClient(containerName)); diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/AppendBlobDirectoryToShareDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/AppendBlobDirectoryToShareDirectoryTests.cs index 48309e94ce832..9b967aba6fe3b 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/AppendBlobDirectoryToShareDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/AppendBlobDirectoryToShareDirectoryTests.cs @@ -147,14 +147,14 @@ protected override ShareClient GetOAuthDestinationContainerClient(string contain { ShareClientOptions options = DestinationClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetShareClient(containerName); } protected override BlobContainerClient GetOAuthSourceContainerClient(string containerName) { BlobClientOptions options = SourceClientBuilder.GetOptions(); - BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetBlobContainerClient(containerName); } diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/BlockBlobDirectoryToShareDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/BlockBlobDirectoryToShareDirectoryTests.cs index d3a3c8a3aee1f..cea5ea959beb8 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/BlockBlobDirectoryToShareDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/BlockBlobDirectoryToShareDirectoryTests.cs @@ -127,14 +127,14 @@ protected override ShareClient GetOAuthDestinationContainerClient(string contain { ShareClientOptions options = DestinationClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetShareClient(containerName); } protected override BlobContainerClient GetOAuthSourceContainerClient(string containerName) { BlobClientOptions options = SourceClientBuilder.GetOptions(); - BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetBlobContainerClient(containerName); } diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ClientBuilderExtensions.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ClientBuilderExtensions.cs index b1a2658271e52..2dbeb72fb9a96 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ClientBuilderExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ClientBuilderExtensions.cs @@ -19,6 +19,7 @@ using Azure.Storage.Files.Shares.Models; using Azure.Storage.Blobs; using Azure.Storage.Blobs.Models; +using Azure.Core; namespace Azure.Storage.DataMovement.Blobs.Files.Shares.Tests { @@ -68,11 +69,11 @@ public static ShareServiceClient GetServiceClient_OAuthAccount_SharedKey(this Sh clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigOAuth); public static ShareServiceClient GetServiceClient_OAuth( - this SharesClientBuilder clientBuilder, ShareClientOptions options = default) + this SharesClientBuilder clientBuilder, TokenCredential tokenCredential, ShareClientOptions options = default) { options ??= clientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - return clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, options); + return clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, tokenCredential, options); } public static async Task GetTestShareAsync( @@ -102,7 +103,7 @@ public static async Task GetTestContainerAsync( if (publicAccessType == default) { - publicAccessType = premium ? PublicAccessType.None : PublicAccessType.BlobContainer; + publicAccessType = PublicAccessType.None; } BlobContainerClient container = clientBuilder.AzureCoreRecordedTestBase.InstrumentClient(service.GetBlobContainerClient(containerName)); diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/PageBlobDirectoryToShareDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/PageBlobDirectoryToShareDirectoryTests.cs index 2c36c15dbc01d..176f5d84b1f2c 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/PageBlobDirectoryToShareDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/PageBlobDirectoryToShareDirectoryTests.cs @@ -147,14 +147,14 @@ protected override ShareClient GetOAuthDestinationContainerClient(string contain { ShareClientOptions options = DestinationClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetShareClient(containerName); } protected override BlobContainerClient GetOAuthSourceContainerClient(string containerName) { BlobClientOptions options = SourceClientBuilder.GetOptions(); - BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + BlobServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetBlobContainerClient(containerName); } diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToAppendBlobDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToAppendBlobDirectoryTests.cs index 72be0ae1d09a8..67e396d03a38f 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToAppendBlobDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToAppendBlobDirectoryTests.cs @@ -145,7 +145,7 @@ protected override StorageResourceContainer GetDestinationStorageResourceContain protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName) { BlobClientOptions options = DestinationClientBuilder.GetOptions(); - BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetBlobContainerClient(containerName); } @@ -153,7 +153,7 @@ protected override ShareClient GetOAuthSourceContainerClient(string containerNam { ShareClientOptions options = SourceClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetShareClient(containerName); } diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToBlockBlobDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToBlockBlobDirectoryTests.cs index 062448ba27a3b..fbc64029f46af 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToBlockBlobDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToBlockBlobDirectoryTests.cs @@ -126,7 +126,7 @@ protected override StorageResourceContainer GetDestinationStorageResourceContain protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName) { BlobClientOptions options = DestinationClientBuilder.GetOptions(); - BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetBlobContainerClient(containerName); } @@ -134,7 +134,7 @@ protected override ShareClient GetOAuthSourceContainerClient(string containerNam { ShareClientOptions options = SourceClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetShareClient(containerName); } diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToPageBlobDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToPageBlobDirectoryTests.cs index fdad2d1fb9ab6..9e4b04a777d11 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToPageBlobDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/BlobToFileSharesTests/ShareDirectoryToPageBlobDirectoryTests.cs @@ -146,7 +146,7 @@ protected override StorageResourceContainer GetDestinationStorageResourceContain protected override BlobContainerClient GetOAuthDestinationContainerClient(string containerName) { BlobClientOptions options = DestinationClientBuilder.GetOptions(); - BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + BlobServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetBlobContainerClient(containerName); } @@ -154,7 +154,7 @@ protected override ShareClient GetOAuthSourceContainerClient(string containerNam { ShareClientOptions options = SourceClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential,options); return oauthService.GetShareClient(containerName); } diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/assets.json b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/assets.json index 75adfb17d6cb4..1004d17f25436 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/assets.json +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.DataMovement.Files.Shares", - "Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_e86fda7f54" + "Tag": "net/storage/Azure.Storage.DataMovement.Files.Shares_feb44d2daa" } diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareDirectoryStartTransferCopyTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareDirectoryStartTransferCopyTests.cs index 76aea7538f6ed..077b01f442e86 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareDirectoryStartTransferCopyTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareDirectoryStartTransferCopyTests.cs @@ -96,7 +96,7 @@ protected override ShareClient GetOAuthSourceContainerClient(string containerNam { ShareClientOptions options = SourceClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = SourceClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetShareClient(containerName); } @@ -104,7 +104,7 @@ protected override ShareClient GetOAuthDestinationContainerClient(string contain { ShareClientOptions options = DestinationClientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, options); + ShareServiceClient oauthService = DestinationClientBuilder.GetServiceClientFromOauthConfig(Tenants.TestConfigOAuth, TestEnvironment.Credential, options); return oauthService.GetShareClient(containerName); } diff --git a/sdk/storage/Azure.Storage.DataMovement/assets.json b/sdk/storage/Azure.Storage.DataMovement/assets.json index e5124384f8fae..36fd6c0dffcfb 100644 --- a/sdk/storage/Azure.Storage.DataMovement/assets.json +++ b/sdk/storage/Azure.Storage.DataMovement/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.DataMovement", - "Tag": "net/storage/Azure.Storage.DataMovement_1fa7086be2" + "Tag": "net/storage/Azure.Storage.DataMovement_03db2933f4" } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs index 79c00a92e73b8..435bdf83267ac 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs @@ -16,6 +16,7 @@ using Azure.Storage.Blobs.Specialized; using Azure.Storage.Blobs.Tests; using Azure.Storage.DataMovement.Tests; +using Azure.Storage.Sas; using Azure.Storage.Test; using DMBlobs::Azure.Storage.DataMovement.Blobs; using Moq; @@ -532,7 +533,7 @@ await destinationResource.CopyFromStreamInternalAsync( public async Task CopyFromUriAsync() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); @@ -544,6 +545,10 @@ public async Task CopyFromUriAsync() await sourceClient.AppendBlockAsync(stream); } + sourceClient = InstrumentClient(new AppendBlobClient( + sourceClient.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + GetOptions())); + AppendBlobStorageResource sourceResource = new AppendBlobStorageResource(sourceClient); AppendBlobStorageResource destinationResource = new AppendBlobStorageResource(destinationClient); @@ -561,7 +566,7 @@ public async Task CopyFromUriAsync() public async Task CopyFromUriAsync_OAuth() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -605,7 +610,7 @@ await destinationResource.CopyFromUriAsync( public async Task CopyFromUriAsync_HttpAuthorization() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -943,7 +948,7 @@ await destinationResource.CopyFromUriInternalAsync( public async Task CopyFromUriAsync_Error() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); @@ -956,7 +961,7 @@ await TestHelper.AssertExpectedExceptionAsync( destinationResource.CopyFromUriAsync(sourceResource: sourceResource, overwrite:false, completeLength: length), e => { - Assert.IsTrue(e.Status == (int)HttpStatusCode.NotFound); + Assert.IsTrue(e.Status == (int)HttpStatusCode.Unauthorized); }); } @@ -964,7 +969,7 @@ await TestHelper.AssertExpectedExceptionAsync( public async Task CopyBlockFromUriAsync() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); await sourceClient.CreateIfNotExistsAsync(); AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); @@ -977,6 +982,9 @@ public async Task CopyBlockFromUriAsync() await sourceClient.AppendBlockAsync(stream); } + sourceClient = InstrumentClient(new AppendBlobClient( + sourceClient.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + GetOptions())); AppendBlobStorageResource sourceResource = new AppendBlobStorageResource(sourceClient); AppendBlobStorageResource destinationResource = new AppendBlobStorageResource(destinationClient); @@ -1002,7 +1010,7 @@ await destinationResource.CopyBlockFromUriAsync( public async Task CopyBlockFromUriAsync_OAuth() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -1067,7 +1075,7 @@ public async Task CopyBlockFromUriAsync_OAuth_Token() AppendBlobStorageResource destinationResource = new AppendBlobStorageResource(destinationClient); // Convert TokenCredential to HttpAuthorization - TokenCredential tokenCredential = Tenants.GetOAuthCredential(); + TokenCredential tokenCredential = TestEnvironment.Credential; string[] scopes = new string[] { "https://storage.azure.com/.default" }; AccessToken accessToken = await tokenCredential.GetTokenAsync(new TokenRequestContext(scopes), CancellationToken.None); StorageResourceCopyFromUriOptions options = new StorageResourceCopyFromUriOptions() @@ -1099,7 +1107,7 @@ await destinationResource.CopyBlockFromUriAsync( public async Task CopyBlockFromUriAsync_HttpAuthorization() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -1447,7 +1455,7 @@ await destinationResource.CopyBlockFromUriInternalAsync( public async Task CopyBlockFromUriAsync_Error() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName()); @@ -1679,7 +1687,7 @@ public async Task GetCopyAuthorizationHeaderAsync_OAuth() { // Arrange var containerName = GetNewContainerName(); - BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient service = GetServiceClient_OAuth(); await using DisposingContainer testContainer = await GetTestContainerAsync( service, containerName, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs index a91e7adb1dcab..f33d299deb0a4 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/BlockBlobStorageResourceTests.cs @@ -15,6 +15,7 @@ using Azure.Storage.Blobs.Specialized; using Azure.Storage.Blobs.Tests; using Azure.Storage.DataMovement.Tests; +using Azure.Storage.Sas; using Azure.Storage.Test; using DMBlobs::Azure.Storage.DataMovement.Blobs; using Microsoft.CodeAnalysis; @@ -441,7 +442,7 @@ public async Task CopyFromStreamAsync_SetAccessTier() public async Task CopyFromUriAsync() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); BlockBlobClient sourceClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); BlockBlobClient destinationClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); @@ -453,6 +454,10 @@ await sourceClient.UploadAsync( content: stream); } + sourceClient = InstrumentClient(new BlockBlobClient( + sourceClient.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + GetOptions())); + BlockBlobStorageResource sourceResource = new BlockBlobStorageResource(sourceClient); BlockBlobStorageResource destinationResource = new BlockBlobStorageResource(destinationClient); @@ -470,7 +475,7 @@ await sourceClient.UploadAsync( public async Task CopyFromUriAsync_OAuth() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -514,7 +519,7 @@ await destinationResource.CopyFromUriAsync( public async Task CopyFromUriAsync_HttpAuthorization() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -556,7 +561,7 @@ await destinationResource.CopyFromUriAsync( public async Task CopyFromUriAsync_Error() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); BlockBlobClient sourceClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); BlockBlobClient destinationClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); @@ -569,7 +574,7 @@ await TestHelper.AssertExpectedExceptionAsync( destinationResource.CopyFromUriAsync(sourceResource: sourceResource, overwrite: false, completeLength: length), e => { - Assert.IsTrue(e.Message.StartsWith("The specified blob does not exist.")); + Assert.IsTrue(e.Message.StartsWith("Server failed to authenticate the request. ")); }); } @@ -982,7 +987,7 @@ await destinationResource.CopyFromUriInternalAsync( public async Task CopyBlockFromUriAsync() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); BlockBlobClient sourceClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); BlockBlobClient destinationClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); @@ -995,6 +1000,10 @@ await sourceClient.UploadAsync( content: stream); } + sourceClient = InstrumentClient(new BlockBlobClient( + sourceClient.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + GetOptions())); + BlockBlobStorageResource sourceResource = new BlockBlobStorageResource(sourceClient); BlockBlobStorageResource destinationResource = new BlockBlobStorageResource(destinationClient); @@ -1083,7 +1092,7 @@ await sourceClient.UploadAsync( BlockBlobStorageResource destinationResource = new BlockBlobStorageResource(destinationClient); // Convert TokenCredential to HttpAuthorization - TokenCredential sourceBearerToken = Tenants.GetOAuthCredential(); + TokenCredential sourceBearerToken = TestEnvironment.Credential; string[] scopes = new string[] { "https://storage.azure.com/.default" }; AccessToken accessToken = await sourceBearerToken.GetTokenAsync(new TokenRequestContext(scopes), CancellationToken.None); StorageResourceCopyFromUriOptions options = new StorageResourceCopyFromUriOptions() @@ -1115,7 +1124,7 @@ await destinationResource.CopyBlockFromUriAsync( public async Task CopyBlockFromUriAsync_HttpAuthorization() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -1162,7 +1171,7 @@ await destinationResource.CopyBlockFromUriAsync( public async Task CopyBlockFromUriAsync_Error() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); BlockBlobClient sourceClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); BlockBlobClient destinationClient = testContainer.Container.GetBlockBlobClient(GetNewBlobName()); @@ -1721,7 +1730,7 @@ public async Task GetCopyAuthorizationHeaderAsync_OAuth() { // Arrange var containerName = GetNewContainerName(); - BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient service = GetServiceClient_OAuth(); await using DisposingContainer testContainer = await GetTestContainerAsync( service, containerName, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/ClientBuilderExtensions.cs b/sdk/storage/Azure.Storage.DataMovement/tests/ClientBuilderExtensions.cs index 9d1ae4a9521c8..fd236062c6775 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/ClientBuilderExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/ClientBuilderExtensions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Azure.Core; using Azure.Storage.Blobs; using Azure.Storage.Blobs.Tests; using Azure.Storage.Blobs.Models; @@ -57,8 +58,8 @@ public static BlobServiceClient GetServiceClient_PreviewAccount_SharedKey(this B public static BlobServiceClient GetServiceClient_PremiumBlobAccount_SharedKey(this BlobsClientBuilder clientBuilder) => clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigPremiumBlob); - public static BlobServiceClient GetServiceClient_OAuth(this BlobsClientBuilder clientBuilder) - => clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth); + public static BlobServiceClient GetServiceClient_OAuth(this BlobsClientBuilder clientBuilder, TokenCredential tokenCredential) + => clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, tokenCredential); public static BlobServiceClient GetServiceClient_OAuthAccount_SharedKey(this BlobsClientBuilder clientBuilder) => clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigOAuth); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs index 586da1bd66c72..a2820cac4d521 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/PageBlobStorageResourceTests.cs @@ -16,6 +16,7 @@ using Azure.Storage.Blobs.Specialized; using Azure.Storage.Blobs.Tests; using Azure.Storage.DataMovement.Tests; +using Azure.Storage.Sas; using Azure.Storage.Test; using DMBlobs::Azure.Storage.DataMovement.Blobs; using Moq; @@ -538,7 +539,7 @@ await destinationResource.CopyFromStreamInternalAsync( public async Task CopyFromUriAsync() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); PageBlobClient sourceClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); PageBlobClient destinationClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); @@ -551,6 +552,11 @@ await sourceClient.UploadPagesAsync( content: stream, offset: 0); } + + sourceClient = InstrumentClient(new PageBlobClient( + sourceClient.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + GetOptions())); + PageBlobStorageResource sourceResource = new PageBlobStorageResource(sourceClient); PageBlobStorageResource destinationResource = new PageBlobStorageResource(destinationClient); @@ -568,7 +574,7 @@ await sourceClient.UploadPagesAsync( public async Task CopyFromUriAsync_OAuth() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -615,7 +621,7 @@ await destinationResource.CopyFromUriAsync( public async Task CopyFromUriAsync_HttpAuthorization() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -971,7 +977,7 @@ await destinationResource.CopyFromUriInternalAsync( public async Task CopyFromUriAsync_Error() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); PageBlobClient sourceClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); PageBlobClient destinationClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); long length = Constants.KB; @@ -984,7 +990,7 @@ await TestHelper.AssertExpectedExceptionAsync( destinationResource.CopyFromUriAsync(sourceResource: sourceResource, overwrite: false, completeLength: length), e => { - Assert.IsTrue(e.Status == (int)HttpStatusCode.NotFound); + Assert.IsTrue(e.Status == (int)HttpStatusCode.Unauthorized); }); } @@ -992,7 +998,7 @@ await TestHelper.AssertExpectedExceptionAsync( public async Task CopyBlockFromUriAsync() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); PageBlobClient sourceClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); PageBlobClient destinationClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); @@ -1007,6 +1013,10 @@ await sourceClient.UploadPagesAsync( offset: 0); } + sourceClient = InstrumentClient(new PageBlobClient( + sourceClient.GenerateSasUri(BlobSasPermissions.Read, Recording.UtcNow.AddHours(1)), + GetOptions())); + PageBlobStorageResource sourceResource = new PageBlobStorageResource(sourceClient); PageBlobStorageResource destinationResource = new PageBlobStorageResource(destinationClient); @@ -1098,7 +1108,7 @@ await sourceClient.UploadPagesAsync( PageBlobStorageResource destinationResource = new PageBlobStorageResource(destinationClient); // Convert TokenCredential to HttpAuthorization - TokenCredential sourceBearerToken = Tenants.GetOAuthCredential(); + TokenCredential sourceBearerToken = TestEnvironment.Credential; string[] scopes = new string[] { "https://storage.azure.com/.default" }; AccessToken accessToken = await sourceBearerToken.GetTokenAsync(new TokenRequestContext(scopes), CancellationToken.None); StorageResourceCopyFromUriOptions options = new StorageResourceCopyFromUriOptions() @@ -1130,7 +1140,7 @@ await destinationResource.CopyBlockFromUriAsync( public async Task CopyBlockFromUriAsync_HttpAuthorization() { // Arrange - BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient serviceClient = GetServiceClient_OAuth(); await using DisposingContainer test = await GetTestContainerAsync( service: serviceClient, publicAccessType: PublicAccessType.None); @@ -1495,7 +1505,7 @@ await destinationResource.CopyBlockFromUriInternalAsync( public async Task CopyBlockFromUriAsync_Error() { // Arrange - await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer); + await using DisposingContainer testContainer = await GetTestContainerAsync(); PageBlobClient sourceClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); PageBlobClient destinationClient = testContainer.Container.GetPageBlobClient(GetNewBlobName()); @@ -1712,7 +1722,7 @@ public async Task GetCopyAuthorizationHeaderAsync_OAuth() { // Arrange var containerName = GetNewContainerName(); - BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient service = GetServiceClient_OAuth(); await using DisposingContainer testContainer = await GetTestContainerAsync( service, containerName, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/DataMovementBlobTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/DataMovementBlobTestBase.cs index d47bdaa57b156..c6b6a5e5cf369 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/DataMovementBlobTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/DataMovementBlobTestBase.cs @@ -104,11 +104,8 @@ private BlobServiceClient GetSecondaryReadServiceClient(TenantConfiguration conf options)); } - private static TokenCredential GetKeyClientTokenCredential(KeyVaultConfiguration config) - => new Identity.ClientSecretCredential( - config.ActiveDirectoryTenantId, - config.ActiveDirectoryApplicationId, - config.ActiveDirectoryApplicationSecret); + public BlobServiceClient GetServiceClient_OAuth() + => BlobsClientBuilder.GetServiceClient_OAuth(TestEnvironment.Credential); public BlobServiceClient GetServiceClient_BlobServiceSas_Container( string containerName, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs index 5589b66d57a4b..24b9990d569d2 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StartTransferSyncCopyDirectoryTests.cs @@ -486,7 +486,7 @@ public async Task BlockBlobDirectoryToDirectory_OAuth() // Arrange long size = Constants.KB; int waitTimeInSec = 10; - BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth(); + BlobServiceClient service = GetServiceClient_OAuth(); var containerName = GetNewContainerName(); await using DisposingContainer testContainer = await GetTestContainerAsync( service, diff --git a/sdk/storage/Azure.Storage.Files.DataLake/assets.json b/sdk/storage/Azure.Storage.Files.DataLake/assets.json index 9c7dfffe8d717..597d72370ca4a 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/assets.json +++ b/sdk/storage/Azure.Storage.Files.DataLake/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.Files.DataLake", - "Tag": "net/storage/Azure.Storage.Files.DataLake_aaa95f3b1a" + "Tag": "net/storage/Azure.Storage.Files.DataLake_133659189e" } diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/ClientBuilderExtensions.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/ClientBuilderExtensions.cs index 37fcd54f8072d..8a9ec7d5ecaa2 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/ClientBuilderExtensions.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/ClientBuilderExtensions.cs @@ -67,7 +67,7 @@ public static async Task GetNewFileSystem( if (publicAccessType == default) { - publicAccessType = premium ? PublicAccessType.None : PublicAccessType.FileSystem; + publicAccessType = PublicAccessType.None; } DataLakeFileSystemClient fileSystem = clientBuilder.AzureCoreRecordedTestBase.InstrumentClient(service.GetFileSystemClient(fileSystemName)); diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestBase.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestBase.cs index 8f69b5542d2dd..60221a7f78ed7 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestBase.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestBase.cs @@ -100,7 +100,7 @@ public DataLakeServiceClient GetServiceClientFromOauthConfig(TenantConfiguration => InstrumentClient( new DataLakeServiceClient( (new Uri(config.BlobServiceEndpoint)).ToHttps(), - Tenants.GetOAuthCredential(config), + TestEnvironment.Credential, GetOptions())); public DataLakeServiceClient GetServiceClient_OAuth() @@ -112,7 +112,7 @@ public StorageSharedKeyCredential GetStorageSharedKeyCredentials() TestConfigHierarchicalNamespace.AccountKey); public TokenCredential GetOAuthHnsCredential() - => Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace); + => TestEnvironment.Credential; public static void AssertValidStoragePathInfo(PathInfo pathInfo) { diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestEnvironment.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestEnvironment.cs index 7dd568f094dd3..b23d821344bfe 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestEnvironment.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/DataLakeTestEnvironment.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.IO; using System.Threading.Tasks; +using Azure.Core.TestFramework; using Azure.Storage.Blobs; using Azure.Storage.Blobs.Specialized; using Azure.Storage.Sas; @@ -32,8 +33,7 @@ private async Task DoesOAuthWorkAsync() // Check flat account. For some reason we observe failures if that one doesn't work before we start datalake run. { BlobServiceClient serviceClient = new BlobServiceClient( - new Uri(TestConfigurations.DefaultTargetOAuthTenant.BlobServiceEndpoint), - GetOAuthCredential(TestConfigurations.DefaultTargetOAuthTenant)); + new Uri(TestConfigurations.DefaultTargetOAuthTenant.BlobServiceEndpoint), Credential); await serviceClient.GetPropertiesAsync(); var containerName = Guid.NewGuid().ToString(); var containerClient = serviceClient.GetBlobContainerClient(containerName); @@ -64,8 +64,7 @@ private async Task DoesOAuthWorkAsync() // Check hierarchical account. { DataLakeServiceClient serviceClient = new DataLakeServiceClient( - new Uri(TestConfigurations.DefaultTargetHierarchicalNamespaceTenant.BlobServiceEndpoint), - GetOAuthCredential(TestConfigurations.DefaultTargetHierarchicalNamespaceTenant)); + new Uri(TestConfigurations.DefaultTargetHierarchicalNamespaceTenant.BlobServiceEndpoint), Credential); await serviceClient.GetPropertiesAsync(); var fileSystemName = Guid.NewGuid().ToString(); var fileSystemClient = serviceClient.GetFileSystemClient(fileSystemName); diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs index 94571d815ccbc..5364051fe5700 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs @@ -98,7 +98,7 @@ public async Task Ctor_TokenCredential() // Arrange await parentDirectory.CreateSubDirectoryAsync(directoryName); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{parentDirectoryName}/{directoryName}").ToHttps(); DataLakeDirectoryClient directoryClient = InstrumentClient(new DataLakeDirectoryClient(uri, tokenCredential, GetOptions())); @@ -158,7 +158,7 @@ public async Task Ctor_ConnectionString_GenerateSas() public void Ctor_TokenCredential_Http() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(TestConfigHierarchicalNamespace.BlobServiceEndpoint).ToHttp(); // Act @@ -251,6 +251,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -279,6 +280,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -933,7 +935,7 @@ public async Task CreateIfNotExistsAsync_Error() // Act await TestHelper.AssertExpectedExceptionAsync( unauthorizedDirecotry.CreateIfNotExistsAsync(), - e => Assert.AreEqual("AuthenticationFailed", e.ErrorCode)); + e => Assert.AreEqual("NoAuthenticationInformation", e.ErrorCode)); } [RecordedTest] @@ -1075,7 +1077,7 @@ public async Task DeleteIfNotExistsAsync_Error() // Act await TestHelper.AssertExpectedExceptionAsync( unauthorizedDirectory.DeleteIfExistsAsync(), - e => Assert.AreEqual("AuthenticationFailed", e.ErrorCode)); + e => Assert.AreEqual("NoAuthenticationInformation", e.ErrorCode)); } [RecordedTest] @@ -2606,7 +2608,7 @@ public async Task SetAccessControlRecursiveAsync_NetworkError() DataLakeDirectoryClient rootDirectory = test.FileSystem.GetRootDirectoryClient(); await rootDirectory.SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -2635,7 +2637,7 @@ public async Task SetAccessControlRecursiveAsync_TaskCanceledError() DataLakeDirectoryClient rootDirectory = test.FileSystem.GetRootDirectoryClient(); await rootDirectory.SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -2663,7 +2665,7 @@ public async Task SetAccessControlRecursiveAsync_Error() await using DisposingFileSystem test = await GetNewFileSystem(fileSystemName: fileSystemName); await test.FileSystem.GetRootDirectoryClient().SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -2891,7 +2893,7 @@ public async Task UpdateAccessControlRecursiveAsync_WithProgressMonitoring_WithF await using DisposingFileSystem test = await GetNewFileSystem(fileSystemName: fileSystemName); await test.FileSystem.GetRootDirectoryClient().SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -3314,7 +3316,7 @@ public async Task UpdateAccessControlRecursiveAsync_NetworkError() DataLakeDirectoryClient rootDirectory = test.FileSystem.GetRootDirectoryClient(); await rootDirectory.SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -3343,7 +3345,7 @@ public async Task UpdateAccessControlRecursiveAsync_TaskCanceledError() DataLakeDirectoryClient rootDirectory = test.FileSystem.GetRootDirectoryClient(); await rootDirectory.SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -3371,7 +3373,7 @@ public async Task UpdateAccessControlRecursiveAsync_Error() await using DisposingFileSystem test = await GetNewFileSystem(fileSystemName: fileSystemName); await test.FileSystem.GetRootDirectoryClient().SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -4017,7 +4019,7 @@ public async Task RemoveAccessControlRecursiveAsync_NetworkError() DataLakeDirectoryClient rootDirectory = test.FileSystem.GetRootDirectoryClient(); await rootDirectory.SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -4046,7 +4048,7 @@ public async Task RemoveAccessControlRecursiveAsync_TaskCanceledError() DataLakeDirectoryClient rootDirectory = test.FileSystem.GetRootDirectoryClient(); await rootDirectory.SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -4074,7 +4076,7 @@ public async Task RemoveAccessControlRecursiveAsync_Error() await using DisposingFileSystem test = await GetNewFileSystem(fileSystemName: fileSystemName); await test.FileSystem.GetRootDirectoryClient().SetAccessControlListAsync(ExecuteOnlyAccessControlList); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{topDirectoryName}").ToHttps(); // Create tree as AAD App @@ -6449,7 +6451,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewHnsSharedKeyCredentials(), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new DataLakeClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace), new DataLakeClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new DataLakeClientOptions()).Object; } } } diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs index 7af1076179718..dade8acee12f6 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs @@ -101,7 +101,7 @@ public async Task Ctor_TokenCredential() // Arrange await directory.CreateFileAsync(fileName); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{directoryName}/{fileName}").ToHttps(); DataLakeFileClient fileClient = InstrumentClient(new DataLakeFileClient(uri, tokenCredential, GetOptions())); @@ -120,7 +120,7 @@ public async Task Ctor_TokenCredential() public void Ctor_TokenCredential_Http() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(TestConfigHierarchicalNamespace.BlobServiceEndpoint).ToHttp(); // Act @@ -254,6 +254,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -282,6 +283,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -867,7 +869,7 @@ public async Task CreateIfNotExistsAsync_Error() // Act await TestHelper.AssertExpectedExceptionAsync( unauthorizedFile.CreateIfNotExistsAsync(), - e => Assert.AreEqual("AuthenticationFailed", e.ErrorCode)); + e => Assert.AreEqual("NoAuthenticationInformation", e.ErrorCode)); } [RecordedTest] @@ -1054,7 +1056,7 @@ public async Task DeleteIfNotExistsAsync_Error() // Act await TestHelper.AssertExpectedExceptionAsync( unauthorizedFile.DeleteIfExistsAsync(), - e => Assert.AreEqual("AuthenticationFailed", e.ErrorCode)); + e => Assert.AreEqual("NoAuthenticationInformation", e.ErrorCode)); } [RecordedTest] @@ -6016,7 +6018,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewHnsSharedKeyCredentials(), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new DataLakeClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace), new DataLakeClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new DataLakeClientOptions()).Object; } } } diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs index 4ba3de8f09d6c..797436ce368c6 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs @@ -92,7 +92,7 @@ public async Task Ctor_TokenCredential() try { - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}").ToHttps(); DataLakeFileSystemClient fileSystemClient = InstrumentClient(new DataLakeFileSystemClient(uri, tokenCredential, GetOptions())); @@ -171,7 +171,7 @@ public async Task Ctor_ConnectionString_GenerateSas() public void Ctor_TokenCredential_Http() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(TestConfigHierarchicalNamespace.BlobServiceEndpoint).ToHttp(); // Act @@ -257,6 +257,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -281,6 +282,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -523,6 +525,7 @@ public async Task CreateAsync_Metadata() } [RecordedTest] + [PlaybackOnly("Public access disabled on live test accounts.")] public async Task CreateAsync_PublicAccess() { // Arrange @@ -1110,13 +1113,13 @@ public async Task GetPathsAsync_NonHns() [RecordedTest] public async Task GetPropertiesAsync() { - await using DisposingFileSystem test = await GetNewFileSystem(publicAccessType: PublicAccessType.FileSystem); + await using DisposingFileSystem test = await GetNewFileSystem(); // Act Response response = await test.FileSystem.GetPropertiesAsync(); // Assert - Assert.AreEqual(PublicAccessType.FileSystem, response.Value.PublicAccess); + Assert.AreEqual(PublicAccessType.None, response.Value.PublicAccess); } [RecordedTest] @@ -2361,19 +2364,14 @@ public async Task SetAccessPolicyAsync() await using DisposingFileSystem test = await GetNewFileSystem(); // Arrange - PublicAccessType publicAccessType = PublicAccessType.FileSystem; DataLakeSignedIdentifier[] signedIdentifiers = BuildSignedIdentifiers(); // Act await test.FileSystem.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers ); // Assert - Response propertiesResponse = await test.FileSystem.GetPropertiesAsync(); - Assert.AreEqual(publicAccessType, propertiesResponse.Value.PublicAccess); - Response response = await test.FileSystem.GetAccessPolicyAsync(); Assert.AreEqual(1, response.Value.SignedIdentifiers.Count()); @@ -2417,6 +2415,7 @@ await TestHelper.AssertExpectedExceptionAsync( } [RecordedTest] + [PlaybackOnly("Public access disabled on live test accounts.")] public async Task SetAccessPolicy_PublicAccessPolicy() { await using DisposingFileSystem test = await GetNewFileSystem(); @@ -2585,7 +2584,6 @@ public async Task SetAccessPolicyAsync_StartsExpiresProperties() public async Task SetAccessPolicyAsync_Error() { // Arrange - PublicAccessType publicAccessType = PublicAccessType.FileSystem; DataLakeSignedIdentifier[] signedIdentifiers = BuildSignedIdentifiers(); DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeFileSystemClient fileSystem = InstrumentClient(service.GetFileSystemClient(GetNewFileSystemName())); @@ -2593,7 +2591,6 @@ public async Task SetAccessPolicyAsync_Error() // Act await TestHelper.AssertExpectedExceptionAsync( fileSystem.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers), e => Assert.AreEqual("ContainerNotFound", e.ErrorCode)); } @@ -2604,7 +2601,6 @@ public async Task SetAccessPolicyAsync_Conditions() foreach (AccessConditionParameters parameters in NoLease_Conditions_Data) { // Arrange - PublicAccessType publicAccessType = PublicAccessType.FileSystem; DataLakeSignedIdentifier[] signedIdentifiers = BuildSignedIdentifiers(); DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeFileSystemClient fileSystem = InstrumentClient(service.GetFileSystemClient(GetNewFileSystemName())); @@ -2617,7 +2613,6 @@ public async Task SetAccessPolicyAsync_Conditions() // Act Response response = await fileSystem.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers, conditions: conditions); @@ -2659,7 +2654,6 @@ public async Task SetAccessPolicyAsync_InvalidPermissionOrder() await using DisposingFileSystem test = await GetNewFileSystem(); // Arrange - PublicAccessType publicAccessType = PublicAccessType.FileSystem; DataLakeSignedIdentifier[] signedIdentifiers = new[] { new DataLakeSignedIdentifier @@ -2676,14 +2670,10 @@ public async Task SetAccessPolicyAsync_InvalidPermissionOrder() // Act await test.FileSystem.SetAccessPolicyAsync( - accessType: publicAccessType, permissions: signedIdentifiers ); // Assert - Response propertiesResponse = await test.FileSystem.GetPropertiesAsync(); - Assert.AreEqual(publicAccessType, propertiesResponse.Value.PublicAccess); - Response response = await test.FileSystem.GetAccessPolicyAsync(); Assert.AreEqual(1, response.Value.SignedIdentifiers.Count()); @@ -3344,7 +3334,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewHnsSharedKeyCredentials(), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new DataLakeClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace), new DataLakeClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new DataLakeClientOptions()).Object; } private IEnumerable Conditions_Data diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs index 5b79e62bab961..ba4a674bfa1db 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/PathClientTests.cs @@ -77,7 +77,7 @@ public async Task Ctor_TokenCredential() string directoryName = GetNewDirectoryName(); await test.FileSystem.CreateDirectoryAsync(directoryName); - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri($"{TestConfigHierarchicalNamespace.BlobServiceEndpoint}/{fileSystemName}/{directoryName}").ToHttps(); DataLakePathClient pathClient = InstrumentClient(new DataLakePathClient(uri, tokenCredential, GetOptions())); @@ -133,7 +133,7 @@ public async Task Ctor_ConnectionString_GenerateSas() public void Ctor_TokenCredential_Http() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(TestConfigHierarchicalNamespace.BlobServiceEndpoint).ToHttp(); // Act @@ -412,7 +412,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewHnsSharedKeyCredentials(), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new DataLakeClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace), new DataLakeClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new DataLakeClientOptions()).Object; } [RecordedTest] diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs index eddaab553871e..9d4227c73d613 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/ServiceClientTests.cs @@ -61,7 +61,7 @@ public async Task Ctor_SharedKey() public async Task Ctor_TokenCredential() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(TestConfigHierarchicalNamespace.BlobServiceEndpoint).ToHttps(); DataLakeServiceClient serviceClient = InstrumentClient(new DataLakeServiceClient(uri, tokenCredential, GetOptions())); @@ -131,7 +131,7 @@ public async Task Ctor_ConnectionString_GenerateSas() public void Ctor_TokenCredential_Http() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(TestConfigHierarchicalNamespace.BlobServiceEndpoint).ToHttp(); // Act @@ -211,6 +211,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -230,6 +231,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -1148,7 +1150,7 @@ public void CanMockClientConstructors() mock = new Mock(new Uri("https://test/test"), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), Tenants.GetNewHnsSharedKeyCredentials(), new DataLakeClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new DataLakeClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(TestConfigHierarchicalNamespace), new DataLakeClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), TestEnvironment.Credential, new DataLakeClientOptions()).Object; } } } diff --git a/sdk/storage/Azure.Storage.Files.Shares/assets.json b/sdk/storage/Azure.Storage.Files.Shares/assets.json index 84bc3ffca974c..028402c5d0c3a 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/assets.json +++ b/sdk/storage/Azure.Storage.Files.Shares/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.Files.Shares", - "Tag": "net/storage/Azure.Storage.Files.Shares_3d104d438e" + "Tag": "net/storage/Azure.Storage.Files.Shares_f7982e093b" } diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/ClientBuilderExtensions.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/ClientBuilderExtensions.cs index d264e2bfe616b..35f4f78c33aab 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ClientBuilderExtensions.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ClientBuilderExtensions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Azure.Core; using Azure.Storage.Files.Shares.Models; using Azure.Storage.Test.Shared; using ShareClientBuilder = Azure.Storage.Test.Shared.ClientBuilder< @@ -45,11 +46,11 @@ public static ShareServiceClient GetServiceClient_SharedKey(this ShareClientBuil => clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigDefault, options); public static ShareServiceClient GetServiceClient_OAuth( - this ShareClientBuilder clientBuilder, ShareClientOptions options = default) + this ShareClientBuilder clientBuilder, TokenCredential tokenCredential, ShareClientOptions options = default) { options ??= clientBuilder.GetOptions(); options.ShareTokenIntent = ShareTokenIntent.Backup; - return clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, options); + return clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, tokenCredential, options); } public static ShareServiceClient GetServiceClient_OAuthAccount_SharedKey(this ShareClientBuilder clientBuilder) => diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/CopySourceAuthTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/CopySourceAuthTests.cs index 9c257c24eb6c9..835591d681dff 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/CopySourceAuthTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/CopySourceAuthTests.cs @@ -32,7 +32,7 @@ public async Task UploadRangeFromUriAsync_SourceBearerToken() // Arrange BlobServiceClient blobServiceClient = InstrumentClient(new BlobServiceClient( new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint), - Tenants.GetOAuthCredential(Tenants.TestConfigOAuth), + TestEnvironment.Credential, GetBlobOptions())); BlobContainerClient containerClient = InstrumentClient(blobServiceClient.GetBlobContainerClient(GetNewShareName())); @@ -87,7 +87,7 @@ public async Task UploadRangeFromUriAsync_SourceBearerTokenFail() // Arrange BlobServiceClient blobServiceClient = InstrumentClient(new BlobServiceClient( new Uri(Tenants.TestConfigOAuth.BlobServiceEndpoint), - Tenants.GetOAuthCredential(Tenants.TestConfigOAuth), + TestEnvironment.Credential, GetBlobOptions())); BlobContainerClient containerClient = InstrumentClient(blobServiceClient.GetBlobContainerClient(GetNewShareName())); diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs index 9c30baaf95d6d..502e255f4a95c 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs @@ -123,7 +123,7 @@ public async Task Ctor_DefaultAudience() ShareDirectoryClient aadDirClient = InstrumentClient(new ShareDirectoryClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -132,6 +132,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -150,7 +151,7 @@ public async Task Ctor_CustomAudience() ShareDirectoryClient aadDirClient = InstrumentClient(new ShareDirectoryClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -159,6 +160,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -177,7 +179,7 @@ public async Task Ctor_StorageAccountAudience() ShareDirectoryClient aadDirClient = InstrumentClient(new ShareDirectoryClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -282,7 +284,7 @@ public async Task CreateAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -529,7 +531,7 @@ public async Task CreateIfNotExists_Error() // Act await TestHelper.AssertExpectedExceptionAsync( unauthorizedDirectory.CreateIfNotExistsAsync(), - e => Assert.AreEqual("ResourceNotFound", e.ErrorCode)); + e => Assert.AreEqual("NoAuthenticationInformation", e.ErrorCode)); } [RecordedTest] @@ -724,7 +726,7 @@ public async Task DeleteAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -792,7 +794,7 @@ public async Task GetPropertiesAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -907,7 +909,7 @@ public async Task SetHttpHeadersAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -1078,7 +1080,7 @@ public async Task SetMetadataAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -1197,7 +1199,7 @@ public async Task ListFilesAndDirectoriesSegmentAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -1449,7 +1451,7 @@ public async Task ListHandles_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -1517,7 +1519,7 @@ public async Task ForceCloseHandles_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -2413,7 +2415,7 @@ public async Task RenameAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); string destDirectoryName = GetNewDirectoryName(); diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs index f8d12a29c50f1..434f91a45f602 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/FileClientTests.cs @@ -128,7 +128,7 @@ public async Task Ctor_DefaultAudience() ShareFileClient aadFileClient = InstrumentClient(new ShareFileClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -137,6 +137,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -157,7 +158,7 @@ public async Task Ctor_CustomAudience() ShareFileClient aadFileClient = InstrumentClient(new ShareFileClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -166,6 +167,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -186,7 +188,7 @@ public async Task Ctor_StorageAccountAudience() ShareFileClient aadFileClient = InstrumentClient(new ShareFileClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -299,7 +301,7 @@ public async Task CreateAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -811,7 +813,7 @@ public async Task SetMetadataAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -939,7 +941,7 @@ public async Task GetPropertiesAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -1262,7 +1264,7 @@ public async Task SetHttpHeadersAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -1539,7 +1541,7 @@ public async Task DeleteAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -1653,7 +1655,7 @@ public async Task StartCopyAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -2251,7 +2253,7 @@ public async Task AbortCopyAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -2534,7 +2536,7 @@ public async Task DownloadAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -2857,7 +2859,7 @@ public async Task GetRangeListAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -3189,7 +3191,7 @@ public async Task GetRangeListDiffAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -3430,7 +3432,7 @@ public async Task UploadRangeAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -3695,7 +3697,7 @@ public async Task UploadAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -3951,7 +3953,7 @@ public async Task ClearRangeAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -4542,7 +4544,7 @@ public async Task UploadRangeFromUriAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); ShareClient oauthShareClient = InstrumentClient(oauthServiceClient.GetShareClient(shareName)); // Arrange @@ -4648,7 +4650,7 @@ public async Task ListHandles_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -4731,7 +4733,7 @@ public async Task ForceCloseHandles_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -4830,7 +4832,7 @@ public async Task AcquireLeaseAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -4922,7 +4924,7 @@ public async Task ReleaseLeaseAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -5022,7 +5024,7 @@ public async Task ChangeLeaseAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -5151,7 +5153,7 @@ public async Task BreakLeaseAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -5300,7 +5302,7 @@ public async Task OpenWriteAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); @@ -6305,7 +6307,7 @@ public async Task RenameAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); string directoryName = GetNewDirectoryName(); ShareDirectoryClient directory = InstrumentClient(oauthServiceClient.GetShareClient(shareName).GetDirectoryClient(directoryName)); diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/FileTestBase.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/FileTestBase.cs index 1e1ffb9e46275..a2b901bf2e383 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/FileTestBase.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/FileTestBase.cs @@ -107,6 +107,9 @@ public ShareServiceClient GetServiceClient_FileServiceSasFile(string shareName, new Uri($"{TestConfigDefault.FileServiceEndpoint}?{sasCredentials ?? GetNewFileServiceSasCredentialsFile(shareName, filePath, sharedKeyCredentials ?? Tenants.GetNewSharedKeyCredentials())}"), GetOptions())); + public ShareServiceClient GetServiceClient_OAuth() + => SharesClientBuilder.GetServiceClient_OAuth(TestEnvironment.Credential); + public SasQueryParameters GetNewAccountSasCredentials(StorageSharedKeyCredential sharedKeyCredentials = default, AccountSasResourceTypes resourceTypes = AccountSasResourceTypes.Container, AccountSasPermissions permissions = AccountSasPermissions.Create | AccountSasPermissions.Delete) diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs index 95d84b83fc57c..79a5a41809473 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs @@ -169,7 +169,7 @@ public async Task Ctor_DefaultAudience() ShareClient aadShare = InstrumentClient(new ShareClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -179,6 +179,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -194,7 +195,7 @@ public async Task Ctor_CustomAudience() ShareClient aadShare = InstrumentClient(new ShareClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -204,6 +205,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -219,7 +221,7 @@ public async Task Ctor_StorageAccountAudience() ShareClient aadShare = InstrumentClient(new ShareClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -465,7 +467,7 @@ public async Task CreateAndGetPermissionAsync_OAuth() string shareName = GetNewShareName(); ShareServiceClient sharedKeyServiceClient = SharesClientBuilder.GetServiceClient_OAuthAccount_SharedKey(); await using DisposingShare sharedKeyShare = await GetTestShareAsync(sharedKeyServiceClient, shareName); - ShareServiceClient oauthServiceClient = SharesClientBuilder.GetServiceClient_OAuth(); + ShareServiceClient oauthServiceClient = GetServiceClient_OAuth(); ShareClient share = oauthServiceClient.GetShareClient(shareName); // Arrange @@ -629,7 +631,7 @@ public async Task CreateIfNotExistsAsync_Error() // Act await TestHelper.AssertExpectedExceptionAsync( unauthorizesShareClient.CreateIfNotExistsAsync(), - e => Assert.AreEqual("ResourceNotFound", e.ErrorCode)); + e => Assert.AreEqual("NoAuthenticationInformation", e.ErrorCode)); } [RecordedTest] diff --git a/sdk/storage/Azure.Storage.Queues/assets.json b/sdk/storage/Azure.Storage.Queues/assets.json index bd4e0cd2b05bb..0e32fbc02a4bd 100644 --- a/sdk/storage/Azure.Storage.Queues/assets.json +++ b/sdk/storage/Azure.Storage.Queues/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/storage/Azure.Storage.Queues", - "Tag": "net/storage/Azure.Storage.Queues_ee3d77cf78" + "Tag": "net/storage/Azure.Storage.Queues_ef3164e0b2" } diff --git a/sdk/storage/Azure.Storage.Queues/tests/ClientBuilderExtensions.cs b/sdk/storage/Azure.Storage.Queues/tests/ClientBuilderExtensions.cs index 96a47b31d295b..2989caf9c96c8 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/ClientBuilderExtensions.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/ClientBuilderExtensions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Azure.Core; using QueuesClientBuilder = Azure.Storage.Test.Shared.ClientBuilder< Azure.Storage.Queues.QueueServiceClient, @@ -32,7 +33,7 @@ public static async Task GetTestQueueAsync( public static QueueServiceClient GetServiceClient_SharedKey(this QueuesClientBuilder clientBuilder, QueueClientOptions options = default) => clientBuilder.GetServiceClientFromSharedKeyConfig(clientBuilder.Tenants.TestConfigDefault, options); - public static QueueServiceClient GetServiceClient_OAuth(this QueuesClientBuilder clientBuilder, QueueClientOptions options = default) - => clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, options); + public static QueueServiceClient GetServiceClient_OAuth(this QueuesClientBuilder clientBuilder, TokenCredential tokenCredential, QueueClientOptions options = default) + => clientBuilder.GetServiceClientFromOauthConfig(clientBuilder.Tenants.TestConfigOAuth, tokenCredential, options); } } diff --git a/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs b/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs index 8ef3b3f3489ed..1010f466864ab 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs @@ -125,7 +125,7 @@ public void Ctor_Uri() public void Ctor_TokenCredential_Http() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(Tenants.TestConfigPremiumBlob.BlobServiceEndpoint).ToHttp(); // Act @@ -181,7 +181,7 @@ public async Task Ctor_DefaultAudience() QueueClient aadQueue = InstrumentClient(new QueueClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -190,6 +190,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -205,7 +206,7 @@ public async Task Ctor_CustomAudience() QueueClient aadQueue = InstrumentClient(new QueueClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -214,6 +215,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -229,7 +231,7 @@ public async Task Ctor_StorageAccountAudience() QueueClient aadQueue = InstrumentClient(new QueueClient( uriBuilder.ToUri(), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -310,7 +312,7 @@ public async Task CreateAsync_WithOauth() { // Arrange var queueName = GetNewQueueName(); - QueueServiceClient service = QueuesClientBuilder.GetServiceClient_OAuth(); + QueueServiceClient service = GetServiceClient_OAuth(); QueueClient queue = InstrumentClient(service.GetQueueClient(queueName)); try @@ -338,7 +340,7 @@ public async Task CreateAsync_WithOauthBearerChallenge() { Audience = QueueAudience.CreateQueueServiceAccountAudience("account"), }; - QueueServiceClient service = QueuesClientBuilder.GetServiceClient_OAuth(options); + QueueServiceClient service = GetServiceClient_OAuth(options); QueueClient queue = InstrumentClient(service.GetQueueClient(queueName)); try @@ -1968,13 +1970,14 @@ public async Task CanGetParentQueueServiceClient_WithAccountSAS() [RecordedTest] public void CanMockClientConstructors() { + TokenCredential mockTokenCredential = new Mock().Object; // One has to call .Object to trigger constructor. It's lazy. var mock = new Mock(TestConfigDefault.ConnectionString, "queuename", new QueueClientOptions()).Object; mock = new Mock(TestConfigDefault.ConnectionString, "queuename").Object; mock = new Mock(new Uri("https://test/test"), new QueueClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), GetNewSharedKeyCredentials(), new QueueClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new QueueClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new QueueClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), mockTokenCredential, new QueueClientOptions()).Object; } } } diff --git a/sdk/storage/Azure.Storage.Queues/tests/QueueTestBase.cs b/sdk/storage/Azure.Storage.Queues/tests/QueueTestBase.cs index 2059f6049bf8e..4f2e8094a8146 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/QueueTestBase.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/QueueTestBase.cs @@ -6,7 +6,6 @@ using System.Net; using System.Threading.Tasks; using Azure.Core; -using Azure.Core.Pipeline; using Azure.Core.TestFramework; using Azure.Storage.Queues.Models; using Azure.Storage.Sas; @@ -83,22 +82,22 @@ public QueueServiceClient GetServiceClient_QueueServiceSas(string queueName, Sto new Uri($"{TestConfigDefault.QueueServiceEndpoint}?{sasCredentials ?? GetNewQueueServiceSasCredentials(queueName, sharedKeyCredentials ?? GetNewSharedKeyCredentials())}"), GetOptions())); + public QueueServiceClient GetServiceClient_OAuth(QueueClientOptions options = default) + => QueuesClientBuilder.GetServiceClient_OAuth(TestEnvironment.Credential, options); + public Security.KeyVault.Keys.KeyClient GetKeyClient_TargetKeyClient() => GetKeyClient(TestConfigurations.DefaultTargetKeyVault); public TokenCredential GetTokenCredential_TargetKeyClient() => GetKeyClientTokenCredential(TestConfigurations.DefaultTargetKeyVault); - private static Security.KeyVault.Keys.KeyClient GetKeyClient(KeyVaultConfiguration config) + private Security.KeyVault.Keys.KeyClient GetKeyClient(KeyVaultConfiguration config) => new Security.KeyVault.Keys.KeyClient( new Uri(config.VaultEndpoint), GetKeyClientTokenCredential(config)); - private static TokenCredential GetKeyClientTokenCredential(KeyVaultConfiguration config) - => new Identity.ClientSecretCredential( - config.ActiveDirectoryTenantId, - config.ActiveDirectoryApplicationId, - config.ActiveDirectoryApplicationSecret); + private TokenCredential GetKeyClientTokenCredential(KeyVaultConfiguration config) + => TestEnvironment.Credential; public QueueServiceClient GetServiceClient_SecondaryAccount_ReadEnabledOnRetry(int numberOfReadFailuresToSimulate, out TestExceptionPolicy testExceptionPolicy, bool simulate404 = false) => GetSecondaryReadServiceClient(Tenants.TestConfigSecondary, numberOfReadFailuresToSimulate, out testExceptionPolicy, simulate404); diff --git a/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs b/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs index 9803bb34f07b9..140eb59095849 100644 --- a/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs +++ b/sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs @@ -53,7 +53,7 @@ public void Ctor_ConnectionString() public void Ctor_TokenCredential_Http() { // Arrange - TokenCredential tokenCredential = Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace); + TokenCredential tokenCredential = TestEnvironment.Credential; Uri uri = new Uri(Tenants.TestConfigPremiumBlob.BlobServiceEndpoint).ToHttp(); // Act @@ -115,7 +115,7 @@ public async Task Ctor_DefaultAudience() QueueServiceClient aadService = InstrumentClient(new QueueServiceClient( new Uri(Tenants.TestConfigOAuth.QueueServiceEndpoint), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -124,6 +124,7 @@ public async Task Ctor_DefaultAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_CustomAudience() { // Arrange @@ -134,7 +135,7 @@ public async Task Ctor_CustomAudience() QueueServiceClient aadService = InstrumentClient(new QueueServiceClient( new Uri(Tenants.TestConfigOAuth.QueueServiceEndpoint), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -143,6 +144,7 @@ public async Task Ctor_CustomAudience() } [RecordedTest] + [PlaybackOnly("https://github.com/Azure/azure-sdk-for-net/issues/44967")] public async Task Ctor_StorageAccountAudience() { // Arrange @@ -153,7 +155,7 @@ public async Task Ctor_StorageAccountAudience() QueueServiceClient aadService = InstrumentClient(new QueueServiceClient( new Uri(Tenants.TestConfigOAuth.QueueServiceEndpoint), - Tenants.GetOAuthCredential(), + TestEnvironment.Credential, options)); // Assert @@ -613,13 +615,14 @@ public void GenerateAccountSas_WrongService_Service() [RecordedTest] public void CanMockClientConstructors() { + TokenCredential mockTokenCredential = new Mock().Object; // One has to call .Object to trigger constructor. It's lazy. var mock = new Mock(TestConfigDefault.ConnectionString, new QueueClientOptions()).Object; mock = new Mock(TestConfigDefault.ConnectionString).Object; mock = new Mock(new Uri("https://test/test"), new QueueClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), GetNewSharedKeyCredentials(), new QueueClientOptions()).Object; mock = new Mock(new Uri("https://test/test"), new AzureSasCredential("foo"), new QueueClientOptions()).Object; - mock = new Mock(new Uri("https://test/test"), Tenants.GetOAuthCredential(Tenants.TestConfigHierarchicalNamespace), new QueueClientOptions()).Object; + mock = new Mock(new Uri("https://test/test"), mockTokenCredential, new QueueClientOptions()).Object; } } } diff --git a/sdk/storage/Azure.Storage.sln b/sdk/storage/Azure.Storage.sln index 19e368a8cb5a7..c8fe0e3b2fa6f 100644 --- a/sdk/storage/Azure.Storage.sln +++ b/sdk/storage/Azure.Storage.sln @@ -129,8 +129,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Storage.Blo EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Perf", "Perf", "{FBC7A205-B57A-44E7-A7CA-2E82F79A4D9C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.Storage", "Microsoft.Azure.Management.Storage\src\Microsoft.Azure.Management.Storage.csproj", "{AD469AF8-0675-4159-A5B7-F486E48B29CE}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Test.HttpRecorder", "..\mgmtcommon\TestFramework\Microsoft.Azure.Test.HttpRecorder\Microsoft.Azure.Test.HttpRecorder.csproj", "{11D040BC-3A89-4BA1-A2C7-90A83A872555}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Rest.ClientRuntime.Azure.TestFramework", "..\mgmtcommon\TestFramework\ClientRuntime.Azure.TestFramework\Microsoft.Rest.ClientRuntime.Azure.TestFramework.csproj", "{AC65C1AC-82F8-482B-B88D-FA9E752D1BC7}" @@ -163,6 +161,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Storage.DataMovement. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Storage.DataMovement.Blobs.Files.Shares.Tests", "Azure.Storage.DataMovement.Files.Shares\BlobToFileSharesTests\Azure.Storage.DataMovement.Blobs.Files.Shares.Tests.csproj", "{B08F17FE-7AFA-4777-B179-0FE15883EA50}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Storage", "Azure.ResourceManager.Storage\src\Azure.ResourceManager.Storage.csproj", "{6EA8939A-537F-475E-B16C-F9E80825C6AD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -357,6 +357,10 @@ Global {B08F17FE-7AFA-4777-B179-0FE15883EA50}.Debug|Any CPU.Build.0 = Debug|Any CPU {B08F17FE-7AFA-4777-B179-0FE15883EA50}.Release|Any CPU.ActiveCfg = Release|Any CPU {B08F17FE-7AFA-4777-B179-0FE15883EA50}.Release|Any CPU.Build.0 = Release|Any CPU + {6EA8939A-537F-475E-B16C-F9E80825C6AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6EA8939A-537F-475E-B16C-F9E80825C6AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6EA8939A-537F-475E-B16C-F9E80825C6AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6EA8939A-537F-475E-B16C-F9E80825C6AD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/sdk/storage/storage-preview-public-msft.json b/sdk/storage/storage-preview-public-msft.json new file mode 100644 index 0000000000000..e35b5b7a0cd51 --- /dev/null +++ b/sdk/storage/storage-preview-public-msft.json @@ -0,0 +1,9 @@ +{ + "SubscriptionId": "23fddbc8-cb64-4b59-ba97-4c9f77c212e4", + "TenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "TestApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360", + "TestApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f", + "ProvisionerApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360", + "ProvisionerApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f", + "Environment": "AzureCloud" +} \ No newline at end of file diff --git a/sdk/storage/test-resources-post.ps1 b/sdk/storage/test-resources-post.ps1 index 2d19759f5d82b..1e06d517ff3f8 100644 --- a/sdk/storage/test-resources-post.ps1 +++ b/sdk/storage/test-resources-post.ps1 @@ -7,10 +7,7 @@ # is finished being deployed. The ARM template is responsible for creating the Storage accounts needed for live tests. param ( - [hashtable] $DeploymentOutputs, - [string] $TenantId, - [string] $TestApplicationId, - [string] $TestApplicationSecret + [hashtable] $DeploymentOutputs ) # outputs from the ARM deployment passed in from New-TestResources @@ -109,12 +106,8 @@ $content = Cloud $PrimaryAccountName $PrimaryAccountKey - $TestApplicationId - $TestApplicationSecret - $StorageTenantId $ResourceGroupName $SubscriptionId - https://login.microsoftonline.com/ https://$PrimaryAccountName.$PrimaryAccountBlobEndpointSuffix https://$PrimaryAccountName.$PrimaryAccountQueueEndpointSuffix https://$PrimaryAccountName.$PrimaryAccountTableEndpointSuffix @@ -130,10 +123,6 @@ $content = Cloud $DataLakeAccountName $DataLakeAccountKey - $TestApplicationId - $TestApplicationSecret - $StorageTenantId - https://login.microsoftonline.com/ https://$DataLakeAccountName.$DataLakeAccountBlobEndpointSuffix https://$DataLakeAccountName.$DataLakeAccountQueueEndpointSuffix https://$DataLakeAccountName.$DataLakeAccountFileEndpointSuffix @@ -171,10 +160,6 @@ $content = ClientsideEncryptionKeyvault $KeyVaultUri - $TestApplicationId - $TestApplicationSecret - $StorageTenantId - https://login.microsoftonline.com/ @@ -184,9 +169,6 @@ $content = $ResourceGroupName $SubscriptionId $Location - $TestApplicationId - $TestApplicationSecret - $StorageTenantId " diff --git a/sdk/storage/tests.yml b/sdk/storage/tests.yml index 6d5100c41d3b1..afd0b6eacfdc2 100644 --- a/sdk/storage/tests.yml +++ b/sdk/storage/tests.yml @@ -12,6 +12,8 @@ extends: Preview: SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview) ServiceConnection: azure-sdk-tests + SubscriptionConfigurationFilePaths: + - sdk/storage/storage-preview-public-msft.json PrivatePreview: SubscriptionConfiguration: $(sub-config-storage-test-resources) Clouds: Preview @@ -30,6 +32,7 @@ extends: DYLD_LIBRARY_PATH: /usr/local/opt/openssl@3/lib ${{ if not(contains(variables['Build.DefinitionName'], 'tests-weekly')) }}: AZURE_ONLY_TEST_LATEST_SERVICE_VERSION: true + UseFederatedAuth: true TestSetupSteps: - template: /sdk/storage/tests-install-azurite.yml - bash: brew install openssl@3