Skip to content

Commit 2feda32

Browse files
authored
Adding test coverage for account SAS generated in different resource … (Azure#29422)
1 parent 407ce06 commit 2feda32

File tree

116 files changed

+17141
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+17141
-2
lines changed

sdk/storage/Azure.Storage.Blobs/tests/Azure.Storage.Blobs.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Microsoft.Azure.Management.Storage\src\Microsoft.Azure.Management.Storage.csproj" />
2020
</ItemGroup>
2121
<ItemGroup>
22+
<Compile Include="$(AzureStorageSharedTestSources)..\Sas\*.cs" LinkBase="Shared\Sas" />
2223
<Compile Include="$(AzureStorageSharedTestSources)\**\*.cs" LinkBase="Shared" />
2324
<None Include="$(AzureStorageSharedTestSources)\*.xml">
2425
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

sdk/storage/Azure.Storage.Blobs/tests/BlobSasTests.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Azure.Storage.Blobs.Tests;
1111
using Azure.Storage.Sas;
1212
using Azure.Storage.Test.Shared;
13+
using NUnit.Framework;
1314

1415
namespace Azure.Storage.Blobs.Test
1516
{
@@ -305,5 +306,73 @@ public async Task AccountSas_AllPermissions()
305306
AppendBlobClient sasBlobClient = InstrumentClient(new AppendBlobClient(blobUriBuilder.ToUri(), GetOptions()));
306307
await sasBlobClient.GetPropertiesAsync();
307308
}
309+
310+
private async Task InvokeAccountSasTest(
311+
string permissions = "rwdylacuptfi",
312+
string services = "bqtf",
313+
string resourceType = "sco")
314+
{
315+
// Arrange
316+
await using DisposingContainer test = await GetTestContainerAsync();
317+
string blobName = GetNewBlobName();
318+
AppendBlobClient blob = InstrumentClient(test.Container.GetAppendBlobClient(blobName));
319+
await blob.CreateAsync();
320+
321+
// Generate a SAS that would set the srt / ResourceTypes in a different order than
322+
// the .NET SDK would normally create the SAS
323+
TestAccountSasBuilder accountSasBuilder = new TestAccountSasBuilder(
324+
permissions: permissions,
325+
expiresOn: Recording.UtcNow.AddDays(1),
326+
services: services,
327+
resourceTypes: resourceType);
328+
329+
UriBuilder blobUriBuilder = new UriBuilder(blob.Uri)
330+
{
331+
Query = accountSasBuilder.ToTestSasQueryParameters(Tenants.GetNewSharedKeyCredentials()).ToString()
332+
};
333+
334+
// Assert
335+
AppendBlobClient sasBlobClient = InstrumentClient(new AppendBlobClient(blobUriBuilder.Uri, GetOptions()));
336+
await sasBlobClient.GetPropertiesAsync();
337+
}
338+
339+
[RecordedTest]
340+
[TestCase("sco")]
341+
[TestCase("soc")]
342+
[TestCase("cos")]
343+
[TestCase("ocs")]
344+
[TestCase("os")]
345+
[TestCase("oc")]
346+
[ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2020_06_12)]
347+
public async Task AccountSas_ResourceTypeOrder(string resourceType)
348+
{
349+
await InvokeAccountSasTest(resourceType: resourceType);
350+
}
351+
352+
[RecordedTest]
353+
[TestCase("bfqt")]
354+
[TestCase("qftb")]
355+
[TestCase("tqfb")]
356+
[TestCase("bqt")]
357+
[TestCase("qb")]
358+
[TestCase("fb")]
359+
[ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2020_06_12)]
360+
public async Task AccountSas_ServiceOrder(string services)
361+
{
362+
await InvokeAccountSasTest(services: services);
363+
}
364+
365+
[RecordedTest]
366+
[TestCase("rwdylacuptfi")]
367+
[TestCase("cuprwdylatfi")]
368+
[TestCase("cudypafitrwl")]
369+
[TestCase("cuprwdyla")]
370+
[TestCase("rywdlcaup")]
371+
[TestCase("larwdycup")]
372+
[ServiceVersion(Min = BlobClientOptions.ServiceVersion.V2020_06_12)]
373+
public async Task AccountSas_PermissionsOrder(string permissions)
374+
{
375+
await InvokeAccountSasTest(permissions: permissions);
376+
}
308377
}
309378
}

sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobSasTests/AccountSas_PermissionsOrder(%cudypafitrwl%).json

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/storage/Azure.Storage.Blobs/tests/SessionRecords/BlobSasTests/AccountSas_PermissionsOrder(%cudypafitrwl%)Async.json

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)