diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index 76e3088..4deaabb 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -42,14 +42,14 @@ jobs: - name: Run Unit Tests run: | echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" - dotnet test "TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj" --logger "trx;LogFileName=TransactionProcessorACL.Tests.trx" --results-directory "./TestResults" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" - dotnet test "TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj" --logger "trx;LogFileName=TransactionProcessorACL.BusinessLogic.Tests.trx" --results-directory "./TestResults" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov2.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" + dotnet test "TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj" --configuration Release --no-build --verbosity normal /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" -- --report-trx + dotnet test "TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj" --configuration Release --no-build --verbosity normal /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov2.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov" -- --report-trx - name: Build Docker Image run: docker build . --file TransactionProcessorACL/Dockerfile --tag transactionprocessoracl:latest - name: Run Integration Tests - run: dotnet test "TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj" --logger "trx;LogFileName=TransactionProcessorACL.IntegrationTests.trx" --results-directory "./TestResults" + run: dotnet test "TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj" --configuration Release --no-build --verbosity normal --results-directory "${{ github.workspace }}/TestResults" --settings "TransactionProcessorACL.IntegrationTests/Integration.runsettings" - uses: actions/upload-artifact@v4.4.0 if: always() @@ -57,7 +57,7 @@ jobs: name: tracelogs path: /home/runner/trace/ - - name: Publish test results + - name: Publish unit test results uses: dorny/test-reporter@v1 if: always() with: @@ -65,6 +65,15 @@ jobs: path: '**/TestResults/*.trx' reporter: dotnet-trx fail-on-error: false + + - name: Publish integration test results + uses: dorny/test-reporter@v1 + if: always() + with: + name: Integration Test Results + path: 'TestResults/TransactionProcessorACL.IntegrationTests.xml' + reporter: dotnet-nunit + fail-on-error: false - name: Upload test results uses: actions/upload-artifact@v4 @@ -74,6 +83,14 @@ jobs: path: '**/TestResults/*.trx' retention-days: 30 + - name: Upload integration test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: integration-test-results + path: 'TestResults/TransactionProcessorACL.IntegrationTests.xml' + retention-days: 30 + - name: Notify on nightly failure if: ${{ failure() }} uses: TransactionProcessing/org-ci-workflows/.github/actions/nightly-failure-issue@main diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index d2aeac4..715ceba 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -25,14 +25,14 @@ jobs: - name: Run Unit Tests run: | echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}" - dotnet test "TransactionProcessorACL.Tests\TransactionProcessorACL.Tests.csproj" --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=acl-test-results.trx" - dotnet test "TransactionProcessorACL.BusinessLogic.Tests\TransactionProcessorACL.BusinessLogic.Tests.csproj" --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=bl-test-results.trx" + dotnet test "TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj" --configuration Release --no-build --verbosity normal -- --report-trx + dotnet test "TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj" --configuration Release --no-build --verbosity normal -- --report-trx - name: Build Docker Image run: docker build . --file TransactionProcessorACL/Dockerfile --tag transactionprocessoracl:latest - name: Run Integration Tests - run: dotnet test "TransactionProcessorACL.IntegrationTests\TransactionProcessorACL.IntegrationTests.csproj" --filter Category=PRTest --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=integration-test-results.trx" + run: dotnet test "TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj" --filter "TestCategory=PRTest" --configuration Release --no-build --verbosity normal --results-directory "${{ github.workspace }}/TestResults" --settings "TransactionProcessorACL.IntegrationTests/Integration.runsettings" - uses: actions/upload-artifact@v4.4.0 if: always() @@ -40,7 +40,7 @@ jobs: name: tracelogs path: /home/runner/trace/ - - name: Publish test results + - name: Publish unit test results uses: dorny/test-reporter@v1 if: always() with: @@ -48,6 +48,15 @@ jobs: path: '**/TestResults/*.trx' reporter: dotnet-trx fail-on-error: true + + - name: Publish integration test results + uses: dorny/test-reporter@v1 + if: always() + with: + name: Integration Test Results + path: 'TestResults/TransactionProcessorACL.IntegrationTests.xml' + reporter: dotnet-nunit + fail-on-error: true - name: Upload test results uses: actions/upload-artifact@v4 @@ -56,3 +65,11 @@ jobs: name: test-results path: '**/TestResults/*.trx' retention-days: 30 + + - name: Upload integration test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: integration-test-results + path: 'TestResults/TransactionProcessorACL.IntegrationTests.xml' + retention-days: 30 diff --git a/Directory.Packages.props b/Directory.Packages.props index f5a6632..82e3f2e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ - + @@ -13,45 +13,46 @@ - + - - - - - - - - - - + + + + + + + + + + + - + - - + + - - - - - + + + + + - - + + - - - - - - - - + + + + + + + + diff --git a/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj b/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj index 05c2383..75f1969 100644 --- a/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj +++ b/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj @@ -4,6 +4,8 @@ net10.0 None false + Exe + true @@ -14,6 +16,7 @@ + diff --git a/TransactionProcessorACL.BusinessLogic.Tests/testconfig.json b/TransactionProcessorACL.BusinessLogic.Tests/testconfig.json new file mode 100644 index 0000000..8beb4a0 --- /dev/null +++ b/TransactionProcessorACL.BusinessLogic.Tests/testconfig.json @@ -0,0 +1,5 @@ +{ + "xUnit": { + "parallelizeTestCollections": false + } +} diff --git a/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs index 2acb6ff..a76d1c5 100644 --- a/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs +++ b/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs @@ -12,6 +12,7 @@ namespace TransactionProcessor.IntegrationTests.Common using System.Net.Http; using System.Threading; using System.Threading.Tasks; + using TestHosts.Clients; /// /// @@ -44,6 +45,8 @@ public class DockerHelper : global::Shared.IntegrationTesting.TestContainers.Doc public EventStoreProjectionManagementClient ProjectionManagementClient; + public IAgencyBankingClient AgencyBankingClient; + #endregion #region Constructors @@ -96,7 +99,8 @@ public override async Task StartContainersForScenarioRun(String scenarioName, Do String SecurityServiceBaseAddressResolver(String api) => $"https://127.0.0.1:{this.SecurityServicePort}"; String TransactionProcessorBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorPort}"; String TransactionProcessorAclBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TransactionProcessorAclPort}"; - + String TestHostServiceBaseAddressResolver(String api) => $"http://127.0.0.1:{this.TestHostServicePort}"; + HttpClientHandler clientHandler = new HttpClientHandler { ServerCertificateCustomValidationCallback = (message, @@ -113,6 +117,7 @@ public override async Task StartContainersForScenarioRun(String scenarioName, Do this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient, Serialise, Deserialise); this.TestHostHttpClient = new HttpClient(clientHandler); this.TestHostHttpClient.BaseAddress = new Uri($"http://127.0.0.1:{this.TestHostServicePort}"); + this.AgencyBankingClient = new AgencyBankingClient(TestHostServiceBaseAddressResolver, httpClient, Serialise_CamelCase, this.Deserialise_CamelCase); this.HttpClient = new HttpClient(); this.HttpClient.BaseAddress = new Uri(TransactionProcessorAclBaseAddressResolver(string.Empty)); @@ -131,6 +136,16 @@ Object Deserialise(String arg, Type type) return StringSerialiser.DeserializeObject(arg, type, new SerialiserOptions(SerialiserPropertyFormat.SnakeCase)); } + String Serialise_CamelCase(Object arg) + { + return StringSerialiser.Serialise(arg, new SerialiserOptions(SerialiserPropertyFormat.CamelCase)); + } + + Object Deserialise_CamelCase(String arg, Type type) + { + return StringSerialiser.DeserializeObject(arg, type, new SerialiserOptions(SerialiserPropertyFormat.CamelCase)); + } + public override Dictionary GetAdditionalVariables(ContainerType containerType) { Dictionary additionalVariables = base.GetAdditionalVariables(containerType); diff --git a/TransactionProcessorACL.IntegrationTests/Integration.runsettings b/TransactionProcessorACL.IntegrationTests/Integration.runsettings new file mode 100644 index 0000000..94fbaaf --- /dev/null +++ b/TransactionProcessorACL.IntegrationTests/Integration.runsettings @@ -0,0 +1,6 @@ + + + TransactionProcessorACL.IntegrationTests + UseResultDirectory + + diff --git a/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs b/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs index b282772..0209826 100644 --- a/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs +++ b/TransactionProcessorACL.IntegrationTests/Shared/SharedSteps.cs @@ -63,7 +63,8 @@ public SharedSteps(ScenarioContext scenarioContext, this.ScenarioContext = scenarioContext; this.TestingContext = testingContext; this.SecurityServiceSteps = new SecurityServiceSteps(testingContext.DockerHelper.SecurityServiceClient); - this.TransactionProcessorSteps = new TransactionProcessorSteps(testingContext.DockerHelper.TransactionProcessorClient, testingContext.DockerHelper.TestHostHttpClient, testingContext.DockerHelper.ProjectionManagementClient); + this.TransactionProcessorSteps = new TransactionProcessorSteps(testingContext.DockerHelper.TransactionProcessorClient, testingContext.DockerHelper.TestHostHttpClient, testingContext.DockerHelper.ProjectionManagementClient, + testingContext.DockerHelper.AgencyBankingClient); this.AclSteps = new ACLSteps(testingContext.DockerHelper.HttpClient, this.TestingContext.DockerHelper.TransactionProcessorClient); } @@ -322,7 +323,7 @@ public async Task WhenICreateTheFollowingEstates(DataTable table){ [When(@"I create the following merchants")] public async Task WhenICreateTheFollowingMerchants(DataTable table){ List estates = this.TestingContext.Estates.Select(e => e.EstateDetails).ToList(); - List<(EstateDetails estate, CreateMerchantRequest)> requests = table.Rows.ToCreateMerchantRequests(estates); + List<(EstateDetails estate, CreateMerchantRequest, Boolean EnableAgencyBanking)> requests = table.Rows.ToCreateMerchantRequests(estates); List verifiedMerchants = await this.TransactionProcessorSteps.WhenICreateTheFollowingMerchants(this.TestingContext.AccessToken, requests); diff --git a/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj b/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj index d6d883a..80f640d 100644 --- a/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj +++ b/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj @@ -4,6 +4,8 @@ net10.0 Full false + true + Exe diff --git a/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj b/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj index f172d64..269f591 100644 --- a/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj +++ b/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj @@ -4,6 +4,8 @@ net10.0 None false + Exe + true @@ -13,6 +15,7 @@ + diff --git a/global.json b/global.json new file mode 100644 index 0000000..7325398 --- /dev/null +++ b/global.json @@ -0,0 +1,9 @@ +{ + "sdk": { + "version": "10.0.302", + "rollForward": "latestFeature" + }, + "test": { + "runner": "Microsoft.Testing.Platform" + } +}