diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc0683ed..496ea044 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: .Net on: push: branches: @@ -12,99 +12,120 @@ on: branches: - main env: - IS_RELEASE_CANDIDATE: >- - ${{ - ( - github.event_name == 'pull_request' && - startsWith(github.event.pull_request.title, 'RELEASES:') && - contains(github.event.pull_request.labels.*.name, 'RELEASES') - ) - || - ( - github.event_name == 'push' && - startsWith(github.event.head_commit.message, 'RELEASES:') && - github.ref_name == 'RELEASE' - ) - }} + MESHCONFIGURATION__URL: ${{ secrets.NEL_MESH_CLIENT_MESHCONFIGURATION__URL }} + MESHCONFIGURATION__MAILBOXID: ${{ secrets.NEL_MESH_CLIENT_MESHCONFIGURATION__MAILBOXID }} + MESHCONFIGURATION__PASSWORD: ${{ secrets.NEL_MESH_CLIENT_MESHCONFIGURATION__PASSWORD }} + MESHCONFIGURATION__KEY: ${{ secrets.NEL_MESH_CLIENT_MESHCONFIGURATION__SHAREDKEY }} + MESHCONFIGURATION__ROOTCERTIFICATE: ${{ secrets.NEL_MESH_CLIENT_MESHCONFIGURATION__TLSROOTCERTIFICATE }} + MESHCONFIGURATION__INTERMEDIATECERTIFICATES__0: ${{ secrets.NEL_MESH_CLIENT_MESHCONFIGURATION__TLSINTERMEDIATECERTIFICATES__0 }} + MESHCONFIGURATION__CLIENTCERTIFICATE: ${{ secrets.NEL_MESH_CLIENT_MESHCONFIGURATION__CLIENTSIGNINGCERTIFICATE }} jobs: build: - runs-on: ubuntu-latest - env: - NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__MAILBOXID: ${{ secrets.NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__MAILBOXID }} - NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__PASSWORD: ${{ secrets.NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__PASSWORD }} - NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__KEY: ${{ secrets.NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__KEY }} - NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__ROOTCERTIFICATE: ${{ secrets.NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__ROOTCERTIFICATE }} - NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__INTERMEDIATECERTIFICATES__0: ${{ secrets.NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__INTERMEDIATECERTIFICATES__0 }} - NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__CLIENTCERTIFICATE: ${{ secrets.NEL_MESH_CLIENT_ACCEPTANCE_MESHCONFIGURATION__CLIENTCERTIFICATE }} - NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__MAILBOXID: ${{ secrets.NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__MAILBOXID }} - NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__PASSWORD: ${{ secrets.NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__PASSWORD }} - NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__KEY: ${{ secrets.NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__KEY }} - NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__ROOTCERTIFICATE: ${{ secrets.NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__ROOTCERTIFICATE }} - NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__INTERMEDIATECERTIFICATES__0: ${{ secrets.NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__INTERMEDIATECERTIFICATES__0 }} - NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__CLIENTCERTIFICATE: ${{ secrets.NEL_MESH_CLIENT_INTEGRATION_MESHCONFIGURATION__CLIENTCERTIFICATE }} + name: Build + runs-on: windows-latest steps: - name: Check Out uses: actions/checkout@v3 - name: Setup Dot Net Version uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.0.101 + dotnet-version: 9.0.100 - name: Restore run: dotnet restore - name: Build run: dotnet build --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal + - name: Unit Tests + run: dotnet test NEL.Mesh.Tests.Unit/NEL.Mesh.Tests.Unit.csproj --no-build --verbosity normal + - name: Acceptance Tests + run: dotnet test NEL.MESH.Tests.Acceptance/NEL.MESH.Tests.Acceptance.csproj --no-build --verbosity normal + - name: Integration Tests + run: dotnet test NEL.MESH.Tests.Integration/NEL.MESH.Tests.Integration.csproj --no-build --verbosity normal add_tag: + name: Add Tag and Create Release runs-on: ubuntu-latest needs: - build - if: > - needs.build.result == 'success' && - github.event.pull_request.merged && - github.event.pull_request.base.ref == 'main' && - startsWith(github.event.pull_request.title, 'RELEASES:') && + if: >- + needs.build.result == 'success' && + + github.event.pull_request.merged && + + github.event.pull_request.base.ref == 'main' && + + startsWith(github.event.pull_request.title, 'RELEASES:') && + contains(github.event.pull_request.labels.*.name, 'RELEASES') steps: - name: Checkout code uses: actions/checkout@v3 - - name: Extract Version Number - id: extract_version - run: |- - echo "version_number=$(grep -oP '(?<=)[^<]+' NEL.MESH/NEL.MESH.csproj)" >> $GITHUB_OUTPUT - echo "package_release_notes=$(grep -oP '(?<=)[^<]+' NEL.MESH/NEL.MESH.csproj)" >> $GITHUB_OUTPUT - - name: Print Version Number - run: |- - echo "Release version - ${{ steps.extract_version.outputs.version_number }}" - echo "Release notes - ${{ steps.extract_version.outputs.package_release_notes }}" + with: + token: ${{ secrets.PAT_FOR_TAGGING }} - name: Configure Git - run: |- + run: >- git config user.name "GitHub Action" + git config user.email "action@github.com" - - name: Authenticate with GitHub - uses: actions/checkout@v3 - with: - token: ${{ secrets.PAT_FOR_TAGGING }} - - name: Add Release Tag - run: |- + - name: Extract Version + id: extract_version + run: > + # Running on Linux/Unix + + sudo apt-get install xmlstarlet + + version_number=$(xmlstarlet sel -t -v "//Version" -n ISL.ReIdentification.Core/ISL.ReIdentification.Core.csproj) + + echo "$version_number" + + echo "version_number<> $GITHUB_OUTPUT + + echo "$version_number" >> $GITHUB_OUTPUT + + echo "EOF" >> $GITHUB_OUTPUT + shell: bash + - name: Display Version + run: 'echo "Version number: ${{ steps.extract_version.outputs.version_number }}"' + - name: Extract Package Release Notes + id: extract_package_release_notes + run: > + # Running on Linux/Unix + + sudo apt-get install xmlstarlet + + package_release_notes=$(xmlstarlet sel -t -v "//PackageReleaseNotes" -n ISL.ReIdentification.Core/ISL.ReIdentification.Core.csproj) + + echo "$package_release_notes" + + echo "package_release_notes<> $GITHUB_OUTPUT + + echo "$package_release_notes" >> $GITHUB_OUTPUT + + echo "EOF" >> $GITHUB_OUTPUT + shell: bash + - name: Display Package Release Notes + run: 'echo "Package Release Notes: ${{ steps.extract_package_release_notes.outputs.package_release_notes }}"' + - name: Create GitHub Tag + run: >- git tag -a "v${{ steps.extract_version.outputs.version_number }}" -m "Release - v${{ steps.extract_version.outputs.version_number }}" + git push origin --tags - - name: Create release - id: create_release + - name: Create GitHub Release uses: actions/create-release@v1 + with: + tag_name: v${{ steps.extract_version.outputs.version_number }} + release_name: Release - v${{ steps.extract_version.outputs.version_number }} + body: >- + ## Release - v${{ steps.extract_version.outputs.version_number }} + + + ### Release Notes + + ${{ steps.extract_package_release_notes.outputs.package_release_notes }} env: GITHUB_TOKEN: ${{ secrets.PAT_FOR_TAGGING }} - with: - tag_name: "v${{ steps.extract_version.outputs.version_number }}" - release_name: "Release - v${{ steps.extract_version.outputs.version_number }}" - body: | - ### Release - v${{ steps.extract_version.outputs.version_number }} - - #### Release Notes - ${{ steps.extract_version.outputs.package_release_notes }} publish: + name: Publish to NuGet runs-on: ubuntu-latest - needs: + needs: - add_tag if: needs.add_tag.result == 'success' steps: @@ -113,15 +134,12 @@ jobs: - name: Setup .Net uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.201 + dotnet-version: 9.0.100 - name: Restore run: dotnet restore - - name: Build Release + - name: Build run: dotnet build --no-restore --configuration Release - - name: Pack Nuget - run: dotnet pack --configuration Release - env: - NUGET_KEY: ${{ secrets.NUGET_API_KEY }} - - name: Release Task - run: - dotnet nuget push **/bin/Release/**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} + - name: Pack NuGet Package + run: dotnet pack --configuration Release --include-symbols + - name: Push NuGet Package + run: dotnet nuget push **/bin/Release/**/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_ACCESS }} --skip-duplicate diff --git a/.github/workflows/prLinter.yml b/.github/workflows/prLinter.yml new file mode 100644 index 00000000..b1dfb03e --- /dev/null +++ b/.github/workflows/prLinter.yml @@ -0,0 +1,135 @@ +name: PR Linter +on: + pull_request: + types: + - opened + - edited + - synchronize + - reopened + - closed + branches: + - main +jobs: + label: + name: Add Label(s) + runs-on: ubuntu-latest + steps: + - name: Apply Label + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: >- + const prefixes = [ + 'INFRA:', + 'PROVISIONS:', + 'RELEASES:', + 'DATA:', + 'BROKERS:', + 'FOUNDATIONS:', + 'PROCESSINGS:', + 'ORCHESTRATIONS:', + 'COORDINATIONS:', + 'MANAGEMENTS:', + 'AGGREGATIONS:', + 'CONTROLLERS:', + 'CLIENTS:', + 'EXPOSERS:', + 'PROVIDERS:', + 'BASE:', + 'COMPONENTS:', + 'VIEWS:', + 'PAGES:', + 'ACCEPTANCE:', + 'INTEGRATIONS:', + 'CODE RUB:', + 'MINOR FIX:', + 'MEDIUM FIX:', + 'MAJOR FIX:', + 'DOCUMENTATION:', + 'CONFIG:', + 'STANDARD:', + 'DESIGN:', + 'BUSINESS:' + ]; + + + const pullRequest = context.payload.pull_request; + + + if (!pullRequest) { + console.log('No pull request context available.'); + return; + } + + + const title = context.payload.pull_request.title; + + const existingLabels = context.payload.pull_request.labels.map(label => label.name); + + + for (const prefix of prefixes) { + if (title.startsWith(prefix)) { + const label = prefix.slice(0, -1); + if (!existingLabels.includes(label)) { + console.log(`Applying label: ${label}`); + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: [label] + }); + } + break; + } + } + permissions: + contents: read + pull-requests: write + requireIssueOrTask: + name: Require Issue Or Task Association + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + - name: Get PR Information + id: get_pr_info + uses: actions/github-script@v6 + with: + script: >2- + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number + }); + + const prOwner = pr.data.user.login || ""; + const prBody = pr.data.body || ""; + core.setOutput("prOwner", prOwner); + core.setOutput("description", prBody); + console.log(`PR Owner: ${prOwner}`); + console.log(`PR Body: ${prBody}`); + - name: Check For Associated Issues Or Tasks + id: check_for_issues_or_tasks + if: ${{ steps.get_pr_info.outputs.prOwner != 'dependabot[bot]' }} + run: >2- + PR_BODY="${{ steps.get_pr_info.outputs.description }}" + echo "::notice::Raw PR Body: $PR_BODY" + + if [[ -z "$PR_BODY" ]]; then + echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')." + exit 1 + fi + + PR_BODY=$(echo "$PR_BODY" | tr -s '\r\n' ' ' | tr '\n' ' ' | xargs) + echo "::notice::Normalized PR Body: $PR_BODY" + + if echo "$PR_BODY" | grep -Piq "((close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[#\d+\]|\#\d+)|(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[AB#\d+\]|AB#\d+))"; then + echo "Valid PR description." + else + echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')." + exit 1 + fi + shell: bash + permissions: + contents: read + pull-requests: read diff --git a/.gitignore b/.gitignore index 4649a14a..c37f6691 100644 --- a/.gitignore +++ b/.gitignore @@ -374,3 +374,9 @@ local.appsettings.json /NEL.MESH.Tests.Acceptance/local.appsettings.integration.json /NEL.MESH.Tests.Integration/local.appsettings.integration.json /NEL.MESH.Tests.Integration/local.appsettings.acceptance.json +/NEL.MESH.Tests.Integration.Witness/appsettings.Development.json +/NEL.MESH.UI/appsettings.Development.json +/NEL.MESH.Tests.Integration/appsettings.Development.json +/NEL.MESH.Tests.Acceptance/appsettings.Development.json +/NEL.MESH/appsettings.Development.json +/NEL.MESH.UI/appsettings.Development.json diff --git a/NEL.MESH.Infrastructure/NEL.MESH.Infrastructure.csproj b/NEL.MESH.Infrastructure/NEL.MESH.Infrastructure.csproj index 5b18b8b3..25700690 100644 --- a/NEL.MESH.Infrastructure/NEL.MESH.Infrastructure.csproj +++ b/NEL.MESH.Infrastructure/NEL.MESH.Infrastructure.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 enable enable false @@ -10,7 +10,7 @@ - + diff --git a/NEL.MESH.Infrastructure/Program.cs b/NEL.MESH.Infrastructure/Program.cs index 2c51f6c1..aac9dbfe 100644 --- a/NEL.MESH.Infrastructure/Program.cs +++ b/NEL.MESH.Infrastructure/Program.cs @@ -11,7 +11,13 @@ internal class Program static void Main(string[] args) { var scriptGenerationService = new ScriptGenerationService(); - scriptGenerationService.GenerateBuildScript(); + + scriptGenerationService.GenerateBuildScript( + branchName: "main", + projectName: "ISL.ReIdentification.Core", + dotNetVersion: "9.0.100"); + + scriptGenerationService.GeneratePrLintScript("main"); } } } \ No newline at end of file diff --git a/NEL.MESH.Infrastructure/Services/ScriptGenerationService.cs b/NEL.MESH.Infrastructure/Services/ScriptGenerationService.cs index a567dd67..f422c397 100644 --- a/NEL.MESH.Infrastructure/Services/ScriptGenerationService.cs +++ b/NEL.MESH.Infrastructure/Services/ScriptGenerationService.cs @@ -16,7 +16,7 @@ internal class ScriptGenerationService public ScriptGenerationService() => this.adotNetClient = new ADotNetClient(); - public void GenerateBuildScript() + public void GenerateBuildScript(string branchName, string projectName, string dotNetVersion) { var githubPipeline = new GithubPipeline { @@ -24,23 +24,33 @@ public void GenerateBuildScript() OnEvents = new Events { - Push = new PushEvent - { - Branches = new string[] { "main" } - }, + Push = new PushEvent { Branches = [branchName] }, PullRequest = new PullRequestEvent { - Branches = new string[] { "main" } + Types = ["opened", "synchronize", "reopened", "closed"], + Branches = [branchName] } }, + EnvironmentVariables = new Dictionary + { + { "MESHCONFIGURATION__URL", "${{ secrets.MESHCONFIGURATION__URL }}"}, + { "MESHCONFIGURATION__MAILBOXID", "${{ secrets.MESHCONFIGURATION__MAILBOXID }}"}, + { "MESHCONFIGURATION__PASSWORD", "${{ secrets.MESHCONFIGURATION__PASSWORD }}"}, + { "MESHCONFIGURATION__SHAREDKEY", "${{ secrets.MESHCONFIGURATION__SHAREDKEY }}"}, + { "MESHCONFIGURATION__TLSROOTCERTIFICATES__0", "${{ secrets.MESHCONFIGURATION__TLSROOTCERTIFICATES__0 }}"}, + { "MESHCONFIGURATION__TLSINTERMEDIATECERTIFICATES__0", "${{ secrets.MESHCONFIGURATION__TLSINTERMEDIATECERTIFICATES__0 }}"}, + { "MESHCONFIGURATION__CLIENTSIGNINGCERTIFICATE", "${{ secrets.MESHCONFIGURATION__CLIENTSIGNINGCERTIFICATE }}" }, + }, + Jobs = new Dictionary { { "build", new Job { + Name = "Build", RunsOn = BuildMachines.WindowsLatest, Steps = new List @@ -56,8 +66,8 @@ public void GenerateBuildScript() With = new TargetDotNetVersionV3 { - DotNetVersion = "7.0.201" - } + DotNetVersion = dotNetVersion +} }, new RestoreTask @@ -72,10 +82,46 @@ public void GenerateBuildScript() new TestTask { - Name = "Test" + Name = "Unit Tests", + Run = "dotnet test NEL.Mesh.Tests.Unit/NEL.Mesh.Tests.Unit.csproj --no-build --verbosity normal" + }, + + new TestTask + { + Name = "Acceptance Tests", + Run = "dotnet test NEL.MESH.Tests.Acceptance/NEL.MESH.Tests.Acceptance.csproj --no-build --verbosity normal" + }, + + new TestTask + { + Name = "Integration Tests", + Run = "dotnet test NEL.MESH.Tests.Integration/NEL.MESH.Tests.Integration.csproj --no-build --verbosity normal" } } } + }, + { + "add_tag", + new TagJob( + runsOn: BuildMachines.UbuntuLatest, + dependsOn: "build", + projectRelativePath: $"{projectName}/{projectName}.csproj", + githubToken: "${{ secrets.PAT_FOR_TAGGING }}", + branchName: branchName) + { + Name = "Add Tag and Create Release" + } + }, + { + "publish", + new PublishJobV2( + runsOn: BuildMachines.UbuntuLatest, + dependsOn: "add_tag", + dotNetVersion: dotNetVersion, + nugetApiKey: "${{ secrets.NUGET_ACCESS }}") + { + Name = "Publish to NuGet" + } } } }; @@ -92,5 +138,52 @@ public void GenerateBuildScript() githubPipeline, path: buildScriptPath); } + + public void GeneratePrLintScript(string branchName) + { + var githubPipeline = new GithubPipeline + { + Name = "PR Linter", + + OnEvents = new Events + { + PullRequest = new PullRequestEvent + { + Types = ["opened", "edited", "synchronize", "reopened", "closed"], + Branches = [branchName] + } + }, + + Jobs = new Dictionary + { + { + "label", + new LabelJobV2(runsOn: BuildMachines.UbuntuLatest) + { + Name = "Add Label(s)", + } + }, + { + "requireIssueOrTask", + new RequireIssueOrTaskJob() + { + Name = "Require Issue Or Task Association", + } + }, + } + }; + + string buildScriptPath = "../../../../.github/workflows/prLinter.yml"; + string directoryPath = Path.GetDirectoryName(buildScriptPath); + + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + + adotNetClient.SerializeAndWriteToFile( + adoPipeline: githubPipeline, + path: buildScriptPath); + } } } diff --git a/NEL.MESH.Tests.Acceptance/ConfigurationTests.Configuration.cs b/NEL.MESH.Tests.Acceptance/ConfigurationTests.Configuration.cs index fe687653..785b23e7 100644 --- a/NEL.MESH.Tests.Acceptance/ConfigurationTests.Configuration.cs +++ b/NEL.MESH.Tests.Acceptance/ConfigurationTests.Configuration.cs @@ -11,33 +11,37 @@ namespace NEL.MESH.Tests.Acceptance { public partial class ConfigurationTests { - [Fact] - public void ShouldGetConfigurationSettings() - { - // given - var mailboxId = this.configuration["MeshConfiguration:MailboxId"]; - var password = this.configuration["MeshConfiguration:Password"]; - var key = this.configuration["MeshConfiguration:Key"]; - var rootCertificate = this.configuration["MeshConfiguration:RootCertificate"]; + //[Fact] + //public void ShouldGetConfigurationSettings() + //{ + // // given + // var mailboxId = this.configuration["MeshConfiguration:MailboxId"]; + // var password = this.configuration["MeshConfiguration:Password"]; + // var sharedKey = this.configuration["MeshConfiguration:SharedKey"]; + // var clientSigningCertificate = this.configuration["MeshConfiguration:ClientSigningCertificate"]; - var intermediateCertificates = - this.configuration.GetSection("MeshConfiguration:IntermediateCertificates") - .Get>(); + // var clientSigningCertificatePassword = + // this.configuration["MeshConfiguration:ClientSigningCertificatePassword"]; - if (intermediateCertificates == null) - { - intermediateCertificates = new List(); - } + // var tlsRootCertificates = this.configuration.GetSection("MeshConfiguration:TlsRootCertificates") + // .Get>(); - var clientCertificate = this.configuration["MeshConfiguration:ClientCertificate"]; + // var tlsIntermediateCertificates = + // this.configuration.GetSection("MeshConfiguration:TlsIntermediateCertificates") + // .Get>(); - // then - mailboxId.Should().NotBeNullOrEmpty(); - password.Should().NotBeNullOrEmpty(); - key.Should().NotBeNullOrEmpty(); - rootCertificate.Should().NotBeNullOrEmpty(); - clientCertificate.Should().NotBeNullOrEmpty(); - intermediateCertificates.Count.Should().Be(1); - } + // if (tlsIntermediateCertificates == null) + // { + // tlsIntermediateCertificates = new List(); + // } + + // // then + // mailboxId.Should().NotBeNullOrEmpty(); + // password.Should().NotBeNullOrEmpty(); + // sharedKey.Should().NotBeNullOrEmpty(); + // tlsRootCertificates.Count.Should().Be(1); + // clientSigningCertificate.Should().NotBeNullOrEmpty(); + // tlsIntermediateCertificates.Count.Should().Be(1); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/ConfigurationTests.cs b/NEL.MESH.Tests.Acceptance/ConfigurationTests.cs index 79e3d4de..a2b8e7ce 100644 --- a/NEL.MESH.Tests.Acceptance/ConfigurationTests.cs +++ b/NEL.MESH.Tests.Acceptance/ConfigurationTests.cs @@ -14,8 +14,8 @@ public ConfigurationTests() { var configurationBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("local.appsettings.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables("NEL_MESH_CLIENT_ACCEPTANCE_"); + .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); this.configuration = configurationBuilder.Build(); } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.AcknowledgeMessages.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.AcknowledgeMessages.cs index 3595d7c1..afa0673b 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.AcknowledgeMessages.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.AcknowledgeMessages.cs @@ -13,37 +13,37 @@ namespace NEL.MESH.Tests.Acceptance { public partial class MeshClientTests { - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldAcknowledgeMessageAsync() - { - // given - string messageId = GetRandomString(); - var path = - $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox/{messageId}/status/acknowledged"; + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldAcknowledgeMessageAsync() + //{ + // // given + // string messageId = GetRandomString(); + // var path = + // $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox/{messageId}/status/acknowledged"; - bool expectedAcknowledgeMessageResult = true; + // bool expectedAcknowledgeMessageResult = true; - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingPut() - .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) - .WithHeader("mex-osname", this.meshConfigurations.MexOSName) - .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) - .WithHeader("authorization", "*", MatchBehaviour.AcceptOnMatch) - ) - .RespondWith( - Response.Create() - .WithSuccess()); + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingPut() + // .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) + // .WithHeader("mex-osname", this.meshConfigurations.MexOSName) + // .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) + // .WithHeader("authorization", "*", MatchBehaviour.AcceptOnMatch) + // ) + // .RespondWith( + // Response.Create() + // .WithSuccess()); - // when - bool actualGetMessageResult = - await this.meshClient.Mailbox.AcknowledgeMessageAsync(messageId); + // // when + // bool actualGetMessageResult = + // await this.meshClient.Mailbox.AcknowledgeMessageAsync(messageId); - // then - actualGetMessageResult.Should().Be(expectedAcknowledgeMessageResult); - } + // // then + // actualGetMessageResult.Should().Be(expectedAcknowledgeMessageResult); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessage.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessage.cs index 424fd2c2..e22ed4b3 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessage.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessage.cs @@ -15,137 +15,137 @@ namespace NEL.MESH.Tests.Acceptance { public partial class MeshClientTests { - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldGetStringMessageAsync() - { - // given - string randomMessageId = GetRandomString(); - string inputMessageId = randomMessageId; - string mexTo = GetRandomString(); - string mexWorkflowId = GetRandomString(); - string content = GetRandomString(wordMinLength: GetRandomNumber()); - string mexSubject = GetRandomString(); - string mexLocalId = GetRandomString(); - string mexFileName = GetRandomString(); - string mexContentChecksum = GetRandomString(); - string contentType = "text/plain"; - string contentEncoding = GetRandomString(); - - - Message randomMessage = ComposeMessage.CreateStringMessage( - mexTo, - mexWorkflowId, - content, - mexSubject, - mexLocalId, - mexFileName, - mexContentChecksum, - contentType, - contentEncoding); - - randomMessage.MessageId = inputMessageId; - - var path = $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox/{inputMessageId}"; - - Message outputMessage = new Message - { - MessageId = randomMessage.MessageId, - FileContent = randomMessage.FileContent - }; - - Message expectedGetMessageResult = outputMessage; - - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingGet() - .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) - .WithHeader("mex-osname", this.meshConfigurations.MexOSName) - .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) - .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - ) - .RespondWith( - Response.Create() - .WithSuccess() - .WithHeader("content-type", contentType) - .WithBody(randomMessage.FileContent)); - - // when - Message actualGetMessageResult = - await this.meshClient.Mailbox.RetrieveMessageAsync(inputMessageId); - - // then - actualGetMessageResult.MessageId.Should().BeEquivalentTo(expectedGetMessageResult.MessageId); - actualGetMessageResult.FileContent.Should().BeEquivalentTo(expectedGetMessageResult.FileContent); - } - - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldGetFileMessageAsync() - { - // given - string randomMessageId = GetRandomString(); - string inputMessageId = randomMessageId; - string mexTo = GetRandomString(); - string mexWorkflowId = GetRandomString(); - byte[] fileContent = Encoding.ASCII.GetBytes(GetRandomString(wordMinLength: GetRandomNumber())); - string mexContentEncrypted = GetRandomString(); - string mexSubject = GetRandomString(); - string mexLocalId = GetRandomString(); - string mexFileName = GetRandomString(); - string mexContentChecksum = GetRandomString(); - string contentType = "application/octet-stream"; - string contentEncoding = GetRandomString(); - - Message randomMessage = ComposeMessage.CreateFileMessage( - mexTo, - mexWorkflowId, - fileContent, - mexContentEncrypted, - mexSubject, - mexLocalId, - mexFileName, - mexContentChecksum, - contentType, - contentEncoding); - - randomMessage.MessageId = inputMessageId; - - var path = $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox/{inputMessageId}"; - - Message outputMessage = new Message - { - MessageId = randomMessage.MessageId, - FileContent = randomMessage.FileContent - }; - - Message expectedGetMessageResult = outputMessage; - - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingGet() - .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) - .WithHeader("mex-osname", this.meshConfigurations.MexOSName) - .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) - .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - ) - .RespondWith( - Response.Create() - .WithSuccess() - .WithHeader("content-type", contentType) - .WithBody(randomMessage.FileContent)); - - // when - Message actualGetMessageResult = - await this.meshClient.Mailbox.RetrieveMessageAsync(inputMessageId); - - // then - actualGetMessageResult.MessageId.Should().BeEquivalentTo(expectedGetMessageResult.MessageId); - actualGetMessageResult.FileContent.Should().BeEquivalentTo(expectedGetMessageResult.FileContent); - } + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldGetStringMessageAsync() + //{ + // // given + // string randomMessageId = GetRandomString(); + // string inputMessageId = randomMessageId; + // string mexTo = GetRandomString(); + // string mexWorkflowId = GetRandomString(); + // string content = GetRandomString(wordMinLength: GetRandomNumber()); + // string mexSubject = GetRandomString(); + // string mexLocalId = GetRandomString(); + // string mexFileName = GetRandomString(); + // string mexContentChecksum = GetRandomString(); + // string contentType = "text/plain"; + // string contentEncoding = GetRandomString(); + + + // Message randomMessage = ComposeMessage.CreateStringMessage( + // mexTo, + // mexWorkflowId, + // content, + // mexSubject, + // mexLocalId, + // mexFileName, + // mexContentChecksum, + // contentType, + // contentEncoding); + + // randomMessage.MessageId = inputMessageId; + + // var path = $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox/{inputMessageId}"; + + // Message outputMessage = new Message + // { + // MessageId = randomMessage.MessageId, + // FileContent = randomMessage.FileContent + // }; + + // Message expectedGetMessageResult = outputMessage; + + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingGet() + // .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) + // .WithHeader("mex-osname", this.meshConfigurations.MexOSName) + // .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) + // .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // ) + // .RespondWith( + // Response.Create() + // .WithSuccess() + // .WithHeader("content-type", contentType) + // .WithBody(randomMessage.FileContent)); + + // // when + // Message actualGetMessageResult = + // await this.meshClient.Mailbox.RetrieveMessageAsync(inputMessageId); + + // // then + // actualGetMessageResult.MessageId.Should().BeEquivalentTo(expectedGetMessageResult.MessageId); + // actualGetMessageResult.FileContent.Should().BeEquivalentTo(expectedGetMessageResult.FileContent); + //} + + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldGetFileMessageAsync() + //{ + // // given + // string randomMessageId = GetRandomString(); + // string inputMessageId = randomMessageId; + // string mexTo = GetRandomString(); + // string mexWorkflowId = GetRandomString(); + // byte[] fileContent = Encoding.ASCII.GetBytes(GetRandomString(wordMinLength: GetRandomNumber())); + // string mexContentEncrypted = GetRandomString(); + // string mexSubject = GetRandomString(); + // string mexLocalId = GetRandomString(); + // string mexFileName = GetRandomString(); + // string mexContentChecksum = GetRandomString(); + // string contentType = "application/octet-stream"; + // string contentEncoding = GetRandomString(); + + // Message randomMessage = ComposeMessage.CreateFileMessage( + // mexTo, + // mexWorkflowId, + // fileContent, + // mexContentEncrypted, + // mexSubject, + // mexLocalId, + // mexFileName, + // mexContentChecksum, + // contentType, + // contentEncoding); + + // randomMessage.MessageId = inputMessageId; + + // var path = $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox/{inputMessageId}"; + + // Message outputMessage = new Message + // { + // MessageId = randomMessage.MessageId, + // FileContent = randomMessage.FileContent + // }; + + // Message expectedGetMessageResult = outputMessage; + + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingGet() + // .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) + // .WithHeader("mex-osname", this.meshConfigurations.MexOSName) + // .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) + // .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // ) + // .RespondWith( + // Response.Create() + // .WithSuccess() + // .WithHeader("content-type", contentType) + // .WithBody(randomMessage.FileContent)); + + // // when + // Message actualGetMessageResult = + // await this.meshClient.Mailbox.RetrieveMessageAsync(inputMessageId); + + // // then + // actualGetMessageResult.MessageId.Should().BeEquivalentTo(expectedGetMessageResult.MessageId); + // actualGetMessageResult.FileContent.Should().BeEquivalentTo(expectedGetMessageResult.FileContent); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessages.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessages.cs index 20ced2ed..f9091896 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessages.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.GetMessages.cs @@ -15,43 +15,43 @@ namespace NEL.MESH.Tests.Acceptance { public partial class MeshClientTests { - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldGetMessagesAsync() - { - // given - string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox"; - - List randomMessages = GetRandomStrings(); - - GetMessagesResponse responseMessages = new GetMessagesResponse - { - Messages = randomMessages - }; - - string serialisedResponseMessage = JsonConvert.SerializeObject(responseMessages); - List expectedGetMessagesResult = randomMessages; - - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingGet() - .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) - .WithHeader("mex-osname", this.meshConfigurations.MexOSName) - .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) - .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - ) - .RespondWith( - Response.Create() - .WithSuccess() - .WithBody(serialisedResponseMessage)); - - // when - List actualGetMessagesResult = await this.meshClient.Mailbox.RetrieveMessagesAsync(); - - // then - actualGetMessagesResult.Should().BeEquivalentTo(expectedGetMessagesResult); - } + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldGetMessagesAsync() + //{ + // // given + // string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/inbox"; + + // List randomMessages = GetRandomStrings(); + + // GetMessagesResponse responseMessages = new GetMessagesResponse + // { + // Messages = randomMessages + // }; + + // string serialisedResponseMessage = JsonConvert.SerializeObject(responseMessages); + // List expectedGetMessagesResult = randomMessages; + + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingGet() + // .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) + // .WithHeader("mex-osname", this.meshConfigurations.MexOSName) + // .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) + // .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // ) + // .RespondWith( + // Response.Create() + // .WithSuccess() + // .WithBody(serialisedResponseMessage)); + + // // when + // List actualGetMessagesResult = await this.meshClient.Mailbox.RetrieveMessagesAsync(); + + // // then + // actualGetMessagesResult.Should().BeEquivalentTo(expectedGetMessagesResult); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.Handshake.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.Handshake.cs index 369b40f3..90c952c4 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.Handshake.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.Handshake.cs @@ -13,31 +13,31 @@ namespace NEL.MESH.Tests.Acceptance { public partial class MeshClientTests { - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldDoHandshakeAsync() - { - // given - bool expectedHandshakeResult = true; - string path = $"/messageexchange/{this.meshConfigurations.MailboxId}"; + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldDoHandshakeAsync() + //{ + // // given + // bool expectedHandshakeResult = true; + // string path = $"/messageexchange/{this.meshConfigurations.MailboxId}"; - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingGet() - .WithHeader("mex-clientversion", "*", MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-osname", "*", MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-osversion", "*", MatchBehaviour.AcceptOnMatch)) - .RespondWith( - Response.Create() - .WithSuccess()); + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingGet() + // .WithHeader("mex-clientversion", "*", MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-osname", "*", MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-osversion", "*", MatchBehaviour.AcceptOnMatch)) + // .RespondWith( + // Response.Create() + // .WithSuccess()); - // when - bool actualHandshakeResult = await this.meshClient.Mailbox.HandshakeAsync(); + // // when + // bool actualHandshakeResult = await this.meshClient.Mailbox.HandshakeAsync(); - // then - actualHandshakeResult.Should().Be(expectedHandshakeResult); - } + // // then + // actualHandshakeResult.Should().Be(expectedHandshakeResult); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.SendFile.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.SendFile.cs index 3f34a60e..623c3551 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.SendFile.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.SendFile.cs @@ -17,93 +17,93 @@ namespace NEL.MESH.Tests.Acceptance { public partial class MeshClientTests { - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldSendFileMessageAsync() - { - // given - string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/outbox"; - string randomId = GetRandomString(); - string outputId = randomId; - string mexTo = GetRandomString(); - string mexWorkflowId = GetRandomString(); - byte[] content = Encoding.UTF8.GetBytes(GetRandomString(wordMinLength: GetRandomNumber())); - string mexSubject = GetRandomString(); - string mexLocalId = GetRandomString(); - string mexFileName = GetRandomString(); - string mexContentChecksum = GetRandomString(); - string contentType = "application/octet-stream"; - string contentEncoding = GetRandomString(); + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldSendFileMessageAsync() + //{ + // // given + // string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/outbox"; + // string randomId = GetRandomString(); + // string outputId = randomId; + // string mexTo = GetRandomString(); + // string mexWorkflowId = GetRandomString(); + // byte[] content = Encoding.UTF8.GetBytes(GetRandomString(wordMinLength: GetRandomNumber())); + // string mexSubject = GetRandomString(); + // string mexLocalId = GetRandomString(); + // string mexFileName = GetRandomString(); + // string mexContentChecksum = GetRandomString(); + // string contentType = "application/octet-stream"; + // string contentEncoding = GetRandomString(); - Message randomMessage = ComposeMessage.CreateFileMessage( - mexTo, - mexWorkflowId, - content, - mexSubject, - mexLocalId, - mexFileName, - mexContentChecksum, - contentType, - contentEncoding); + // Message randomMessage = ComposeMessage.CreateFileMessage( + // mexTo, + // mexWorkflowId, + // content, + // mexSubject, + // mexLocalId, + // mexFileName, + // mexContentChecksum, + // contentType, + // contentEncoding); - Message inputMessage = randomMessage; + // Message inputMessage = randomMessage; - SendMessageResponse responseMessage = new SendMessageResponse - { - MessageId = outputId, - Message = outputId, - }; + // SendMessageResponse responseMessage = new SendMessageResponse + // { + // MessageId = outputId, + // Message = outputId, + // }; - string serialisedResponseMessage = JsonConvert.SerializeObject(responseMessage); + // string serialisedResponseMessage = JsonConvert.SerializeObject(responseMessage); - Message outputMessage = new Message - { - MessageId = outputId, - FileContent = inputMessage.FileContent - }; + // Message outputMessage = new Message + // { + // MessageId = outputId, + // FileContent = inputMessage.FileContent + // }; - Message expectedSendMessageResult = outputMessage; + // Message expectedSendMessageResult = outputMessage; - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingPost() - .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-from", this.meshConfigurations.MailboxId) - .WithHeader("mex-to", GetKeyStringValue("mex-to", inputMessage.Headers)) - .WithHeader("mex-workflowid", GetKeyStringValue("mex-workflowid", inputMessage.Headers)) - .WithHeader("mex-chunk-range", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-subject", GetKeyStringValue("mex-subject", inputMessage.Headers)) - .WithHeader("mex-localid", GetKeyStringValue("mex-localid", inputMessage.Headers)) - .WithHeader("mex-filename", GetKeyStringValue("mex-filename", inputMessage.Headers)) - .WithHeader("mex-content-checksum", GetKeyStringValue("mex-content-checksum", inputMessage.Headers)) - .WithHeader("Accept", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) - .WithHeader("mex-osname", this.meshConfigurations.MexOSName) - .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) - .WithBody(randomMessage.FileContent) - ) - .RespondWith( - Response.Create() - .WithSuccess() - .WithBody(serialisedResponseMessage)); + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingPost() + // .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-from", this.meshConfigurations.MailboxId) + // .WithHeader("mex-to", GetKeyStringValue("mex-to", inputMessage.Headers)) + // .WithHeader("mex-workflowid", GetKeyStringValue("mex-workflowid", inputMessage.Headers)) + // .WithHeader("mex-chunk-range", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-subject", GetKeyStringValue("mex-subject", inputMessage.Headers)) + // .WithHeader("mex-localid", GetKeyStringValue("mex-localid", inputMessage.Headers)) + // .WithHeader("mex-filename", GetKeyStringValue("mex-filename", inputMessage.Headers)) + // .WithHeader("mex-content-checksum", GetKeyStringValue("mex-content-checksum", inputMessage.Headers)) + // .WithHeader("Accept", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) + // .WithHeader("mex-osname", this.meshConfigurations.MexOSName) + // .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) + // .WithBody(randomMessage.FileContent) + // ) + // .RespondWith( + // Response.Create() + // .WithSuccess() + // .WithBody(serialisedResponseMessage)); - // when - Message actualSendMessageResult = await this.meshClient.Mailbox - .SendMessageAsync( - mexTo, - mexWorkflowId, - content, - mexSubject, - mexLocalId, - mexFileName, - mexContentChecksum, - contentType, - contentEncoding); + // // when + // Message actualSendMessageResult = await this.meshClient.Mailbox + // .SendMessageAsync( + // mexTo, + // mexWorkflowId, + // content, + // mexSubject, + // mexLocalId, + // mexFileName, + // mexContentChecksum, + // contentType, + // contentEncoding); - // then - actualSendMessageResult.Should().BeEquivalentTo(expectedSendMessageResult); - } + // // then + // actualSendMessageResult.Should().BeEquivalentTo(expectedSendMessageResult); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.SendMessage.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.SendMessage.cs index 608cbac7..b895b890 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.SendMessage.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.SendMessage.cs @@ -16,93 +16,93 @@ namespace NEL.MESH.Tests.Acceptance { public partial class MeshClientTests { - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldSendStringMessageAsync() - { - // given - string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/outbox"; - string randomId = GetRandomString(); - string outputId = randomId; - string mexTo = GetRandomString(); - string mexWorkflowId = GetRandomString(); - string content = GetRandomString(wordMinLength: GetRandomNumber()); - string mexSubject = GetRandomString(); - string mexLocalId = GetRandomString(); - string mexFileName = GetRandomString(); - string mexContentChecksum = GetRandomString(); - string contentType = "text/plain"; - string contentEncoding = GetRandomString(); + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldSendStringMessageAsync() + //{ + // // given + // string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/outbox"; + // string randomId = GetRandomString(); + // string outputId = randomId; + // string mexTo = GetRandomString(); + // string mexWorkflowId = GetRandomString(); + // string content = GetRandomString(wordMinLength: GetRandomNumber()); + // string mexSubject = GetRandomString(); + // string mexLocalId = GetRandomString(); + // string mexFileName = GetRandomString(); + // string mexContentChecksum = GetRandomString(); + // string contentType = "text/plain"; + // string contentEncoding = GetRandomString(); - Message randomMessage = ComposeMessage.CreateStringMessage( - mexTo, - mexWorkflowId, - content, - mexSubject, - mexLocalId, - mexFileName, - mexContentChecksum, - contentType, - contentEncoding); + // Message randomMessage = ComposeMessage.CreateStringMessage( + // mexTo, + // mexWorkflowId, + // content, + // mexSubject, + // mexLocalId, + // mexFileName, + // mexContentChecksum, + // contentType, + // contentEncoding); - Message inputMessage = randomMessage; + // Message inputMessage = randomMessage; - SendMessageResponse responseMessage = new SendMessageResponse - { - MessageId = outputId, - Message = outputId, - }; + // SendMessageResponse responseMessage = new SendMessageResponse + // { + // MessageId = outputId, + // Message = outputId, + // }; - string serialisedResponseMessage = JsonConvert.SerializeObject(responseMessage); + // string serialisedResponseMessage = JsonConvert.SerializeObject(responseMessage); - Message outputMessage = new Message - { - MessageId = outputId, - FileContent = inputMessage.FileContent - }; + // Message outputMessage = new Message + // { + // MessageId = outputId, + // FileContent = inputMessage.FileContent + // }; - Message expectedSendMessageResult = outputMessage; + // Message expectedSendMessageResult = outputMessage; - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingPost() - .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-from", this.meshConfigurations.MailboxId) - .WithHeader("mex-to", GetKeyStringValue("mex-to", inputMessage.Headers)) - .WithHeader("mex-workflowid", GetKeyStringValue("mex-workflowid", inputMessage.Headers)) - .WithHeader("mex-chunk-range", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-subject", GetKeyStringValue("mex-subject", inputMessage.Headers)) - .WithHeader("mex-localid", GetKeyStringValue("mex-localid", inputMessage.Headers)) - .WithHeader("mex-filename", GetKeyStringValue("mex-filename", inputMessage.Headers)) - .WithHeader("mex-content-checksum", GetKeyStringValue("mex-content-checksum", inputMessage.Headers)) - .WithHeader("Accept", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) - .WithHeader("mex-osname", this.meshConfigurations.MexOSName) - .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) - .WithBody(randomMessage.FileContent) - ) - .RespondWith( - Response.Create() - .WithSuccess() - .WithBody(serialisedResponseMessage)); + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingPost() + // .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-from", this.meshConfigurations.MailboxId) + // .WithHeader("mex-to", GetKeyStringValue("mex-to", inputMessage.Headers)) + // .WithHeader("mex-workflowid", GetKeyStringValue("mex-workflowid", inputMessage.Headers)) + // .WithHeader("mex-chunk-range", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-subject", GetKeyStringValue("mex-subject", inputMessage.Headers)) + // .WithHeader("mex-localid", GetKeyStringValue("mex-localid", inputMessage.Headers)) + // .WithHeader("mex-filename", GetKeyStringValue("mex-filename", inputMessage.Headers)) + // .WithHeader("mex-content-checksum", GetKeyStringValue("mex-content-checksum", inputMessage.Headers)) + // .WithHeader("Accept", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) + // .WithHeader("mex-osname", this.meshConfigurations.MexOSName) + // .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) + // .WithBody(randomMessage.FileContent) + // ) + // .RespondWith( + // Response.Create() + // .WithSuccess() + // .WithBody(serialisedResponseMessage)); - // when - Message actualSendMessageResult = await this.meshClient.Mailbox - .SendMessageAsync( - mexTo, - mexWorkflowId, - content, - mexSubject, - mexLocalId, - mexFileName, - mexContentChecksum, - contentType, - contentEncoding); + // // when + // Message actualSendMessageResult = await this.meshClient.Mailbox + // .SendMessageAsync( + // mexTo, + // mexWorkflowId, + // content, + // mexSubject, + // mexLocalId, + // mexFileName, + // mexContentChecksum, + // contentType, + // contentEncoding); - // then - actualSendMessageResult.Should().BeEquivalentTo(expectedSendMessageResult); - } + // // then + // actualSendMessageResult.Should().BeEquivalentTo(expectedSendMessageResult); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.TrackMessage.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.TrackMessage.cs index f2929a41..e4639ee1 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.TrackMessage.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.TrackMessage.cs @@ -14,79 +14,79 @@ namespace NEL.MESH.Tests.Acceptance { public partial class MeshClientTests { - [Fact] - [Trait("Category", "Acceptance")] - public async Task ShouldTrackMessageAsync() - { - // given - string messageId = GetRandomString(); - string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/outbox/tracking"; + //[Fact] + //[Trait("Category", "Acceptance")] + //public async Task ShouldTrackMessageAsync() + //{ + // // given + // string messageId = GetRandomString(); + // string path = $"/messageexchange/{this.meshConfigurations.MailboxId}/outbox/tracking"; - TrackingInfo randomTrackingInfo = new TrackingInfo - { - AddressType = GetRandomString(), - Checksum = GetRandomString(), - ChunkCount = GetRandomNumber(), - CompressFlag = GetRandomString(), - DownloadTimestamp = GetRandomString(), - DtsId = GetRandomString(), - EncryptedFlag = GetRandomString(), - ExpiryTime = GetRandomString(), - FileName = GetRandomString(), - FileSize = GetRandomNumber(), - IsCompressed = GetRandomString(), - LocalId = GetRandomString(), - MeshRecipientOdsCode = GetRandomString(), - MessageId = GetRandomString(), - MessageType = GetRandomString(), - PartnerId = GetRandomString(), - Recipient = GetRandomString(), - RecipientName = GetRandomString(), - RecipientOrgCode = GetRandomString(), - RecipientSmtp = GetRandomString(), - Sender = GetRandomString(), - SenderName = GetRandomString(), - SenderOdsCode = GetRandomString(), - SenderOrgCode = GetRandomString(), - SenderSmtp = GetRandomString(), - Status = GetRandomString(), - StatusSuccess = GetRandomString(), - UploadTimestamp = GetRandomString(), - Version = GetRandomString(), - WorkflowId = GetRandomString(), - }; + // TrackingInfo randomTrackingInfo = new TrackingInfo + // { + // AddressType = GetRandomString(), + // Checksum = GetRandomString(), + // ChunkCount = GetRandomNumber(), + // CompressFlag = GetRandomString(), + // DownloadTimestamp = GetRandomString(), + // DtsId = GetRandomString(), + // EncryptedFlag = GetRandomString(), + // ExpiryTime = GetRandomString(), + // FileName = GetRandomString(), + // FileSize = GetRandomNumber(), + // IsCompressed = GetRandomString(), + // LocalId = GetRandomString(), + // MeshRecipientOdsCode = GetRandomString(), + // MessageId = GetRandomString(), + // MessageType = GetRandomString(), + // PartnerId = GetRandomString(), + // Recipient = GetRandomString(), + // RecipientName = GetRandomString(), + // RecipientOrgCode = GetRandomString(), + // RecipientSmtp = GetRandomString(), + // Sender = GetRandomString(), + // SenderName = GetRandomString(), + // SenderOdsCode = GetRandomString(), + // SenderOrgCode = GetRandomString(), + // SenderSmtp = GetRandomString(), + // Status = GetRandomString(), + // StatusSuccess = GetRandomString(), + // UploadTimestamp = GetRandomString(), + // Version = GetRandomString(), + // WorkflowId = GetRandomString(), + // }; - string serialisedResponseMessage = JsonConvert.SerializeObject(randomTrackingInfo); + // string serialisedResponseMessage = JsonConvert.SerializeObject(randomTrackingInfo); - Message outputMessage = new Message - { - MessageId = messageId, - TrackingInfo = randomTrackingInfo - }; + // Message outputMessage = new Message + // { + // MessageId = messageId, + // TrackingInfo = randomTrackingInfo + // }; - Message expectedTrackMessageResult = outputMessage; + // Message expectedTrackMessageResult = outputMessage; - this.wireMockServer - .Given( - Request.Create() - .WithPath(path) - .UsingGet() - .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) - .WithHeader("mex-osname", this.meshConfigurations.MexOSName) - .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) - .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) - .WithParam("messageID", messageId) - ) - .RespondWith( - Response.Create() - .WithSuccess() - .WithBody(serialisedResponseMessage)); + // this.wireMockServer + // .Given( + // Request.Create() + // .WithPath(path) + // .UsingGet() + // .WithHeader("mex-clientversion", this.meshConfigurations.MexClientVersion) + // .WithHeader("mex-osname", this.meshConfigurations.MexOSName) + // .WithHeader("mex-osversion", this.meshConfigurations.MexOSVersion) + // .WithHeader("authorization", "*", WireMock.Matchers.MatchBehaviour.AcceptOnMatch) + // .WithParam("messageID", messageId) + // ) + // .RespondWith( + // Response.Create() + // .WithSuccess() + // .WithBody(serialisedResponseMessage)); - // when - Message actualTrackMessageResult = await this.meshClient.Mailbox.TrackMessageAsync(messageId); + // // when + // Message actualTrackMessageResult = await this.meshClient.Mailbox.TrackMessageAsync(messageId); - // then - actualTrackMessageResult.Should().BeEquivalentTo(expectedTrackMessageResult); - } + // // then + // actualTrackMessageResult.Should().BeEquivalentTo(expectedTrackMessageResult); + //} } } diff --git a/NEL.MESH.Tests.Acceptance/MeshClientTests.cs b/NEL.MESH.Tests.Acceptance/MeshClientTests.cs index c51b62bb..af29d19f 100644 --- a/NEL.MESH.Tests.Acceptance/MeshClientTests.cs +++ b/NEL.MESH.Tests.Acceptance/MeshClientTests.cs @@ -27,7 +27,7 @@ public MeshClientTests() var configurationBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile("local.appsettings.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables("NEL_MESH_CLIENT_ACCEPTANCE_"); + .AddEnvironmentVariables(); IConfiguration configuration = configurationBuilder.Build(); this.wireMockServer = WireMockServer.Start(); @@ -135,4 +135,4 @@ private static string GetKeyStringValue(string key, Dictionary - net8.0 + net9.0 disable disable false @@ -11,20 +11,20 @@ - - - - + + + + - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -38,7 +38,7 @@ Always - + Always diff --git a/NEL.MESH.Tests.Acceptance/appsettings.json b/NEL.MESH.Tests.Acceptance/appsettings.json index 4a9f45dc..397956fb 100644 --- a/NEL.MESH.Tests.Acceptance/appsettings.json +++ b/NEL.MESH.Tests.Acceptance/appsettings.json @@ -5,20 +5,18 @@ "Microsoft.AspNetCore": "Warning" } }, - "RunAcceptanceTests": false, - "RunIntegrationTests": false, "MeshConfiguration": { "MailboxId": "", "Password": "", - "Key": "", - "Url": "https://msg.devspineservices.nhs.uk/", + "SharedKey": "", + "Url": "", "MexClientVersion": "ApiDocs==0.0.1", "MexOSName": "Windows", "MexOSVersion": "#11", - "RootCertificate": "", - "IntermediateCertificates": [], - "ClientCertificate": "", - "ClientCertificatePassword": "", + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "", + "ClientSigningCertificatePassword": "", "MaxChunkSizeInMegabytes": "20" } } diff --git a/NEL.MESH.Tests.Integration.Witness/100.MeshClientTests.cs b/NEL.MESH.Tests.Integration.Witness/100.MeshClientTests.cs index cc8a803d..1aea27cd 100644 --- a/NEL.MESH.Tests.Integration.Witness/100.MeshClientTests.cs +++ b/NEL.MESH.Tests.Integration.Witness/100.MeshClientTests.cs @@ -167,4 +167,4 @@ private static Filler CreateMessageFiller(string content) return filler; } } -} +} \ No newline at end of file diff --git a/NEL.MESH.Tests.Integration.Witness/705.MeshClientTests.RetrieveMessageGone.cs b/NEL.MESH.Tests.Integration.Witness/705.MeshClientTests.RetrieveMessageGone.cs index 064140d6..e57a2ed3 100644 --- a/NEL.MESH.Tests.Integration.Witness/705.MeshClientTests.RetrieveMessageGone.cs +++ b/NEL.MESH.Tests.Integration.Witness/705.MeshClientTests.RetrieveMessageGone.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Force.DeepCloner; using NEL.MESH.Clients; +using NEL.MESH.Models.Foundations.Mesh; using Xunit; namespace NEL.MESH.Tests.Integration.Witness @@ -25,8 +26,8 @@ public async Task ShouldNotRetirveGoneMessageAsync() //string invalidMessageId = "20231123151625288395_ADB038"; // when - //Message retrievedMessage = - // await meshClient.Mailbox.RetrieveMessageAsync(invalidMessageId); + Message retrievedMessage = + await meshClient.Mailbox.RetrieveMessageAsync(invalidMessageId); // then } diff --git a/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.Configuration.cs b/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.Configuration.cs index 5ff75dbb..d91e759c 100644 --- a/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.Configuration.cs +++ b/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.Configuration.cs @@ -17,23 +17,24 @@ public void ShouldGetConfigurationSettings() // given var mailboxId = this.configuration["MeshConfiguration:MailboxId"]; var password = this.configuration["MeshConfiguration:Password"]; - var key = this.configuration["MeshConfiguration:Key"]; - var rootCertificate = this.configuration["MeshConfiguration:RootCertificate"]; + var sharedKey = this.configuration["MeshConfiguration:SharedKey"]; + var clientSigningCertificate = this.configuration["MeshConfiguration:ClientSigningCertificate"]; - var intermediateCertificates = - this.configuration.GetSection("MeshConfiguration:IntermediateCertificates") - .Get>(); + var tlsRootCertificates = this.configuration.GetSection("MeshConfiguration:TlsRootCertificates") + .Get>(); - var clientCertificate = this.configuration["MeshConfiguration:ClientCertificate"]; + var tlsIntermediateCertificates = + this.configuration.GetSection("MeshConfiguration:TlsIntermediateCertificates") + .Get>(); // then mailboxId.Should().NotBeNullOrEmpty(); password.Should().NotBeNullOrEmpty(); - key.Should().NotBeNullOrEmpty(); - rootCertificate.Should().NotBeNullOrEmpty(); - intermediateCertificates.Count().Should().BeGreaterThan(0); - clientCertificate.Should().NotBeNullOrEmpty(); - intermediateCertificates.Count.Should().Be(1); + sharedKey.Should().NotBeNullOrEmpty(); + tlsRootCertificates.Count.Should().Be(1); + tlsIntermediateCertificates.Count().Should().BeGreaterThan(0); + clientSigningCertificate.Should().NotBeNullOrEmpty(); + tlsIntermediateCertificates.Count.Should().Be(1); } } } diff --git a/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.cs b/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.cs index 6225547d..13ccaee3 100644 --- a/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.cs +++ b/NEL.MESH.Tests.Integration.Witness/ConfigurationTests.cs @@ -14,8 +14,8 @@ public ConfigurationTests() { var configurationBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("local.appsettings.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables("NEL_MESH_CLIENT_INTEGRATION_"); + .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); this.configuration = configurationBuilder.Build(); } diff --git a/NEL.MESH.Tests.Integration.Witness/NEL.MESH.Tests.Integration.Witness.csproj b/NEL.MESH.Tests.Integration.Witness/NEL.MESH.Tests.Integration.Witness.csproj index 0327b5c9..23cbd7fa 100644 --- a/NEL.MESH.Tests.Integration.Witness/NEL.MESH.Tests.Integration.Witness.csproj +++ b/NEL.MESH.Tests.Integration.Witness/NEL.MESH.Tests.Integration.Witness.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 disable disable false @@ -12,24 +12,28 @@ + + + + - - - - + + + + - - - + + + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -43,22 +47,7 @@ Always - - Always - - - Always - - - Always - - - Always - - - Always - - + Always diff --git a/NEL.MESH.Tests.Integration.Witness/Resources/dev_IA_Cert.cer b/NEL.MESH.Tests.Integration.Witness/Resources/dev_IA_Cert.cer deleted file mode 100644 index 2150e710..00000000 --- a/NEL.MESH.Tests.Integration.Witness/Resources/dev_IA_Cert.cer +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDrzCCApegAwIBAgIEXR9MizANBgkqhkiG9w0BAQsFADA8MQwwCgYDVQQKEwNu -aHMxCzAJBgNVBAsTAkNBMR8wHQYDVQQDExZOSFMgUFRMIFJvb3QgQXV0aG9yaXR5 -MB4XDTE5MDcxMjEzNDgyNVoXDTI5MDcxMjE0MTgyNVowNjEMMAoGA1UEChMDbmhz -MQswCQYDVQQLEwJDQTEZMBcGA1UEAxMQTkhTIERFViBMZXZlbCAxQzCCASIwDQYJ -KoZIhvcNAQEBBQADggEPADCCAQoCggEBAKdTQFJTAhjZ/+GdqkS6yE47xSF0VC8H -3ktAISj5BWmm+73vJtAioTm1s9TocR5+mQ4olZNnJ4vX0Z+Wc3QOq4/4ZLMb/nOO -mBcWsIABbsNoSwVKu9MbxtXNtSuxMt0biAWx2t9BLiHJDTtPG149K+b+RIyd0x3y -ZRypP3JTr1+hPq14GG2+aGMBTXwPnglWfpXIdv8p/PU2P/ka8y4bwjMGtBB3iE3O -H1jxk70RO+UcLBCcftRZJ4AAKCxohBjf7z31gx50Lp9Y+Dcooae3P51McOmpFd8y -/YTn/YTFaYHMlVHoO8rYcYJswcBtpa+H+ON7fvaEYtLAgH/GGNlkecUCAwEAAaOB -vjCBuzBeBgNVHR8EVzBVMFOgUaBPpE0wSzEMMAoGA1UEChMDbmhzMQswCQYDVQQL -EwJDQTEfMB0GA1UEAxMWTkhTIFBUTCBSb290IEF1dGhvcml0eTENMAsGA1UEAxME -Q1JMMTALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUz4gDrKnt3tEACoCAAEC4A4jI -kFIwHQYDVR0OBBYEFF7z2lL2Ai7amiZSUf9JNcgMdw12MAwGA1UdEwQFMAMBAf8w -DQYJKoZIhvcNAQELBQADggEBACOcohf06LEnxo8JlemqDnOYRxixoXAHwf256Yzr -0/NbpltYXMlYE2jJg3ldsZFYsNxP5ysizxgrkW4B6oRBjhqvAZlSzYEiUsEP2LDA -8UpmDdX3XurB/OGRDuqxSqoqezEHpaTs0ERpkTZdZL/kYQED6+N7mQcUWZrPYYvv -ANa1z5PZuAFIezskfOfFIuzWws/2V0SCCxfUyoLizVH55Wp6ETYmGA28R5tUXsWk -GAH4zSEDczXJkdHwK3sXYyqjjUAyQcGwcknK+DyUYube3S9lzORgU82lI1W+cjFq -NTZjuJNqIkoGR0YTIpylcAGayVQ2OP5Snt2PpyI0QoA3PHU= ------END CERTIFICATE----- \ No newline at end of file diff --git a/NEL.MESH.Tests.Integration.Witness/Resources/dev_RA_Cert.cer b/NEL.MESH.Tests.Integration.Witness/Resources/dev_RA_Cert.cer deleted file mode 100644 index a6398459..00000000 --- a/NEL.MESH.Tests.Integration.Witness/Resources/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+69dOU4G7W0+NYT4e/w -wDcJSq0fi8dwixDTYU8DkFCfEyahEqeuNPp9X3ddWZryq3XjbR3n0YA1sUmnuwiT -ruMNXR0m34pt0nFLQFz57+dLWhAsB5xQdLPc1AuWwK/R8jnHh3+Q/RXOnXG4NNmn -RKYUDjLpFTnWmiZfGyX6edIrjN72M3Guu5cAs0pD/2d6QFsp1Dg= ------END CERTIFICATE----- \ No newline at end of file diff --git a/NEL.MESH.Tests.Integration.Witness/appsettings.json b/NEL.MESH.Tests.Integration.Witness/appsettings.json index b9556fd3..a00761c9 100644 --- a/NEL.MESH.Tests.Integration.Witness/appsettings.json +++ b/NEL.MESH.Tests.Integration.Witness/appsettings.json @@ -5,20 +5,18 @@ "Microsoft.AspNetCore": "Warning" } }, - "RunAcceptanceTests": false, - "RunIntegrationTests": false, "MeshConfiguration": { "MailboxId": "", "Password": "", - "Key": "", + "SharedKey": "", "Url": "https://msg.intspineservices.nhs.uk", "MexClientVersion": "ApiDocs==0.0.1", "MexOSName": "Windows", "MexOSVersion": "#11", - "RootCertificate": "", - "IntermediateCertificates": [], - "ClientCertificate": "", - "ClientCertificatePassword": "", + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "", + "ClientSigningCertificatePassword": "", "MaxChunkSizeInMegabytes": "20" }, "IS_RELEASE_CANDIDATE": false, diff --git a/NEL.MESH.Tests.Integration/ConfigurationTests.Configuration.cs b/NEL.MESH.Tests.Integration/ConfigurationTests.Configuration.cs index d9d22bf3..9c36846a 100644 --- a/NEL.MESH.Tests.Integration/ConfigurationTests.Configuration.cs +++ b/NEL.MESH.Tests.Integration/ConfigurationTests.Configuration.cs @@ -37,4 +37,4 @@ public void ShouldGetConfigurationSettings() intermediateCertificates.Count.Should().Be(1); } } -} +} \ No newline at end of file diff --git a/NEL.MESH.Tests.Integration/ConfigurationTests.cs b/NEL.MESH.Tests.Integration/ConfigurationTests.cs index fbc8a819..a36caea0 100644 --- a/NEL.MESH.Tests.Integration/ConfigurationTests.cs +++ b/NEL.MESH.Tests.Integration/ConfigurationTests.cs @@ -14,12 +14,10 @@ public ConfigurationTests() { var configurationBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("local.appsettings.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables("NEL_MESH_CLIENT_INTEGRATION_"); + .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); this.configuration = configurationBuilder.Build(); } - - } } diff --git a/NEL.MESH.Tests.Integration/MeshClientTests.cs b/NEL.MESH.Tests.Integration/MeshClientTests.cs index 1cf3357c..614e7d8e 100644 --- a/NEL.MESH.Tests.Integration/MeshClientTests.cs +++ b/NEL.MESH.Tests.Integration/MeshClientTests.cs @@ -9,7 +9,6 @@ using Microsoft.Extensions.Configuration; using NEL.MESH.Clients; using NEL.MESH.Models.Configurations; -using NEL.MESH.Models.Foundations.Mesh; using Tynamix.ObjectFiller; namespace NEL.MESH.Tests.Integration @@ -23,8 +22,8 @@ public MeshClientTests() { var configurationBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("local.appsettings.json", optional: true, reloadOnChange: true) - .AddEnvironmentVariables("NEL_MESH_CLIENT_INTEGRATION_"); + .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); IConfiguration configuration = configurationBuilder.Build(); bool RunAcceptanceTests = configuration.GetSection("RunAcceptanceTests").Get(); @@ -89,47 +88,5 @@ private static string GetRandomString(int wordMinLength = 2, int wordMaxLength = private static int GetRandomNumber() => new IntRange(min: 2, max: 10).GetValue(); - - private static Message CreateRandomSendMessage( - string mexFrom, - string mexTo, - string mexWorkflowId, - string mexLocalId, - string mexSubject, - string mexFileName, - string mexContentChecksum, - string mexContentEncrypted, - string mexEncoding, - string mexChunkRange, - string contentType, - string content) - { - var message = CreateMessageFiller(content).Create(); - message.Headers.Add("mex-from", new List { mexFrom }); - message.Headers.Add("mex-to", new List { mexTo }); - message.Headers.Add("mex-workflowid", new List { mexWorkflowId }); - message.Headers.Add("mex-localid", new List { mexLocalId }); - message.Headers.Add("mex-subject", new List { mexSubject }); - message.Headers.Add("mex-filename", new List { mexFileName }); - message.Headers.Add("mex-content-checksum", new List { mexContentChecksum }); - message.Headers.Add("Mex-Content-Encrypted", new List { mexContentEncrypted }); - message.Headers.Add("Mex-Encoding", new List { mexEncoding }); - message.Headers.Add("mex-chunk-range", new List { mexChunkRange }); - message.Headers.Add("content-type", new List { contentType }); - - return message; - } - - private static Filler CreateMessageFiller(string content) - { - byte[] fileContent = Encoding.UTF8.GetBytes(content); - var filler = new Filler(); - - filler.Setup() - .OnProperty(message => message.FileContent).Use(fileContent) - .OnProperty(message => message.Headers).Use(new Dictionary>()); - - return filler; - } } } diff --git a/NEL.MESH.Tests.Integration/NEL.MESH.Tests.Integration.csproj b/NEL.MESH.Tests.Integration/NEL.MESH.Tests.Integration.csproj index 141b8e8b..8ca0030a 100644 --- a/NEL.MESH.Tests.Integration/NEL.MESH.Tests.Integration.csproj +++ b/NEL.MESH.Tests.Integration/NEL.MESH.Tests.Integration.csproj @@ -1,7 +1,7 @@ - + - net8.0 + net9.0 disable disable false @@ -12,24 +12,30 @@ + + + Always + + + - - - - + + + + - - - + + + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -43,24 +49,9 @@ Always - - Always - - - Always - - + Always - - Always - - - Always - - - Always - diff --git a/NEL.MESH.Tests.Integration/Resources/dev_IA_Cert.cer b/NEL.MESH.Tests.Integration/Resources/dev_IA_Cert.cer deleted file mode 100644 index 2150e710..00000000 --- a/NEL.MESH.Tests.Integration/Resources/dev_IA_Cert.cer +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDrzCCApegAwIBAgIEXR9MizANBgkqhkiG9w0BAQsFADA8MQwwCgYDVQQKEwNu -aH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xfUyoLizVH55Wp6ETYmGA28R5tUXsWk -GAH4zSEDczXJkdHwK3sXYyqjjUAyQcGwcknK+DyUYube3S9lzORgU82lI1W+cjFq -NTZjuJNqIkoGR0YTIpylcAGayVQ2OP5Snt2PpyI0QoA3PHU= ------END CERTIFICATE----- \ No newline at end of file diff --git a/NEL.MESH.Tests.Integration/Resources/dev_RA_Cert.cer b/NEL.MESH.Tests.Integration/Resources/dev_RA_Cert.cer deleted file mode 100644 index a6398459..00000000 --- a/NEL.MESH.Tests.Integration/Resources/dev_RA_Cert.cer +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDgjCCAmqgAwIBAgIEXR9LkDANBgkqhkiG9w0BAQsFADA8MQwwCgYDVQQKEwNu -aHMxCzAJBgNVBAsTAkNBMR8wHQYDVQQDExZOSFMgUFRMIFJvb3QgQXV0aG9yaXR5 -MB4XDTE5MDcwNTEyMzcyOFoXDTM5MDcwNTEzMDcyOFowPDEMMAoGA1UEChMDbmhz -MQswCQYDVQQLEwJDQTEfMB0GA1UEAxMWTkhTIFBUTCBSb290IEF1dGhvcml0eTCC -ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJkUOEvituvw0SSmU4adXDnP -SXiaLsQb8CPZwLylSYqumfIzSjsxkktJsekegF6ybtGRMPWW+zBXMI15C3cT+tn8 -gpCNYyn1P8/+oNgxtqTLYjxackfU6S8AL+6d39grDd6PlI5ILvCZko82m23cUx2y -2aRnpAIBgDk518tWLTZbMuM14bza/QvYVeX5DqW9gsz947opb6FYRe3MjeHiQmxq -GvWfPY/yb/cggo5y8m2fTQa6dencHeFwnmwbX6nwbrFx8UXzflD0Yke4i5Z2NN4C -xmgAqtxSu5Bz9f7ZQLPPBT5FL+pvxkAu4cEHma4JDD3KayhxzxigKbQcnQpXWEcC -AwEAAaOBizCBiDArBgNVHRAEJDAigA8yMDE5MDcwNTEyMzcyOFqBDzIwMzkwNzA1 -MTMwNzI4WjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUz4gDrKnt3tEACoCAAEC4 -A4jIkFIwHQYDVR0OBBYEFM+IA6yp7d7RAAqAgABAuAOIyJBSMAwGA1UdEwQFMAMB -Af8wDQYJKoZIhvcNAQELBQADggEBAJU06JOPpBMgj/Owzd2aDDIlzEjHDyBx0UOa -xcIeeAT/ByYkTuPees9b5vsPmUwVuNzKscChQ9tvuugPPoTu9gXQfLldKTLlPqOf -+VCghQhM4H+i9+JyK7iKYN7xdVJLjH0AIgpNLwNN/2pnZ+69dOU4G7W0+NYT4e/w -wDcJSq0fi8dwixDTYU8DkFCfEyahEqeuNPp9X3ddWZryq3XjbR3n0YA1sUmnuwiT -ruMNXR0m34pt0nFLQFz57+dLWhAsB5xQdLPc1AuWwK/R8jnHh3+Q/RXOnXG4NNmn -RKYUDjLpFTnWmiZfGyX6edIrjN72M3Guu5cAs0pD/2d6QFsp1Dg= ------END CERTIFICATE----- \ No newline at end of file diff --git a/NEL.MESH.Tests.Integration/appsettings.json b/NEL.MESH.Tests.Integration/appsettings.json index 4b7cc870..397956fb 100644 --- a/NEL.MESH.Tests.Integration/appsettings.json +++ b/NEL.MESH.Tests.Integration/appsettings.json @@ -5,20 +5,18 @@ "Microsoft.AspNetCore": "Warning" } }, - "RunAcceptanceTests": false, - "RunIntegrationTests": false, "MeshConfiguration": { "MailboxId": "", "Password": "", - "Key": "", - "Url": "https://msg.intspineservices.nhs.uk", + "SharedKey": "", + "Url": "", "MexClientVersion": "ApiDocs==0.0.1", "MexOSName": "Windows", "MexOSVersion": "#11", - "RootCertificate": "", - "IntermediateCertificates": [], - "ClientCertificate": "", - "ClientCertificatePassword": "", + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "", + "ClientSigningCertificatePassword": "", "MaxChunkSizeInMegabytes": "20" } } diff --git a/NEL.MESH.Tests.Unit/NEL.Mesh.Tests.Unit.csproj b/NEL.MESH.Tests.Unit/NEL.Mesh.Tests.Unit.csproj index 5a471a7f..e1daa3e0 100644 --- a/NEL.MESH.Tests.Unit/NEL.Mesh.Tests.Unit.csproj +++ b/NEL.MESH.Tests.Unit/NEL.Mesh.Tests.Unit.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 disable disable false @@ -11,19 +11,19 @@ - - - - + + + + - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -34,7 +34,7 @@ - + Always diff --git a/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Exceptions.SplitMessageIntoChunks.cs b/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Exceptions.SplitMessageIntoChunks.cs index 5de8cc39..88324eee 100644 --- a/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Exceptions.SplitMessageIntoChunks.cs +++ b/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Exceptions.SplitMessageIntoChunks.cs @@ -3,7 +3,6 @@ // --------------------------------------------------------------- using System; -using System.Threading.Tasks; using FluentAssertions; using Moq; using NEL.MESH.Models.Foundations.Chunking.Exceptions; @@ -16,7 +15,7 @@ namespace NEL.MESH.Tests.Unit.Services.Foundations.Chunks public partial class ChunkServiceTests { [Fact] - public async Task ShouldThrowServiceExceptionIfServiceErrorOccursOnSplitMessageIntoChunks() + public void ShouldThrowServiceExceptionIfServiceErrorOccursOnSplitMessageIntoChunks() { // given Message someMessage = CreateRandomMessage(); diff --git a/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Validations.SplitMessageIntoChunks.cs b/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Validations.SplitMessageIntoChunks.cs index a10bfc46..2ecde92b 100644 --- a/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Validations.SplitMessageIntoChunks.cs +++ b/NEL.MESH.Tests.Unit/Services/Foundations/Chunks/ChunkServiceTests.Validations.SplitMessageIntoChunks.cs @@ -3,7 +3,6 @@ // --------------------------------------------------------------- using System; -using System.Threading.Tasks; using FluentAssertions; using NEL.MESH.Models.Foundations.Chunking.Exceptions; using NEL.MESH.Models.Foundations.Mesh; @@ -15,7 +14,7 @@ namespace NEL.MESH.Tests.Unit.Services.Foundations.Chunks public partial class ChunkServiceTests { [Fact] - public async Task ShouldThrowValidationExceptionOnSplitMessageIntoChunksIfMessageIsNullAsync() + public void ShouldThrowValidationExceptionOnSplitMessageIntoChunksIfMessageIsNull() { // given Message nullMessage = null; diff --git a/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.Exceptions.Handshake.cs b/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.Exceptions.Handshake.cs index 17825ac5..a4b1e694 100644 --- a/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.Exceptions.Handshake.cs +++ b/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.Exceptions.Handshake.cs @@ -2,7 +2,6 @@ // Copyright (c) North East London ICB. All rights reserved. // --------------------------------------------------------------- -using System; using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; @@ -117,7 +116,7 @@ public async Task ShouldThrowServiceExceptionIfServiceErrorOccursOnHandshakeAsyn var httpRequestException = new HttpRequestException($"{(int)response.StatusCode} - {response.ReasonPhrase}"); - + var failedMeshServiceException = new FailedMeshServiceException( message: "Mesh service error occurred, contact support.", innerException: httpRequestException); diff --git a/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.cs b/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.cs index 2aa619eb..100ef63a 100644 --- a/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.cs +++ b/NEL.MESH.Tests.Unit/Services/Foundations/Mesh/MeshServiceTests.cs @@ -35,7 +35,7 @@ public MeshServiceTests() this.compareLogic = new CompareLogic(); } - public static TheoryData DependencyValidationResponseMessages() + public static TheoryData DependencyValidationResponseMessages() { var invalidValue = new HttpResponseMessage((HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), "400")) @@ -98,7 +98,7 @@ public static TheoryData DependencyValidationResponseMessages() }; } - public static TheoryData DependencyResponseMessages() + public static TheoryData DependencyResponseMessages() { var internalServerError = new HttpResponseMessage((HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), "500")) diff --git a/NEL.MESH.Tests.Unit/Services/Foundations/Tokens/TokenServiceTests.Validations.GenerateToken.cs b/NEL.MESH.Tests.Unit/Services/Foundations/Tokens/TokenServiceTests.Validations.GenerateToken.cs index 1f9777a5..574a2998 100644 --- a/NEL.MESH.Tests.Unit/Services/Foundations/Tokens/TokenServiceTests.Validations.GenerateToken.cs +++ b/NEL.MESH.Tests.Unit/Services/Foundations/Tokens/TokenServiceTests.Validations.GenerateToken.cs @@ -53,15 +53,15 @@ public async Task ShouldThrowValidationExceptionOnGenerateTokenIfArgumentsAreInv "please correct the errors and try again."); InvalidTokenArgsException.AddData( - key: "MailboxId", + key: nameof(MeshConfiguration.MailboxId), values: "Text is required"); InvalidTokenArgsException.AddData( - key: "Password", + key: nameof(MeshConfiguration.Password), values: "Text is required"); InvalidTokenArgsException.AddData( - key: "Key", + key: nameof(MeshConfiguration.Key), values: "Text is required"); var expectedTokenValidationException = diff --git a/NEL.MESH.Tests.Unit/Services/Orchestrations/Mesh/MeshOrchestrationTests.cs b/NEL.MESH.Tests.Unit/Services/Orchestrations/Mesh/MeshOrchestrationTests.cs index ffc527ab..7ca291fe 100644 --- a/NEL.MESH.Tests.Unit/Services/Orchestrations/Mesh/MeshOrchestrationTests.cs +++ b/NEL.MESH.Tests.Unit/Services/Orchestrations/Mesh/MeshOrchestrationTests.cs @@ -2,7 +2,6 @@ // Copyright (c) North East London ICB. All rights reserved. // --------------------------------------------------------------- -using System; using System.Collections.Generic; using System.Linq; using Moq; @@ -60,7 +59,7 @@ private static List GetRandomMessages() .ToList(); } - public static TheoryData InvalidMessageList() + public static TheoryData> InvalidMessageList() { return new TheoryData> { @@ -69,7 +68,7 @@ public static TheoryData InvalidMessageList() }; } - public static TheoryData MeshDependencyValidationExceptions() + public static TheoryData MeshDependencyValidationExceptions() { string randomMessage = GetRandomString(); string exceptionMessage = randomMessage; @@ -95,7 +94,7 @@ public static TheoryData MeshDependencyValidationExceptions() }; } - public static TheoryData MeshDependencyExceptions() + public static TheoryData MeshDependencyExceptions() { string randomMessage = GetRandomString(); string exceptionMessage = randomMessage; @@ -104,7 +103,7 @@ public static TheoryData MeshDependencyExceptions() return new TheoryData { new TokenDependencyException( - message: "Token dependency error occurred, contact support.", + message: "Token dependency error occurred, contact support.", innerException), new TokenServiceException( diff --git a/NEL.MESH.UI/MeshMailbox.Designer.cs b/NEL.MESH.UI/MeshMailbox.Designer.cs index cdcc83ed..8b59c4a4 100644 --- a/NEL.MESH.UI/MeshMailbox.Designer.cs +++ b/NEL.MESH.UI/MeshMailbox.Designer.cs @@ -2,6 +2,9 @@ // Copyright (c) North East London ICB. All rights reserved. // --------------------------------------------------------------- +using System.Drawing; +using System.Windows.Forms; + namespace NEL.MESH.UI { partial class MeshMailbox diff --git a/NEL.MESH.UI/MeshMailbox.cs b/NEL.MESH.UI/MeshMailbox.cs index a75b6c1f..c96207ca 100644 --- a/NEL.MESH.UI/MeshMailbox.cs +++ b/NEL.MESH.UI/MeshMailbox.cs @@ -10,6 +10,7 @@ using NEL.MESH.Clients; using NEL.MESH.Models.Configurations; using NEL.MESH.UI.Models; +using Newtonsoft.Json.Linq; namespace NEL.MESH.UI { @@ -137,14 +138,17 @@ private void InitializeMailbox(Mailbox mailbox) txtHeaders.Text = string.Empty; txtContent.Text = string.Empty; - var clientCertificate = meshCertificates.First(cert => cert.Environment == mailbox.Environment) - .ClientCertificate; + var clientCertificate = + meshCertificates.First(cert => cert.Environment == mailbox.Environment) + .ClientCertificate; + + var rootCertificate = meshCertificates.First(cert => cert.Environment == mailbox.Environment) + .RootCertificate; var intermediateCertificates = meshCertificates.First(cert => cert.Environment == mailbox.Environment) - .IntermediateCertificates; + .IntermediateCertificates; - var rootCertificate = meshCertificates.First(cert => cert.Environment == mailbox.Environment) - .RootCertificate; + var clientSigningCertificatePassword = string.Empty; var meshConfiguration = new MeshConfiguration { @@ -170,29 +174,38 @@ private static X509Certificate2 GetCertificate(string value) if (!string.IsNullOrEmpty(value)) { byte[] certBytes = Convert.FromBase64String(value); - return new X509Certificate2(certBytes); } return null; } - private static X509Certificate2Collection GetCertificates(List values) + private static X509Certificate2Collection GetCertificates(List certificates) { - values ??= new List(); + var certificateCollection = new X509Certificate2Collection(); - var certificates = new X509Certificate2Collection(); - - if (values.Any()) + foreach (string item in certificates) { - foreach (string item in values) - { - byte[] certBytes = Convert.FromBase64String(item); - certificates.Add(new X509Certificate2(certBytes)); - } + certificateCollection.Add(GetPemOrDerCertificate(item)); } - return certificates; + return certificateCollection; + } + + private static X509Certificate2 GetPemOrDerCertificate(string value) + { + byte[] certBytes = Convert.FromBase64String(value); + var certificate = X509CertificateLoader.LoadCertificate(certBytes); + + return certificate; + } + + private static X509Certificate2 GetPkcs12Certificate(string value, string password = "") + { + byte[] certBytes = Convert.FromBase64String(value); + var certificate = X509CertificateLoader.LoadPkcs12(certBytes, password); + + return certificate; } private void cbApplications_SelectedIndexChanged(object sender, EventArgs e) diff --git a/NEL.MESH.UI/Models/MeshCertificates.cs b/NEL.MESH.UI/Models/MeshCertificates.cs index 2371299d..a1504c8f 100644 --- a/NEL.MESH.UI/Models/MeshCertificates.cs +++ b/NEL.MESH.UI/Models/MeshCertificates.cs @@ -8,7 +8,7 @@ public class MeshCertificates { public string Environment { get; set; } = string.Empty; public string ClientCertificate { get; set; } = string.Empty; - public List IntermediateCertificates { get; set; } = new List(); public string RootCertificate { get; set; } = string.Empty; + public List IntermediateCertificates { get; set; } = new List(); } } diff --git a/NEL.MESH.UI/NEL.MESH.UI.csproj b/NEL.MESH.UI/NEL.MESH.UI.csproj index c327f6e3..85bd8d6e 100644 --- a/NEL.MESH.UI/NEL.MESH.UI.csproj +++ b/NEL.MESH.UI/NEL.MESH.UI.csproj @@ -2,19 +2,19 @@ WinExe - net8.0-windows - enable + net9.0-windows + disable + enable true true - enable false - - - - + + + + @@ -22,10 +22,11 @@ + Always - + Always diff --git a/NEL.MESH.UI/Program.cs b/NEL.MESH.UI/Program.cs index e4784763..de62333f 100644 --- a/NEL.MESH.UI/Program.cs +++ b/NEL.MESH.UI/Program.cs @@ -20,7 +20,7 @@ static void Main() var configurationBuilder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile("local.appsettings.json", optional: true, reloadOnChange: true); + .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true); IConfiguration configuration = configurationBuilder.Build(); diff --git a/NEL.MESH.UI/appsettings.json b/NEL.MESH.UI/appsettings.json index a195b412..84bebc77 100644 --- a/NEL.MESH.UI/appsettings.json +++ b/NEL.MESH.UI/appsettings.json @@ -8,19 +8,21 @@ "MeshCertificates": [ { "Environment": "DEV", - "RootCertificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tDQpNSUlEZ2pDQ0FtcWdBd0lCQWdJRVhSOUxrREFOQmdrcWhraUc5dzBCQVFzRkFEQThNUXd3Q2dZRFZRUUtFd051DQphSE14Q3pBSkJnTlZCQXNUQWtOQk1SOHdIUVlEVlFRREV4Wk9TRk1nVUZSTUlGSnZiM1FnUVhWMGFHOXlhWFI1DQpNQjRYRFRFNU1EY3dOVEV5TXpjeU9Gb1hEVE01TURjd05URXpNRGN5T0Zvd1BERU1NQW9HQTFVRUNoTURibWh6DQpNUXN3Q1FZRFZRUUxFd0pEUVRFZk1CMEdBMVVFQXhNV1RraFRJRkJVVENCU2IyOTBJRUYxZEdodmNtbDBlVENDDQpBU0l3RFFZSktvWklodmNOQVFFQkJRQURnZ0VQQURDQ0FRb0NnZ0VCQUprVU9Fdml0dXZ3MFNTbVU0YWRYRG5QDQpTWGlhTHNRY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lRigc+sWP7tug+6qU70SUHhx3QoTfE3mkBxP7pWVpZiagQUni14nAmfxVBWkrlszuJHABXHVRskMX8vkgNwCJsZVuFG2qHXV6BVeyn20B5yrsR1ELOG4BKyNN77s6cMVjDwN/yoC66WCP2C0GC96Q0Wr1x1dV7BIWMdF0o72aqNYf1o5O9xvAFHG61X1QRTsNMZsS1kdB/AQwR98GoVdRimI+flo7NEtTMCctdNQikHI2mzK9hvA4qZe8MCooWIcZYo1C3PaSwntn4azUqrMkAnxhVURpyU7PPv8CU6vGQqoi4fbSq8zHv2mzxHSMVT5CvbzPbOCJMWEQHNPVoepuhl7JKeaX2yLPWzG2E+tio5c5x48IbLu+D1Bfb/N0oj3UwTTAxMA0GCWCGSAFlAwQCAQUABCCwzIR2GxoiDZPmqavwl5AWKyc38goQ2Hm7CTXgQlFORwQUcCncWylC+NvKNBaVxF40hznRLEoCAicQ" + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "" }, { "Environment": "INT", - "RootCertificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURnakNDQW1xZ0F3SUJBZ0lFWFI5TGtEQU5CZ2txaGtpRzl3MEJBUXNGQURBOE1Rd3dDZ1lEVlFRS0V3TnUKYUhNeEN6QUpCZ05WQkFzVEFrTkJNUjh3SFFZRFZRUURFeFpPU0ZNZ1VGUk1JRkp2YjNRZ1FYVjBhRzl5YVhSNQpNQjRYRFRFNU1EY3dOVEV5TXpjeU9Gb1hEVE01TURjd05URXpNRGN5T0Zvd1BERU1NQW9HQTFVRUNoTURibWh6Ck1Rc3dDUVlEVlFRTEV3SkRRVEVmTUIwR0ExVUVBeE1XVGtoVElGQlVUQ0JTYjI5MElFRjFkR2h2Y21sMGVUQ0MKQVNJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dFUEFEQ0NBUW9DZ2dFQkFKa1VPRXZpdHV2dzBTU21VNGFkWERuUApTWGlhTHNRYjhDUFp3THlsU1lxd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ABXHVRskMX8vkgNwCJsZVuFG2qHXV6BVeyn20B5yrsR1ELOG4BKyNN77s6cMVjDwN/yoC66WCP2C0GC96Q0Wr1x1dV7BIWMdF0o72aqNYf1o5O9xvAFHG61X1QRTsNMZsS1kdB/AQwR98GoVdRimI+flo7NEtTMCctdNQikHI2mzK9hvA4qZe8MCooWIcZYo1C3PaSwntn4azUqrMkAnxhVURpyU7PPv8CU6vGQqoi4fbSq8zHv2mzxHSMVT5CvbzPbOCJMWEQHNPVoepuhl7JKeaX2yLPWzG2E+tio5c5x48IbLu+D1Bfb/N0oj3UwTTAxMA0GCWCGSAFlAwQCAQUABCCwzIR2GxoiDZPmqavwl5AWKyc38goQ2Hm7CTXgQlFORwQUcCncWylC+NvKNBaVxF40hznRLEoCAicQ" + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "" + }, + { + "Environment": "PROD", + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "" } ], diff --git a/NEL.MESH.UI/local.appsettings.zip b/NEL.MESH.UI/local.appsettings.zip deleted file mode 100644 index 25557b89..00000000 Binary files a/NEL.MESH.UI/local.appsettings.zip and /dev/null differ diff --git a/NEL.MESH/Brokers/Mesh/MeshBroker.cs b/NEL.MESH/Brokers/Mesh/MeshBroker.cs index 63a2606a..41147d22 100644 --- a/NEL.MESH/Brokers/Mesh/MeshBroker.cs +++ b/NEL.MESH/Brokers/Mesh/MeshBroker.cs @@ -202,11 +202,47 @@ private HttpClientHandler SetupHttpClientHandler() CheckCertificateRevocationList = false, }; + //if (this.MeshConfiguration.ClientSigningCertificate != null) + //{ + // handler.ClientCertificates.Add(this.MeshConfiguration.ClientSigningCertificate); + //} + if (this.MeshConfiguration.ClientCertificate != null) { handler.ClientCertificates.Add(this.MeshConfiguration.ClientCertificate); } + //if (this.MeshConfiguration.TlsRootCertificates != null + // || this.MeshConfiguration.TlsRootCertificates.Count > 0) + //{ + // handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => + // { + // if (chain != null) + // { + // chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; + + // // Try Add instead of AddRange to confirm certificates + // chain.ChainPolicy.CustomTrustStore.AddRange(this.MeshConfiguration.TlsRootCertificates); + + // if (this.MeshConfiguration.TlsIntermediateCertificates != null + // || this.MeshConfiguration.TlsIntermediateCertificates.Count > 0) + // { + // chain.ChainPolicy.ExtraStore.AddRange(this.MeshConfiguration.TlsIntermediateCertificates); + // } + + // chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; + // chain.ChainPolicy.VerificationFlags = X509VerificationFlags.IgnoreWrongUsage; + + // if (cert != null && chain.Build(cert)) + // { + // return true; + // }; + // } + + // throw new Exception(chain.ChainStatus.FirstOrDefault().StatusInformation); + // }; + //} + if (this.MeshConfiguration.RootCertificate != null) { handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => @@ -214,10 +250,12 @@ private HttpClientHandler SetupHttpClientHandler() if (chain != null) { chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; + + // Try Add instead of AddRange to confirm certificates + //chain.ChainPolicy.CustomTrustStore.AddRange(this.MeshConfiguration.TlsRootCertificates); chain.ChainPolicy.CustomTrustStore.Add(this.MeshConfiguration.RootCertificate); - if (this.MeshConfiguration.IntermediateCertificates != null - || this.MeshConfiguration.IntermediateCertificates.Count > 0) + if (this.MeshConfiguration.IntermediateCertificates != null) { chain.ChainPolicy.ExtraStore.AddRange(this.MeshConfiguration.IntermediateCertificates); } @@ -228,7 +266,8 @@ private HttpClientHandler SetupHttpClientHandler() if (cert != null && chain.Build(cert)) { return true; - }; + } + ; } throw new Exception(chain.ChainStatus.FirstOrDefault().StatusInformation); diff --git a/NEL.MESH/Clients/Mailboxes/IMailboxClient.cs b/NEL.MESH/Clients/Mailboxes/IMailboxClient.cs index 781913de..ed1c81d8 100644 --- a/NEL.MESH/Clients/Mailboxes/IMailboxClient.cs +++ b/NEL.MESH/Clients/Mailboxes/IMailboxClient.cs @@ -8,10 +8,36 @@ namespace NEL.MESH.Clients.Mailboxes { + /// + /// Defines operations for interacting with a mailbox system. + /// public interface IMailboxClient { + /// + /// Performs a handshake with the MESH mailbox service. + /// + /// + /// A task that represents the asynchronous operation. + /// The task result contains a value indicating whether the handshake was successful. + /// ValueTask HandshakeAsync(); + /// + /// Sends a text-based message to the specified recipient. + /// + /// The recipient of the message. + /// The workflow ID associated with the message. + /// The content of the message. + /// The subject of the message (optional). + /// A local identifier for the message (optional). + /// The file name associated with the message (optional). + /// The checksum of the message content (optional). + /// The MIME type of the message content (default: empty string). + /// The encoding of the message content (optional). + /// The expected response format (default: "application/json"). + /// + /// A task that represents the asynchronous operation. The task result contains the sent message. + /// ValueTask SendMessageAsync( string mexTo, string mexWorkflowId, @@ -24,6 +50,22 @@ ValueTask SendMessageAsync( string contentEncoding = "", string accept = "application/json"); + /// + /// Sends a file-based message to the specified recipient. + /// + /// The recipient of the message. + /// The workflow ID associated with the message. + /// The file content to send. + /// The subject of the message (optional). + /// A local identifier for the message (optional). + /// The file name associated with the message (optional). + /// The checksum of the message content (optional). + /// The MIME type of the file content (default: "application/octet-stream"). + /// The encoding of the file content (optional). + /// The expected response format (default: "application/json"). + /// + /// A task that represents the asynchronous operation. The task result contains the sent message. + /// ValueTask SendMessageAsync( string mexTo, string mexWorkflowId, @@ -36,9 +78,37 @@ ValueTask SendMessageAsync( string contentEncoding = "", string accept = "application/json"); + /// + /// Tracks the status of a specific message. + /// + /// The identifier of the message to track. + /// + /// A task that represents the asynchronous operation. The task result contains the tracked message. + /// ValueTask TrackMessageAsync(string messageId); + + /// + /// Retrieves a list of all available message identifiers. + /// ValueTask> RetrieveMessagesAsync(); + + /// + /// Retrieves the details of a specific message. + /// + /// The identifier of the message to retrieve. + /// + /// A task that represents the asynchronous operation. The task result contains the retrieved message. + /// ValueTask RetrieveMessageAsync(string messageId); + + /// + /// Acknowledges a specific message, marking it as processed. + /// + /// The identifier of the message to acknowledge. + /// + /// A task that represents the asynchronous operation. + /// The task result contains a value indicating whether the acknowledgment was successful. + /// ValueTask AcknowledgeMessageAsync(string messageId); } } diff --git a/NEL.MESH/Clients/MeshClient.cs b/NEL.MESH/Clients/MeshClient.cs index 6f5bdce1..2a0fcb35 100644 --- a/NEL.MESH/Clients/MeshClient.cs +++ b/NEL.MESH/Clients/MeshClient.cs @@ -18,20 +18,42 @@ namespace NEL.MESH.Clients { + /// + /// Represents a client for interacting with the Mesh service. + /// public class MeshClient : IMeshClient { - public MeshClient(MeshConfiguration meshConfigurations, ILoggerFactory? loggerFactory = null) + /// + /// Initializes a new instance of the class with the specified configuration. + /// + /// The Mesh configuration settings. + public MeshClient(MeshConfiguration meshConfigurations) + { + IHost host = RegisterServices(meshConfigurations, null); + Mailbox = InitializeClient(host); + } + + /// + /// Initializes a new instance of the class with the specified configuration + /// and optional logger factory. + /// + /// The Mesh configuration settings. + /// An optional logger factory for logging operations. + public MeshClient(MeshConfiguration meshConfigurations, ILoggerFactory loggerFactory = null) { IHost host = RegisterServices(meshConfigurations, loggerFactory); Mailbox = InitializeClient(host); } + /// + /// Gets the instance for interacting with a MESH mailbox. + /// public IMailboxClient Mailbox { get; private set; } private static IMailboxClient InitializeClient(IHost host) => host.Services.GetRequiredService(); - private static IHost RegisterServices(MeshConfiguration meshConfigurations, ILoggerFactory? loggerFactory) + private static IHost RegisterServices(MeshConfiguration meshConfigurations, ILoggerFactory loggerFactory) { if (loggerFactory is null) { diff --git a/NEL.MESH/Models/Configurations/MeshConfigurations.cs b/NEL.MESH/Models/Configurations/MeshConfigurations.cs index d854dc67..3418caf5 100644 --- a/NEL.MESH/Models/Configurations/MeshConfigurations.cs +++ b/NEL.MESH/Models/Configurations/MeshConfigurations.cs @@ -20,4 +20,4 @@ public class MeshConfiguration public string MexOSVersion { get; set; } public int MaxChunkSizeInMegabytes { get; set; } } -} +} \ No newline at end of file diff --git a/NEL.MESH/NEL.MESH.csproj b/NEL.MESH/NEL.MESH.csproj index 073fd16d..f62ba493 100644 --- a/NEL.MESH/NEL.MESH.csproj +++ b/NEL.MESH/NEL.MESH.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 disable disable MESH Client @@ -46,9 +46,9 @@ - - + + - + \ No newline at end of file diff --git a/NEL.MESH/Services/Foundations/Mesh/MeshService.Validation.cs b/NEL.MESH/Services/Foundations/Mesh/MeshService.Validation.cs index 8eab1b88..03a6b8ee 100644 --- a/NEL.MESH/Services/Foundations/Mesh/MeshService.Validation.cs +++ b/NEL.MESH/Services/Foundations/Mesh/MeshService.Validation.cs @@ -21,7 +21,20 @@ private static void ValidateResponse(HttpResponseMessage response) if (response.IsSuccessStatusCode == false) { string body = response.Content.ReadAsStringAsync().Result; - SendMessageErrorResponse error = JsonConvert.DeserializeObject(body); + SendMessageErrorResponse error; + + try + { + error = JsonConvert.DeserializeObject(body); + } + catch (Exception exception) + { + throw new HttpRequestException( + message: $"Unable to deserialize response: {body}", + inner: exception, + statusCode: response.StatusCode); + } + string message = $"{(int)response.StatusCode} - {response.ReasonPhrase}"; var httpRequestException = diff --git a/NEL.MESH/Services/Foundations/Tokens/TokenService.Validations.cs b/NEL.MESH/Services/Foundations/Tokens/TokenService.Validations.cs index d615891c..eb17fef9 100644 --- a/NEL.MESH/Services/Foundations/Tokens/TokenService.Validations.cs +++ b/NEL.MESH/Services/Foundations/Tokens/TokenService.Validations.cs @@ -18,6 +18,7 @@ public static void ValidateGenerateTokenArgs(string mailboxId, string password, "please correct the errors and try again.", (Rule: IsInvalid(mailboxId), Parameter: nameof(MeshConfiguration.MailboxId)), (Rule: IsInvalid(password), Parameter: nameof(MeshConfiguration.Password)), + //(Rule: IsInvalid(key), Parameter: nameof(MeshConfiguration.SharedKey))); (Rule: IsInvalid(key), Parameter: nameof(MeshConfiguration.Key))); } diff --git a/NEL.MESH/Services/Foundations/Tokens/TokenService.cs b/NEL.MESH/Services/Foundations/Tokens/TokenService.cs index 5f490905..521fc61f 100644 --- a/NEL.MESH/Services/Foundations/Tokens/TokenService.cs +++ b/NEL.MESH/Services/Foundations/Tokens/TokenService.cs @@ -34,7 +34,8 @@ public ValueTask GenerateTokenAsync() => ValidateGenerateTokenArgs( this.meshBroker.MeshConfiguration.MailboxId, this.meshBroker.MeshConfiguration.Password, - this.meshBroker.MeshConfiguration.Key); + //this.meshBroker.MeshConfiguration.SharedKey); + this.meshBroker.MeshConfiguration.Key); string nonce = this.identifierBroker.GetIdentifier().ToString(); string timeStamp = this.dateTimeBroker.GetCurrentDateTimeOffset().ToString("yyyyMMddHHmm"); @@ -47,11 +48,14 @@ public ValueTask GenerateTokenAsync() => $":{this.meshBroker.MeshConfiguration.Password}" + $":{timeStamp}"; + //string sharedKey = GenerateSha256(stringToHash, this.meshBroker.MeshConfiguration.SharedKey); string sharedKey = GenerateSha256(stringToHash, this.meshBroker.MeshConfiguration.Key); string token = await ValueTask .FromResult($"NHSMESH {this.meshBroker.MeshConfiguration.MailboxId}:{nonce}:{nonce_count}:{timeStamp}:{sharedKey}"); + Console.WriteLine($"Generated token: {token}"); + return token; }); diff --git a/NEL.MESH/appsettings.json b/NEL.MESH/appsettings.json index ee664218..3c32ebee 100644 --- a/NEL.MESH/appsettings.json +++ b/NEL.MESH/appsettings.json @@ -8,14 +8,15 @@ "MeshConfiguration": { "MailboxId": "", "Password": "", - "Key": "", - "Url": "https://msg.intspineservices.nhs.uk", + "SharedKey": "", + "Url": "https://msg.devspineservices.nhs.uk/", "MexClientVersion": "ApiDocs==0.0.1", "MexOSName": "Windows", "MexOSVersion": "#11", - "RootCertificate": "", - "IntermediateCertificates": [], - "ClientCertificate": "", - "MaxChunkSizeInMegabytes": "20" + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "", + "ClientSigningCertificatePassword": "", + "MaxChunkSizeInMegabytes": "20" } } diff --git a/NHSISL.MESH.Tests.Integration/appsettings.Development.json b/NHSISL.MESH.Tests.Integration/appsettings.Development.json new file mode 100644 index 00000000..fe2af5ff --- /dev/null +++ b/NHSISL.MESH.Tests.Integration/appsettings.Development.json @@ -0,0 +1,24 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "RunAcceptanceTests": false, + "RunIntegrationTests": false, + "MeshConfiguration": { + "MailboxId": "", + "Password": "", + "Key": "", + "Url": "https://msg.intspineservices.nhs.uk", + "MexClientVersion": "ApiDocs==0.0.1", + "MexOSName": "Windows", + "MexOSVersion": "#11", + "TlsRootCertificates": [], + "TlsIntermediateCertificates": [], + "ClientSigningCertificate": "", + "ClientSigningCertificatePassword": "", + "MaxChunkSizeInMegabytes": "20" + } +}