From 24d5d76782953e441ee3ea70c2ea06eb93a5c8bb Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 4 May 2023 11:38:21 +0100 Subject: [PATCH 01/17] Update to ASP.NET Core 8 preview 3 Update to preview 3 of ASP.NET Core 8. --- .vscode/launch.json | 2 +- Directory.Build.props | 2 +- global.json | 2 +- src/ApplePayJS/ApplePayJS.csproj | 2 +- src/ApplePayJS/package-lock.json | 2 +- src/ApplePayJS/package.json | 2 +- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 80daf82f..7591523d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,7 +6,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceRoot}/src/ApplePayJS/bin/Debug/net7.0/JustEat.ApplePayJS.dll", + "program": "${workspaceRoot}/src/ApplePayJS/bin/Debug/net8.0/JustEat.ApplePayJS.dll", "args": [], "cwd": "${workspaceRoot}/src/ApplePayJS", "stopAtEntry": false, diff --git a/Directory.Build.props b/Directory.Build.props index 8f7ab3e1..eb2fc0cb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,7 +15,7 @@ git $(PackageProjectUrl).git latest - 7.0.0 + 8.0.0 diff --git a/global.json b/global.json index f046bc4a..660d7f54 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.403", + "version": "8.0.100-preview.3.23178.7", "allowPrerelease": false } } diff --git a/src/ApplePayJS/ApplePayJS.csproj b/src/ApplePayJS/ApplePayJS.csproj index 407f9bd3..d6413004 100644 --- a/src/ApplePayJS/ApplePayJS.csproj +++ b/src/ApplePayJS/ApplePayJS.csproj @@ -12,7 +12,7 @@ applepay true JustEat.ApplePayJS - net7.0 + net8.0 latest JustEat.ApplePayJS diff --git a/src/ApplePayJS/package-lock.json b/src/ApplePayJS/package-lock.json index 94837c80..e47361a4 100644 --- a/src/ApplePayJS/package-lock.json +++ b/src/ApplePayJS/package-lock.json @@ -1,6 +1,6 @@ { "name": "justeatapplepayjs", - "version": "7.0.0", + "version": "8.0.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/src/ApplePayJS/package.json b/src/ApplePayJS/package.json index 8efd84f6..def338d4 100644 --- a/src/ApplePayJS/package.json +++ b/src/ApplePayJS/package.json @@ -1,7 +1,7 @@ { "name": "justeatapplepayjs", "private": true, - "version": "7.0.0", + "version": "8.0.0", "devDependencies": { "@types/applepayjs": "3.0.0", "@types/jquery": "3.3.34", diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index 38c0f6c6..2d7a25af 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 false @@ -11,7 +11,7 @@ - + From 3d64bafab95c94c50f5bdfeb3caf622d68f432b9 Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 4 May 2023 11:55:53 +0100 Subject: [PATCH 02/17] Disable ASP.NET Core certificate Disable generation of the ASP.NET Core HTTPS certificate to see if it fixes `net::ERR_CERT_DATABASE_CHANGED` error. --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ee7dbad..5c53283a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,6 +34,7 @@ jobs: run: ./build.ps1 env: DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_GENERATE_ASPNET_CERTIFICATE: false DOTNET_NOLOGO: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 From 9b85d8a2e9553f232da230e14df0d4025cb44500 Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 4 May 2023 12:05:01 +0100 Subject: [PATCH 03/17] Override ConfigureClient() Override `ConfigureClient()` to see if it fixes the certificate issues. --- tests/ApplePayJS.Tests/TestFixture.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/ApplePayJS.Tests/TestFixture.cs b/tests/ApplePayJS.Tests/TestFixture.cs index 7fd0a99f..8781c844 100644 --- a/tests/ApplePayJS.Tests/TestFixture.cs +++ b/tests/ApplePayJS.Tests/TestFixture.cs @@ -53,6 +53,11 @@ public override IServiceProvider Services } } + protected override void ConfigureClient(HttpClient client) + { + client.BaseAddress = ServerAddress; + } + protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices( From 0b163633e66d10600c44b0b6b70fd2a770f3734e Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 16 May 2023 18:12:00 +0100 Subject: [PATCH 04/17] Trigger for dotnet-vnext PRs Trigger workflows for pull requests to the `dotnet-vnext` branch. --- .github/workflows/approve-and-merge.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/code-ql.yml | 2 +- .github/workflows/dependency-review.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/approve-and-merge.yml b/.github/workflows/approve-and-merge.yml index 6579d707..c45b8316 100644 --- a/.github/workflows/approve-and-merge.yml +++ b/.github/workflows/approve-and-merge.yml @@ -2,7 +2,7 @@ name: approve-and-merge on: pull_request: - branches: [ main ] + branches: [ main, dotnet-vnext ] env: REVIEWER_LOGIN: ${{ vars.REVIEWER_USER_NAME }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c53283a..20925813 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: [ main ] pull_request: - branches: [ main ] + branches: [ main, dotnet-vnext ] jobs: build: diff --git a/.github/workflows/code-ql.yml b/.github/workflows/code-ql.yml index 52d28ea9..a63d1f0e 100644 --- a/.github/workflows/code-ql.yml +++ b/.github/workflows/code-ql.yml @@ -4,7 +4,7 @@ on: push: branches: [ main ] pull_request: - branches: [ main ] + branches: [ main, dotnet-vnext ] schedule: - cron: '0 6 * * MON' workflow_dispatch: diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index e729571f..a91246bf 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -2,7 +2,7 @@ name: dependency-review on: pull_request: - branches: [ main ] + branches: [ main, dotnet-vnext ] permissions: contents: read From 403f67b94ece78d98778efa98ff2276c0948d53b Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 17:13:05 +0000 Subject: [PATCH 05/17] Update .NET SDK Update .NET SDK to version 8.0.100-preview.4.23260.5. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 660d7f54..5e657a17 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-preview.3.23178.7", + "version": "8.0.100-preview.4.23260.5", "allowPrerelease": false } } From dd7e6f5e43c5c52a86b5eb0a44ba100acfa0d1a5 Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 17:13:43 +0000 Subject: [PATCH 06/17] Bump Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.3.23177.8 to 8.0.0-preview.4.23260.4 Bumps Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.3.23177.8 to 8.0.0-preview.4.23260.4. --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Mvc.Testing dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index 2d7a25af..aec907c3 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -11,7 +11,7 @@ - + From 7375da569166a9be5d70845218b95b0260f0f673 Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 18 May 2023 14:05:34 +0100 Subject: [PATCH 07/17] Remove redundant changes Remove changes that didn't fix the UI tests. --- .github/workflows/build.yml | 1 - tests/ApplePayJS.Tests/TestFixture.cs | 5 ----- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 20925813..d8216aa1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,6 @@ jobs: run: ./build.ps1 env: DOTNET_CLI_TELEMETRY_OPTOUT: true - DOTNET_GENERATE_ASPNET_CERTIFICATE: false DOTNET_NOLOGO: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 diff --git a/tests/ApplePayJS.Tests/TestFixture.cs b/tests/ApplePayJS.Tests/TestFixture.cs index 8781c844..7fd0a99f 100644 --- a/tests/ApplePayJS.Tests/TestFixture.cs +++ b/tests/ApplePayJS.Tests/TestFixture.cs @@ -53,11 +53,6 @@ public override IServiceProvider Services } } - protected override void ConfigureClient(HttpClient client) - { - client.BaseAddress = ServerAddress; - } - protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices( From 41fd1f724672734258ed518afba5f9ae2da912b8 Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:02:24 +0000 Subject: [PATCH 08/17] Update .NET SDK to 8.0.100-preview.5.23303.2 (#250) * Update .NET SDK Update .NET SDK to version 8.0.100-preview.5.23303.2. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> * Bump Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.4.23260.4 to 8.0.0-preview.5.23302.2 Bumps Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.4.23260.4 to 8.0.0-preview.5.23302.2. --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Mvc.Testing dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --------- Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Co-authored-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 5e657a17..b675391e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-preview.4.23260.5", + "version": "8.0.100-preview.5.23303.2", "allowPrerelease": false } } diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index aec907c3..271938d2 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -11,7 +11,7 @@ - + From 279b6a9b1cb4e13cbbe84058e460091c65898f9e Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 18:33:48 +0100 Subject: [PATCH 09/17] Update .NET SDK to 8.0.100-preview.6.23330.14 (#262) * Update .NET SDK Update .NET SDK to version 8.0.100-preview.6.23330.14. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> * Bump Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.5.23302.2 to 8.0.0-preview.6.23329.11 Bumps Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.5.23302.2 to 8.0.0-preview.6.23329.11. --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Mvc.Testing dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --------- Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Co-authored-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index b675391e..16064ed2 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-preview.5.23303.2", + "version": "8.0.100-preview.6.23330.14", "allowPrerelease": false } } diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index 271938d2..adcb9d8e 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -11,7 +11,7 @@ - + From bf13d13f5f1b72e7cdfeaef0442f640430638f4f Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:52:55 +0000 Subject: [PATCH 10/17] Update .NET SDK to 8.0.100-preview.7.23376.3 (#269) * Update .NET SDK Update .NET SDK to version 8.0.100-preview.7.23376.3. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> * Bump Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.6.23329.11 to 8.0.0-preview.7.23375.9 Bumps Microsoft.AspNetCore.Mvc.Testing from 8.0.0-preview.6.23329.11 to 8.0.0-preview.7.23375.9. --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Mvc.Testing dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --------- Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Co-authored-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 16064ed2..1b1d4721 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-preview.6.23330.14", + "version": "8.0.100-preview.7.23376.3", "allowPrerelease": false } } diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index adcb9d8e..d3a15743 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -11,7 +11,7 @@ - + From 57d6500b088fc9dd6f673991497aa6f6c90d3874 Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:32:15 +0000 Subject: [PATCH 11/17] Update .NET SDK (#288) Update .NET SDK to version 8.0.100-rc.1.23455.8. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Co-authored-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 1b1d4721..df98e2ff 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-preview.7.23376.3", + "version": "8.0.100-rc.1.23455.8", "allowPrerelease": false } } From 70fc171bbbe531b254f38d9a5ac3c3c66470b607 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Tue, 12 Sep 2023 18:46:49 +0100 Subject: [PATCH 12/17] Bump NuGet package Update M.A.Mvc.Testing for RC.1. --- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index d3a15743..f1ee28dd 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -11,7 +11,7 @@ - + From ab6d2ac553ffeb909619f4db42d6d1899ef525dd Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:09:58 +0000 Subject: [PATCH 13/17] Update .NET SDK (#289) Update .NET SDK to version 8.0.100-rc.1.23463.5. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Co-authored-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index df98e2ff..73edfd6d 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-rc.1.23455.8", + "version": "8.0.100-rc.1.23463.5", "allowPrerelease": false } } From a18cd4e717491ba5b6132c2eb6ff5eaa309b16a8 Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 30 Sep 2023 13:00:01 +0100 Subject: [PATCH 14/17] Use C# 12 features - Use primary constructors where relevant. - Use collection literals where relevant. - Simplify JSON serialization with `HttpClient`. - Fix some typos. - Fix indentation. --- src/ApplePayJS/Clients/ApplePayClient.cs | 22 +++----------- src/ApplePayJS/Clients/MerchantCertificate.cs | 9 ++---- src/ApplePayJS/Controllers/HomeController.cs | 29 ++++++------------- src/ApplePayJS/Program.cs | 2 +- tests/ApplePayJS.Tests/BrowserFixture.cs | 21 +++++--------- tests/ApplePayJS.Tests/IntegrationTests.cs | 18 ++++-------- tests/ApplePayJS.Tests/TestFixture.cs | 11 ++----- 7 files changed, 30 insertions(+), 82 deletions(-) diff --git a/src/ApplePayJS/Clients/ApplePayClient.cs b/src/ApplePayJS/Clients/ApplePayClient.cs index 19e866fd..27c5ca26 100644 --- a/src/ApplePayJS/Clients/ApplePayClient.cs +++ b/src/ApplePayJS/Clients/ApplePayClient.cs @@ -1,38 +1,24 @@ // Copyright (c) Just Eat, 2016. All rights reserved. // Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. -using System.Net.Mime; -using System.Text; using System.Text.Json; namespace JustEat.ApplePayJS.Clients; -public class ApplePayClient +public class ApplePayClient(HttpClient httpClient) { - private readonly HttpClient _httpClient; - - public ApplePayClient(HttpClient httpClient) - { - _httpClient = httpClient; - } - public async Task GetMerchantSessionAsync( Uri requestUri, MerchantSessionRequest request, CancellationToken cancellationToken = default) { // POST the data to create a valid Apple Pay merchant session. - string json = JsonSerializer.Serialize(request); - - using var content = new StringContent(json, Encoding.UTF8, MediaTypeNames.Application.Json); - - using var response = await _httpClient.PostAsync(requestUri, content, cancellationToken); + using var response = await httpClient.PostAsJsonAsync(requestUri, request, cancellationToken); response.EnsureSuccessStatusCode(); // Read the opaque merchant session JSON from the response body. - using var stream = await response.Content.ReadAsStreamAsync(); - - return await JsonDocument.ParseAsync(stream, cancellationToken: cancellationToken); + var merchantSession = await response.Content.ReadFromJsonAsync(cancellationToken); + return merchantSession!; } } diff --git a/src/ApplePayJS/Clients/MerchantCertificate.cs b/src/ApplePayJS/Clients/MerchantCertificate.cs index 5eccc1d9..28a8a5f2 100644 --- a/src/ApplePayJS/Clients/MerchantCertificate.cs +++ b/src/ApplePayJS/Clients/MerchantCertificate.cs @@ -8,14 +8,9 @@ namespace JustEat.ApplePayJS.Clients; -public class MerchantCertificate +public class MerchantCertificate(IOptions options) { - private readonly ApplePayOptions _options; - - public MerchantCertificate(IOptions options) - { - _options = options.Value; - } + private readonly ApplePayOptions _options = options.Value; public X509Certificate2 GetCertificate() { diff --git a/src/ApplePayJS/Controllers/HomeController.cs b/src/ApplePayJS/Controllers/HomeController.cs index 1d168056..829c404c 100644 --- a/src/ApplePayJS/Controllers/HomeController.cs +++ b/src/ApplePayJS/Controllers/HomeController.cs @@ -10,29 +10,18 @@ namespace JustEat.ApplePayJS.Controllers; using Microsoft.Extensions.Options; using Models; -public class HomeController : Controller +public class HomeController( + ApplePayClient client, + MerchantCertificate certificate, + IOptions options) : Controller { - private readonly ApplePayClient _client; - private readonly MerchantCertificate _certificate; - private readonly ApplePayOptions _options; - - public HomeController( - ApplePayClient client, - MerchantCertificate certificate, - IOptions options) - { - _client = client; - _certificate = certificate; - _options = options.Value; - } - public IActionResult Index() { // Get the merchant identifier and store name for use in the JavaScript by ApplePaySession. var model = new HomeModel() { - MerchantId = _certificate.GetMerchantIdentifier(), - StoreName = _options.StoreName, + MerchantId = certificate.GetMerchantIdentifier(), + StoreName = options.Value.StoreName, }; return View(model); @@ -56,13 +45,13 @@ public async Task Validate([FromBody] ValidateMerchantSessionMode // Create the JSON payload to POST to the Apple Pay merchant validation URL. var request = new MerchantSessionRequest() { - DisplayName = _options.StoreName, + DisplayName = options.Value.StoreName, Initiative = "web", InitiativeContext = Request.GetTypedHeaders().Host.Value, - MerchantIdentifier = _certificate.GetMerchantIdentifier(), + MerchantIdentifier = certificate.GetMerchantIdentifier(), }; - JsonDocument merchantSession = await _client.GetMerchantSessionAsync(requestUri, request, cancellationToken); + JsonDocument merchantSession = await client.GetMerchantSessionAsync(requestUri, request, cancellationToken); // Return the merchant session as-is to the JavaScript as JSON. return Json(merchantSession.RootElement); diff --git a/src/ApplePayJS/Program.cs b/src/ApplePayJS/Program.cs index 3ebee863..ede42a6c 100644 --- a/src/ApplePayJS/Program.cs +++ b/src/ApplePayJS/Program.cs @@ -40,7 +40,7 @@ var handler = new HttpClientHandler(); handler.ClientCertificates.Add(certificate); - // Apple Pay JS requires the use of at least TLS 1.2 to generate a merchange session: + // Apple Pay JS requires the use of at least TLS 1.2 to generate a merchant session: // https://developer.apple.com/documentation/applepayjs/setting_up_server_requirements // If you run an older operating system that does not negotiate this by default, uncomment the line below. // handler.SslProtocols = SslProtocols.Tls12; diff --git a/tests/ApplePayJS.Tests/BrowserFixture.cs b/tests/ApplePayJS.Tests/BrowserFixture.cs index 3ab813d9..1cb24401 100644 --- a/tests/ApplePayJS.Tests/BrowserFixture.cs +++ b/tests/ApplePayJS.Tests/BrowserFixture.cs @@ -8,17 +8,10 @@ namespace ApplePayJS.Tests; -internal sealed class BrowserFixture +internal sealed class BrowserFixture(ITestOutputHelper? outputHelper) { - public BrowserFixture(ITestOutputHelper? outputHelper) - { - OutputHelper = outputHelper; - } - private static bool IsRunningInGitHubActions { get; } = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS")); - private ITestOutputHelper? OutputHelper { get; } - public async Task WithPageAsync( Func action, string browserType = "chromium", @@ -32,8 +25,8 @@ public async Task WithPageAsync( IPage page = await browser.NewPageAsync(options); - page.Console += (_, e) => OutputHelper?.WriteLine(e.Text); - page.PageError += (_, e) => OutputHelper?.WriteLine(e); + page.Console += (_, e) => outputHelper?.WriteLine(e.Text); + page.PageError += (_, e) => outputHelper?.WriteLine(e); try { @@ -119,11 +112,11 @@ await page.ScreenshotAsync(new PageScreenshotOptions() Path = path, }); - OutputHelper?.WriteLine($"Screenshot saved to {path}."); + outputHelper?.WriteLine($"Screenshot saved to {path}."); } catch (Exception ex) { - OutputHelper?.WriteLine("Failed to capture screenshot: " + ex); + outputHelper?.WriteLine("Failed to capture screenshot: " + ex); } } @@ -152,11 +145,11 @@ private async Task TryCaptureVideoAsync( File.Move(videoSource, videoDestination); - OutputHelper?.WriteLine($"Video saved to {videoDestination}."); + outputHelper?.WriteLine($"Video saved to {videoDestination}."); } catch (Exception ex) { - OutputHelper?.WriteLine("Failed to capture video: " + ex); + outputHelper?.WriteLine("Failed to capture video: " + ex); } } } diff --git a/tests/ApplePayJS.Tests/IntegrationTests.cs b/tests/ApplePayJS.Tests/IntegrationTests.cs index 137778f2..9e3c8af5 100644 --- a/tests/ApplePayJS.Tests/IntegrationTests.cs +++ b/tests/ApplePayJS.Tests/IntegrationTests.cs @@ -9,17 +9,9 @@ namespace ApplePayJS.Tests; -public class IntegrationTests : IAsyncLifetime +public class IntegrationTests(ITestOutputHelper outputHelper) : IAsyncLifetime { - public IntegrationTests(ITestOutputHelper outputHelper) - { - Fixture = new TestFixture() - { - OutputHelper = outputHelper, - }; - } - - private TestFixture Fixture { get; } + private TestFixture Fixture { get; } = new() { OutputHelper = outputHelper }; public Task InitializeAsync() { @@ -64,7 +56,7 @@ await fixture.WithPageAsync(async (page) => await page.WaitForSelectorAsync(Selectors.CardName); await page.InnerTextAsync(Selectors.CardName).ShouldBe("American Express"); - foreach (string selector in new[] { Selectors.BillingContact, Selectors.ShipingContact }) + foreach (string selector in new[] { Selectors.BillingContact, Selectors.ShippingContact }) { var contact = await page.QuerySelectorAsync(selector); contact.ShouldNotBeNull(); @@ -79,7 +71,7 @@ await fixture.WithPageAsync(async (page) => private static void InstallPlaywright() { - int exitCode = Program.Main(new[] { "install" }); + int exitCode = Program.Main(["install"]); if (exitCode != 0) { @@ -94,6 +86,6 @@ private static class Selectors internal const string CardName = ".card-name"; internal const string ContactName = ".contact-name"; internal const string Pay = "id=apple-pay-button"; - internal const string ShipingContact = "id=shipping-contact"; + internal const string ShippingContact = "id=shipping-contact"; } } diff --git a/tests/ApplePayJS.Tests/TestFixture.cs b/tests/ApplePayJS.Tests/TestFixture.cs index 7fd0a99f..e51f8dfc 100644 --- a/tests/ApplePayJS.Tests/TestFixture.cs +++ b/tests/ApplePayJS.Tests/TestFixture.cs @@ -125,21 +125,14 @@ private void EnsureServer() } } - private sealed class HttpRequestInterceptionFilter : IHttpMessageHandlerBuilderFilter + private sealed class HttpRequestInterceptionFilter(HttpClientInterceptorOptions options) : IHttpMessageHandlerBuilderFilter { - internal HttpRequestInterceptionFilter(HttpClientInterceptorOptions options) - { - Options = options; - } - - private HttpClientInterceptorOptions Options { get; } - public Action Configure(Action next) { return (builder) => { next(builder); - builder.AdditionalHandlers.Add(Options.CreateHttpMessageHandler()); + builder.AdditionalHandlers.Add(options.CreateHttpMessageHandler()); }; } } From dc6a4cbd5815ada1a4b3f547a192f31e19b38915 Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 18:55:46 +0100 Subject: [PATCH 15/17] Update .NET SDK to 8.0.100-rc.2.23502.2 (#298) * Update .NET SDK Update .NET SDK to version 8.0.100-rc.2.23502.2. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> * Bump Microsoft.AspNetCore.Mvc.Testing from 8.0.0-rc.1.23421.29 to 8.0.0-rc.2.23480.2 Bumps Microsoft.AspNetCore.Mvc.Testing from 8.0.0-rc.1.23421.29 to 8.0.0-rc.2.23480.2. --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Mvc.Testing dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --------- Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Co-authored-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 73edfd6d..eb6291d4 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-rc.1.23463.5", + "version": "8.0.100-rc.2.23502.2", "allowPrerelease": false } } diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index f1ee28dd..c8d51e83 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -11,7 +11,7 @@ - + From 1aa9dfb008196647f87fe6b624962cea03f6c7b5 Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Sun, 5 Nov 2023 16:30:21 +0000 Subject: [PATCH 16/17] Use terminal logger Use the new MSBuild terminal logger. --- build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 3ad79968..d18be498 100755 --- a/build.ps1 +++ b/build.ps1 @@ -67,7 +67,7 @@ if (($installDotNetSdk -eq $true) -And ($null -eq $env:TF_BUILD)) { } Write-Host "Publishing application..." -ForegroundColor Green -& $dotnet publish (Join-Path $solutionPath "src" "ApplePayJS" "ApplePayJS.csproj") --output $OutputPath --configuration $Configuration +& $dotnet publish (Join-Path $solutionPath "src" "ApplePayJS" "ApplePayJS.csproj") --output $OutputPath --configuration $Configuration --tl $additionalArgs = @() @@ -77,7 +77,7 @@ if (![string]::IsNullOrEmpty($env:GITHUB_SHA)) { } Write-Host "Running tests..." -ForegroundColor Green -& $dotnet test (Join-Path $solutionPath "tests" "ApplePayJS.Tests" "ApplePayJS.Tests.csproj") --output $OutputPath --configuration $Configuration $additionalArgs +& $dotnet test (Join-Path $solutionPath "tests" "ApplePayJS.Tests" "ApplePayJS.Tests.csproj") --output $OutputPath --configuration $Configuration --tl $additionalArgs if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed with exit code $LASTEXITCODE" From d0b0eb162ca0f7eccd9954afad4126b0f05feedf Mon Sep 17 00:00:00 2001 From: "jet-codeflow-maintainer[bot]" <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:36:43 +0000 Subject: [PATCH 17/17] Update .NET SDK to 8.0.100 (#315) * Update .NET SDK Update .NET SDK to version 8.0.100. --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> * Bump Microsoft.AspNetCore.Mvc.Testing from 8.0.0-rc.2.23480.2 to 8.0.0 Bumps Microsoft.AspNetCore.Mvc.Testing from 8.0.0-rc.2.23480.2 to 8.0.0. --- updated-dependencies: - dependency-name: Microsoft.AspNetCore.Mvc.Testing dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --------- Signed-off-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> Co-authored-by: jet-codeflow-maintainer[bot] <131594757+jet-codeflow-maintainer[bot]@users.noreply.github.com> --- global.json | 2 +- tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index eb6291d4..9ee8ca78 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100-rc.2.23502.2", + "version": "8.0.100", "allowPrerelease": false } } diff --git a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj index c8d51e83..2c5b41bc 100644 --- a/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj +++ b/tests/ApplePayJS.Tests/ApplePayJS.Tests.csproj @@ -11,7 +11,7 @@ - +