diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 26ea558..176f62b 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -18,7 +18,7 @@ jobs: - name: 'Setup .NET' uses: actions/setup-dotnet@v3 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - name: 'Run tests' run: dotnet test --configuration Release diff --git a/Adliance.AzureBlobSimulator.sln b/Adliance.AzureBlobSimulator.sln deleted file mode 100644 index 67acffc..0000000 --- a/Adliance.AzureBlobSimulator.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adliance.AzureBlobSimulator", "src\Adliance.AzureBlobSimulator\Adliance.AzureBlobSimulator.csproj", "{94AF4640-39F3-45B0-80D7-B4E10746E63B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adliance.AzureBlobSimulator.Tests", "test\Adliance.AzureBlobSimulator.Tests\Adliance.AzureBlobSimulator.Tests.csproj", "{38867EAF-A4C4-4C69-B14F-F9CBA07D812C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F3A9EDE3-F084-4676-9063-B0A5F8DF4685}" - ProjectSection(SolutionItems) = preProject - README.md = README.md - .gitignore = .gitignore - dockerfile = dockerfile - docker-build-push.yml = .github/workflows/docker-build-push.yml - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {94AF4640-39F3-45B0-80D7-B4E10746E63B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {94AF4640-39F3-45B0-80D7-B4E10746E63B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {94AF4640-39F3-45B0-80D7-B4E10746E63B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {94AF4640-39F3-45B0-80D7-B4E10746E63B}.Release|Any CPU.Build.0 = Release|Any CPU - {38867EAF-A4C4-4C69-B14F-F9CBA07D812C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {38867EAF-A4C4-4C69-B14F-F9CBA07D812C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {38867EAF-A4C4-4C69-B14F-F9CBA07D812C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {38867EAF-A4C4-4C69-B14F-F9CBA07D812C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/Adliance.AzureBlobSimulator.slnx b/Adliance.AzureBlobSimulator.slnx new file mode 100644 index 0000000..81acc71 --- /dev/null +++ b/Adliance.AzureBlobSimulator.slnx @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/Adliance.AzureBlobSimulator/Adliance.AzureBlobSimulator.csproj b/src/Adliance.AzureBlobSimulator/Adliance.AzureBlobSimulator.csproj index c80a213..7c079b9 100644 --- a/src/Adliance.AzureBlobSimulator/Adliance.AzureBlobSimulator.csproj +++ b/src/Adliance.AzureBlobSimulator/Adliance.AzureBlobSimulator.csproj @@ -1,13 +1,10 @@ - - - net9.0 - enable - enable - - - - - - - + + net10.0 + enable + enable + + + + + \ No newline at end of file diff --git a/test/Adliance.AzureBlobSimulator.Tests/Adliance.AzureBlobSimulator.Tests.csproj b/test/Adliance.AzureBlobSimulator.Tests/Adliance.AzureBlobSimulator.Tests.csproj index 593a05a..6233bfc 100644 --- a/test/Adliance.AzureBlobSimulator.Tests/Adliance.AzureBlobSimulator.Tests.csproj +++ b/test/Adliance.AzureBlobSimulator.Tests/Adliance.AzureBlobSimulator.Tests.csproj @@ -1,35 +1,30 @@  - - net9.0 + net10.0 enable enable false - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + \ No newline at end of file diff --git a/test/Adliance.AzureBlobSimulator.Tests/Controllers/BlobControllerTests.cs b/test/Adliance.AzureBlobSimulator.Tests/Controllers/BlobControllerTests.cs index 53dfa84..57bebdb 100644 --- a/test/Adliance.AzureBlobSimulator.Tests/Controllers/BlobControllerTests.cs +++ b/test/Adliance.AzureBlobSimulator.Tests/Controllers/BlobControllerTests.cs @@ -70,7 +70,6 @@ public async Task Can_Get_Properties_of_Blob() var containerPath = Path.Combine(TestStoragePath, containerName); Directory.CreateDirectory(containerPath); await File.WriteAllBytesAsync(Path.Combine(containerPath, blobName), "Hello World!"u8.ToArray()); - ; var containerClient = BlobServiceClient.GetBlobContainerClient(containerName); var blobClient = containerClient.GetBlobClient(blobName); diff --git a/test/Adliance.AzureBlobSimulator.Tests/E2ETests.cs b/test/Adliance.AzureBlobSimulator.Tests/E2ETests.cs index d6e390c..51c0929 100644 --- a/test/Adliance.AzureBlobSimulator.Tests/E2ETests.cs +++ b/test/Adliance.AzureBlobSimulator.Tests/E2ETests.cs @@ -97,9 +97,9 @@ public async Task E2E_UploadAndDownloadBlob_ShouldSucceed() var blob = container.GetBlockBlobClient("file.txt"); const string txt = "This is a E2E test file which should be uploaded and downloaded by the simulator."; using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(txt)); - await blob.UploadAsync(stream); + await blob.UploadAsync(stream, cancellationToken: cts.Token); - var result = await blob.DownloadContentAsync(); + var result = await blob.DownloadContentAsync(cts.Token); Assert.Equal(txt, result.Value.Content.ToString()); } } diff --git a/test/Adliance.AzureBlobSimulator.Tests/SharedAccessSignature/SasAuthenticationMiddlewareTests.cs b/test/Adliance.AzureBlobSimulator.Tests/SharedAccessSignature/SasAuthenticationMiddlewareTests.cs index 56d2b2f..e474ca6 100644 --- a/test/Adliance.AzureBlobSimulator.Tests/SharedAccessSignature/SasAuthenticationMiddlewareTests.cs +++ b/test/Adliance.AzureBlobSimulator.Tests/SharedAccessSignature/SasAuthenticationMiddlewareTests.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; namespace Adliance.AzureBlobSimulator.Tests.SharedAccessSignature; @@ -20,41 +21,47 @@ public class SasAuthenticationMiddlewareTests public SasAuthenticationMiddlewareTests() { - var builder = new WebHostBuilder() - .ConfigureServices(services => + var host = new HostBuilder() + .ConfigureWebHost(webBuilder => { - services.Configure(options => - { - options.Accounts = - [ - new StorageAccountOptions + webBuilder + .UseTestServer() + .ConfigureServices(services => + { + services.Configure(options => { - Name = "testaccount", - Key = Convert.ToBase64String( - Encoding.UTF8.GetBytes("1234567890123456")) - } - ]; - }); - - services.AddSingleton(); - }) - .Configure(app => - { - app.UseMiddleware(); + options.Accounts = + [ + new StorageAccountOptions + { + Name = "testaccount", + Key = Convert.ToBase64String( + Encoding.UTF8.GetBytes("1234567890123456")) + } + ]; + }); + + services.AddSingleton(); + }) + .Configure(app => + { + app.UseMiddleware(); - app.Run(context => - { - context.Response.StatusCode = 200; - return Task.CompletedTask; - }); - }); + app.Run(context => + { + context.Response.StatusCode = 200; + return Task.CompletedTask; + }); + }); + }) + .Start(); - var server = new TestServer(builder); - _client = server.CreateClient(); + _client = host.GetTestClient(); + var options = host.Services.GetRequiredService>(); var env = new TestHostEnvironment(); - var options = server.Services.GetRequiredService>(); var validator = new SasValidatorService(options, null, env); + _sasHelper = new SasHelper(options, validator); }