diff --git a/.azuredevops/pipelines/build-v2.yml b/.azuredevops/pipelines/build-v2.yml index 0917633..7530c2a 100644 --- a/.azuredevops/pipelines/build-v2.yml +++ b/.azuredevops/pipelines/build-v2.yml @@ -18,26 +18,90 @@ resources: branches: include: - develop - - main - - releases/* + - main trigger: - develop - - main - - releases/* + - main pool: vmImage: ubuntu-latest steps: +################################################################################################### + # Set obligation date container tags +################################################################################################### +- task: PowerShell@2 + displayName: Update Obligation date + inputs: + targetType: 'inline' + script: | + $DataHolderEnergyObligationDate = "$(ObligationDate)" + if (-not [string]::IsNullOrWhiteSpace( $DataHolderEnergyObligationDate )) { + Write-Host "##vso[task.setvariable variable=ObligationDateTag]$DataHolderEnergyObligationDate" + } + else { + Write-Host "##vso[task.setvariable variable=ObligationDateTag]22-4" + } +# Set release version variables for release tags +- task: PowerShell@2 + name: 'splitBranchName' + displayName: 'Split Branch Name' + inputs: + targetType: 'inline' + script: | + $branchParts = "$(Build.SourceBranchName)" -split '\.' + # Write-Host "Branch Name: $branchParts" + $majorVersion = $branchParts[0] + $minorVersion = $branchParts[1] + # Write-Host "Major Name: $majorVersion" + Write-Host "##vso[task.setvariable variable=majorVersion]$majorVersion" + Write-Host "##vso[task.setvariable variable=minorVersion]$minorVersion" + Write-Host "##vso[task.setvariable variable=majorMinorVersion]$majorVersion.$minorVersion" + ################################################################################################### # Checkout repositories ################################################################################################### - checkout: MockRegister - checkout: self -- checkout: CDRAuthServer +- checkout: git://cdr-auth-server@refs/heads/develop + persistCredentials: true + + ### Swith AuthServer to required branch. +- powershell: | + cd cdr-auth-server + + $branchRef = "" + $authServerBranch = "" + $SourcebranchName = "$(Build.SourceBranch)" -replace 'refs/heads/', '' + + if ($branchName -match "releases/") { + $authServerBranch = "$(AuthServerReleaseBranchName)" + $branchRef = "refs/heads/$(authServerBranch)" + } + elseif ($branchName -eq "main" -or $branchName -eq "develop") { + $authServerBranch = $branchName + $branchRef = "$(Build.SourceBranch)" + } + else { + $authServerBranch = "develop" + $branchRef = "refs/heads/develop" + } + + echo "authServerBranch - $authServerBranch and branchRef - $branchRef" + + if ( git ls-remote origin $branchRef) + { + echo "Remote branch of $branchRef exists for cdr_auth_server" + git switch $authServerBranch + git status + } + + cd .. + + displayName: 'Switch cdr-auth-server code to required branch' ################################################################################################### # Build images @@ -265,14 +329,21 @@ steps: condition: always() inputs: command: login - containerRegistry: <> + containerRegistry: $(AcrBaseUrl) + +# Login to Shared ACR +- task: Docker@2 + displayName: Login to Shared ACR + inputs: + command: login + containerRegistry: $(SpSharedAcr) # Run trx formatter to output .MD and .CSV - script: | docker run \ -v=$(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-integration-tests/testresults/results.trx:/app/results.trx:ro \ -v=$(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-integration-tests/testresults/formatted/:/app/out/:rw \ - <>.io/trx-formatter -i results.trx -t "MDHE" --outputprefix "MDHE" -o out/ + $(AcrBaseUrl).azurecr.io/trx-formatter -i results.trx -t "MDHE" --outputprefix "MDHE" -o out/ displayName: 'Run trx-formatter' condition: always() @@ -290,7 +361,7 @@ steps: docker run \ -v=$(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-cdr-auth-server-integration-tests/testresults/results.trx:/app/results.trx:ro \ -v=$(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-cdr-auth-server-integration-tests/testresults/formatted/:/app/out/:rw \ - <>.io/trx-formatter -i results.trx -t "MDHE-CAS" --outputprefix "MDHE-CAS" -o out/ + $(AcrBaseUrl).azurecr.io/trx-formatter -i results.trx -t "MDHE-CAS" --outputprefix "MDHE-CAS" -o out/ displayName: 'Run trx-formatter (CAS)' condition: always() @@ -314,7 +385,7 @@ steps: # docker run \ # -v=$(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-cdr-auth-server-e2e-tests/testresults/results.trx:/app/results.trx:ro \ # -v=$(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-cdr-auth-server-e2e-tests/testresults/formatted/:/app/out/:rw \ -# <>.io/trx-formatter -i results.trx -t "MDH-CAS-E2E" --outputprefix "MDH-CAS-E2E" -o out/ +# $(AcrBaseUrl).azurecr.io/trx-formatter -i results.trx -t "MDH-CAS-E2E" --outputprefix "MDH-CAS-E2E" -o out/ # displayName: "Run trx-formatter (CAS)" # condition: always() @@ -394,57 +465,215 @@ steps: - task: Docker@2 displayName: 'Re-Tag Mock Data Holder Energy image with :branch-name' inputs: - containerRegistry: <> + containerRegistry: $(AcrBaseUrl) repository: 'mock-data-holder-energy' command: tag - arguments: 'mock-data-holder-energy <>.io/mock-data-holder-energy:$(Build.SourceBranchName)' + arguments: 'mock-data-holder-energy $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)' - task: Docker@2 displayName: 'Re-Tag Mock Data Holder Energy image with :latest (for develop branch only)' condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) inputs: - containerRegistry: <> + containerRegistry: $(AcrBaseUrl) repository: 'mock-data-holder-energy' command: tag - arguments: 'mock-data-holder-energy <>.io/mock-data-holder-energy:latest' + arguments: 'mock-data-holder-energy $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:latest' - task: CmdLine@2 displayName: 'Push Mock Data Holder Energy image with :branch-name tag to ACR' inputs: - script: 'docker push <>.io/mock-data-holder-energy:$(Build.SourceBranchName)' + script: 'docker push $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)' - task: CmdLine@2 displayName: 'Push Mock Data Holder Energy image with :latest tag to ACR (develop branch only)' condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) inputs: - script: 'docker push <>.io/mock-data-holder-energy:latest' + script: 'docker push $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:latest' # mock-data-holder-energy - task: Docker@2 displayName: 'Re-Tag Mock Data Holder Energy image with :branch-name' inputs: - containerRegistry: <> + containerRegistry: $(AcrBaseUrl) repository: 'mock-data-holder-energy' command: tag - arguments: 'mock-data-holder-energy <>.io/mock-data-holder-energy:$(Build.SourceBranchName)' + arguments: 'mock-data-holder-energy $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)' - task: Docker@2 displayName: 'Re-Tag Mock Data Holder Energy image with :latest (for develop branch only)' condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) inputs: - containerRegistry: <> + containerRegistry: $(AcrBaseUrl) repository: 'mock-data-holder-energy' command: tag - arguments: 'mock-data-holder-energy <>.io/mock-data-holder-energy:latest' + arguments: 'mock-data-holder-energy $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:latest' - task: CmdLine@2 displayName: 'Push Mock Data Holder Energy image with :branch-name tag to ACR' inputs: - script: 'docker push <>.io/mock-data-holder-energy:$(Build.SourceBranchName)' + script: 'docker push $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)' - task: CmdLine@2 displayName: 'Push Mock Data Holder Energy image with :latest tag to ACR (develop branch only)' condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) inputs: - script: 'docker push <>.io/mock-data-holder-energy:latest' + script: 'docker push $(AcrBaseUrl).azurecr.io/mock-data-holder-energy:latest' + +################################################################################################### +# Tag images and push to Shared ACR +################################################################################################### +# Pipeline variables are required : SharedAcrBaseUrl and SpSharedAcr +# develop branch tags +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with develop-latest (for develop branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:develop-latest' +# develop-latest-obligation-date tag +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with develop-latest-{obligation-date} (for develop branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:develop-latest-$(ObligationDateTag)' + +# develop branch> build number tag only +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with build number (for develop branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.BuildId)' +# main branch tags +# Pipeline variables are required : SharedAcrBaseUrl +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with main-latest (for main branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:main-latest' +# main-latest-obligation-date tag +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with main-latest-{obligation-date} (for main branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:main-latest-$(ObligationDateTag)' +# Build number tag +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with build number (for main branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.BuildId)' +# Re tag for full version for releases branch +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with full version for releases branch' + # Cannot use releases/* wildcard + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)' +# Re tag release full version and obligation date +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with releases-{obligation-date} for releases branch' + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)-$(ObligationDateTag)' +# Re tag Major and Mnior Tags using above variables +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with major and minor tags for releases branch' + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:"$(majorMinorVersion)"' +# Re tag Major release Tag using above variables +- task: Docker@2 + displayName: 'Re-Tag Mock Data Holder Energy image with major tag for releases branch' + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + containerRegistry: $(SpSharedAcr) + repository: 'mock-data-holder-energy' + command: tag + arguments: 'mock-data-holder-energy $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:"$(majorVersion)"' +# Pushing develop branch tags changes to the ACR +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with :develop-latest tag to ACR (develop branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:develop-latest' +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with :develop-latest-obligation-date tag to ACR (develop branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:develop-latest-$(ObligationDateTag)' + +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with :build id tag to ACR (develop branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.BuildId)' +# Pushing main branch tags changes to the ACR +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with :main-latest tag to ACR (main branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:main-latest' +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with :main-latest-obligation-date tag to ACR (main branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:main-latest-$(ObligationDateTag)' + +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with :build id tag to ACR (main branch only)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.BuildId)' + +# Push release full version Tag +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with releases tags to ACR (releases branch only)' + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)' +# Push release full version Tag and obligation date +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with releases tags to ACR (releases branch only)' + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:$(Build.SourceBranchName)-$(ObligationDateTag)' +# Push Major and Minor release Tags using above variables +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with releases tags to ACR (releases branch only)' + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:"$(majorMinorVersion)"' + +# Push Major release Tag using above variables +- task: CmdLine@2 + displayName: 'Push Mock Data Holder Energy image with releases tags to ACR (releases branch only)' + condition: eq(startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/'), 'True') + inputs: + script: 'docker push $(SharedAcrBaseUrl).azurecr.io/mock-data-holder-energy:"$(majorVersion)"' \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 186806f..7b5c71a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [1.3.2] - 2023-06-20 +### Changed +- Regenerated all mTLS, SSA and TLS certificates to allow for another five years before they expire. + ### Fixed - Links in help file diff --git a/CertificateManagement/mtls/server.cmd b/CertificateManagement/mtls/server.cmd index b3eff54..692a70f 100644 --- a/CertificateManagement/mtls/server.cmd +++ b/CertificateManagement/mtls/server.cmd @@ -1,5 +1,5 @@ -openssl req -new -newkey rsa:2048 -keyout server.key -sha256 -nodes -out server.csr -config server.cnf -openssl req -in server.csr -noout -text -openssl x509 -req -days 400 -in server.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out server.pem -extfile server.ext -openssl pkcs12 -inkey server.key -in server.pem -export -out server.pfx -openssl pkcs12 -in server.pfx -noout -info +openssl req -new -newkey rsa:2048 -keyout server-energy.key -sha256 -nodes -out server-energy.csr -config server-energy.cnf +openssl req -in server-energy.csr -noout -text +openssl x509 -req -days 1826 -in server-energy.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out server-energy.pem -extfile server-energy.ext +openssl pkcs12 -inkey server-energy.key -in server-energy.pem -export -out server-energy.pfx +openssl pkcs12 -in server-energy.pfx -noout -info diff --git a/CertificateManagement/mtls/server.cnf b/CertificateManagement/mtls/server.cnf index a449727..a10f5d2 100644 --- a/CertificateManagement/mtls/server.cnf +++ b/CertificateManagement/mtls/server.cnf @@ -4,7 +4,7 @@ distinguished_name = req_distinguished_name prompt = no req_extensions = req_ext [ req_distinguished_name ] -commonName = register.mock +commonName = mock-data-holder-energy countryName = AU stateOrProvinceName = ACT localityName = Canberra @@ -16,5 +16,5 @@ keyUsage = critical, nonRepudiation, digitalSignature, keyEnciphermen extendedKeyUsage = critical, serverAuth subjectAltName = @alt_names [alt_names] -DNS.1 = localhost -DNS.2 = register.mock +DNS.1 = mock-data-holder-energy +DNS.2 = localhost diff --git a/CertificateManagement/mtls/server.csr b/CertificateManagement/mtls/server.csr index 5d468d8..2c0bfd3 100644 --- a/CertificateManagement/mtls/server.csr +++ b/CertificateManagement/mtls/server.csr @@ -1,19 +1,19 @@ -----BEGIN CERTIFICATE REQUEST----- -MIIDETCCAfkCAQAwYzEWMBQGA1UEAwwNcmVnaXN0ZXIubW9jazELMAkGA1UEBhMC -QVUxDDAKBgNVBAgMA0FDVDERMA8GA1UEBwwIQ2FuYmVycmExDTALBgNVBAoMBEFD -Q0MxDDAKBgNVBAsMA0NEUjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -AMCYK/r1gCqFEcA8sKJmPDpAPYikr1rNrDtkRiNLoEGZjQBx6wL5yl1//OdT8OY+ -ulCzivu2lDSpPcN6gYVyLjyshfDQ4e8wjyvuewoEa9yonbRPQJcMGajl3b+WP8H2 -zoMXdCqbhXw+7s9SVWivhANLYQ+gjUu5d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87Mcxem7VaNb3mi2VpevSEXYEPzv8ZwdZT4kHx/cM+ +RclAHbNT3BmzhUVPDqLeq3Mg98f+eYmmdzEGHXjr3JholuqXw7EVjWHOL4K3h7fC +PrHU58x78pr84TENR28c8wYk57qr6J4/4r35goj2oj2r1XnPh5ajzam/+ar/BlpO +JNrtfOzYweWtzDrU7A6xMYlHD81svNhqCnDnAgMBAAGgczBxBgkqhkiG9w0BCQ4x +ZDBiMAkGA1UdEwQCMAAwDgYDVR0PAQH/BAQDAgXgMBYGA1UdJQEB/wQMMAoGCCsG +AQUFBwMBMC0GA1UdEQQmMCSCF21vY2stZGF0YS1ob2xkZXItZW5lcmd5gglsb2Nh +bGhvc3QwDQYJKoZIhvcNAQELBQADggEBAK94YAkQ75NTqbxWsAAGeBvKur59lB7d +3o4BMhN1D4pUjQnJIijPv5ECynlU+f9T3hnvWD/Y4eJvw5qUhoKC3uLBnmi81meI +Wtj3PZE6DEkcJfiLxpDdnnOkmFRMB/RcplPFES6W3AT69wvhB5qauyUlE9T55GtS +aalzxustFg5daxsZKxzTsiUI+sUyPI0TaDECAX34nuDaXxrh79ktkVk+oT8M+yiO +BvVTkUvfbXeGRM0pXzR+J9armjjRWmb357IhIgjWcpJlHR2TXsgc0ish8j00M9W5 +hrEnTg5JcTOCbp0qLMFjVMgSyPSMRQkUPbk+bfT+VKALtYnW4rpzOjI= -----END CERTIFICATE REQUEST----- diff --git a/CertificateManagement/mtls/server.ext b/CertificateManagement/mtls/server.ext index b7a0210..65d8bcc 100644 --- a/CertificateManagement/mtls/server.ext +++ b/CertificateManagement/mtls/server.ext @@ -5,5 +5,5 @@ extendedKeyUsage = critical, serverAuth subjectAltName = @alt_names [alt_names] DNS.1 = localhost -DNS.2 = register.mock +DNS.2 = mock-data-holder-energy diff --git a/CertificateManagement/mtls/server.key b/CertificateManagement/mtls/server.key index cfae6ff..62b4c62 100644 --- a/CertificateManagement/mtls/server.key +++ b/CertificateManagement/mtls/server.key @@ -1,28 +1,28 @@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cIkpqIZ50R5gKYJTtiOpEYL5ZgAROaW9FkorcPqYy1tYzJn0vmWFiwGCS/IVq +jmPdvTySaaMtfWukUUckfVw= -----END PRIVATE KEY----- diff --git a/CertificateManagement/mtls/server.pem b/CertificateManagement/mtls/server.pem index 5cc58b2..abafc0e 100644 --- a/CertificateManagement/mtls/server.pem +++ b/CertificateManagement/mtls/server.pem @@ -1,28 +1,29 @@ -----BEGIN CERTIFICATE----- -MIIEzTCCArWgAwIBAgIUF3EHUgccfdTxbug7CvE7qyx2Xl0wDQYJKoZIhvcNAQEL +MIIE4zCCAsugAwIBAgIUZArKvnjChy+gwjOSYMnMf3tioukwDQYJKoZIhvcNAQEL BQAwYTELMAkGA1UEBhMCQVUxDDAKBgNVBAgMA0FDVDERMA8GA1UEBwwIQ2FuYmVy cmExDTALBgNVBAoMBEFDQ0MxDDAKBgNVBAsMA0NEUjEUMBIGA1UEAwwLTW9jayBD -RFIgQ0EwHhcNMjIwNTExMDUxNjMyWhcNMjMwNjE1MDUxNjMyWjBjMRYwFAYDVQQD -DA1yZWdpc3Rlci5tb2NrMQswCQYDVQQGEwJBVTEMMAoGA1UECAwDQUNUMREwDwYD -VQQHDAhDYW5iZXJyYTENMAsGA1UECgwEQUNDQzEMMAoGA1UECwwDQ0RSMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwJgr+vWAKoURwDywomY8OkA9iKSv -Ws2sO2RGI0ugQZmNAHHrAvnKXX/851Pw5j66ULOK+7aUNKk9w3qBhXIuPKyF8NDh -7zCPK+57CgRr3KidtE9AlwwZqOXdv5Y/wfbOgxd0KpuFfD7uz1JVaK+EA0thD6CN -S7l35d4eJqNzem/UDtNr68R9JzMIQX+7JKBdEg8/HP0KyUerw6e7ErwlEy3KGnuA -QrnYY6J3oPDf0BlPN5ileabweLUqnW22aGLI5LAbf79jQuztBM02FYNNHBY7Buxd -jbbfqhce9yxgLrR/Gzuz9zF9gXhXtPSALmPFnkY3AQTwKAhLr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RQpZSQfw3XyJR0Ikk31t9vAaEN +o0MSnSFFN1iIPCCPYDH7MFgNN27oS+Yp2dzo7oyxF7MtwygyGJS51W4ro4QMabWs +WymO3yDZZNSE4XMb8voIywGQMU80FKTSx6dmwkSXwMiB4jD9LUl9Jh6q2QSn1GcA +qmthmg2PYE/FjCcl9Q5ftF9o+fgbA+GEtd05CPHGoENEIqtzIQ1UADPDFvSzqi94 +GqbpzwF4qW8lnN+hIluhT8f/+oCoKOvoTJYSwpUfLszbbHPz7YYbJmJBvZBNzWEP +wkiVMGumAw== -----END CERTIFICATE----- diff --git a/CertificateManagement/mtls/server.pfx b/CertificateManagement/mtls/server.pfx index 6b1eae9..4ce1b60 100644 Binary files a/CertificateManagement/mtls/server.pfx and b/CertificateManagement/mtls/server.pfx differ diff --git a/CertificateManagement/tls/mock-data-holder.cmd b/CertificateManagement/tls/mock-data-holder.cmd index cdab3f3..8d68e9c 100644 --- a/CertificateManagement/tls/mock-data-holder.cmd +++ b/CertificateManagement/tls/mock-data-holder.cmd @@ -1,5 +1,5 @@ -openssl req -new -newkey rsa:2048 -keyout mock-data-holder.key -sha256 -nodes -out mock-data-holder.csr -config mock-data-holder.cnf -openssl req -in mock-data-holder.csr -noout -text -openssl x509 -req -days 400 -in mock-data-holder.csr -out mock-data-holder.pem -extfile mock-data-holder.ext -signkey mock-data-holder.key -openssl pkcs12 -inkey mock-data-holder.key -in mock-data-holder.pem -export -out mock-data-holder.pfx -openssl pkcs12 -in mock-data-holder.pfx -noout -info \ No newline at end of file +openssl req -new -newkey rsa:2048 -keyout mock-data-holder-energy.key -sha256 -nodes -out mock-data-holder-energy.csr -config mock-data-holder-energy.cnf +openssl req -in mock-data-holder-energy.csr -noout -text +openssl x509 -req -days 1826 -in mock-data-holder-energy.csr -CA ..\mtls\ca.pem -CAkey ..\mtls\ca.key -CAcreateserial -out mock-data-holder-energy.pem -extfile mock-data-holder-energy.ext +openssl pkcs12 -inkey mock-data-holder-energy.key -in mock-data-holder-energy.pem -export -out mock-data-holder-energy.pfx +openssl pkcs12 -in mock-data-holder-energy.pfx -noout -info diff --git a/CertificateManagement/tls/mock-data-holder.cnf b/CertificateManagement/tls/mock-data-holder.cnf index df46c8a..a10f5d2 100644 --- a/CertificateManagement/tls/mock-data-holder.cnf +++ b/CertificateManagement/tls/mock-data-holder.cnf @@ -1,10 +1,10 @@ [ req ] -default_bits = 2048 -distinguished_name = req_distinguished_name -prompt = no -req_extensions = req_ext +default_bits = 2048 +distinguished_name = req_distinguished_name +prompt = no +req_extensions = req_ext [ req_distinguished_name ] -commonName = localhost +commonName = mock-data-holder-energy countryName = AU stateOrProvinceName = ACT localityName = Canberra @@ -16,5 +16,5 @@ keyUsage = critical, nonRepudiation, digitalSignature, keyEnciphermen extendedKeyUsage = critical, serverAuth subjectAltName = @alt_names [alt_names] -DNS.1 = localhost -DNS.2 = dataholder.mock +DNS.1 = mock-data-holder-energy +DNS.2 = localhost diff --git a/CertificateManagement/tls/mock-data-holder.csr b/CertificateManagement/tls/mock-data-holder.csr index 5a8e48b..5530e32 100644 --- a/CertificateManagement/tls/mock-data-holder.csr +++ b/CertificateManagement/tls/mock-data-holder.csr @@ -1,19 +1,19 @@ -----BEGIN CERTIFICATE REQUEST----- -MIIDFzCCAf8CAQAwZjEZMBcGA1UEAwwQbW9jay1kYXRhLWhvbGRlcjELMAkGA1UE -BhMCQVUxDDAKBgNVBAgMA0FDVDERMA8GA1UEBwwIQ2FuYmVycmExDTALBgNVBAoM -BEFDQ0MxDDAKBgNVBAsMA0NEUjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC -ggEBALDRyYftnSLsDjxNcFlOgOFtA40Zs6oemnkGfa7uHOgGYEEZSdaGfzUkuNHw -qQkByT6XsNzsFf65OKrxF/GKLl0Bgjukiik/2/+GAC1yeo2clvTTuHyhEaHdb6y0 -gNl3q2InFkI5gTrplEs9JvavQHj/a6x6ExkeSCcQJdhEauumxZI1lDRXozsxag2w -WMRikPTEW/UnECMKCsAV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B2z/1xYqK1Qzk+6e8Gh38CGYxkYUN02gXa5Vgrcbh8goFgPQr +w9iyE5yki6apu5dH0766mUQi6Q4oHqaSRkgoUOYp4cT/n+vTDaS+pl4Lo7/S2ezb +Eq3Poe/cG0I15JQqBhZ/2fv0FhToaDDmtVjTAgMBAAGgczBxBgkqhkiG9w0BCQ4x +ZDBiMAkGA1UdEwQCMAAwDgYDVR0PAQH/BAQDAgXgMBYGA1UdJQEB/wQMMAoGCCsG +AQUFBwMBMC0GA1UdEQQmMCSCF21vY2stZGF0YS1ob2xkZXItZW5lcmd5gglsb2Nh +bGhvc3QwDQYJKoZIhvcNAQELBQADggEBAFD7JnGe5jEnSvj5dM4na1uUkqGUontX +sYbMdd7EtN13yqtS2OYK04Lc1zPwcVmsCr+M19sh+3NSaynL5Tn5NVCjCsp8g7rS ++KzL/Mr+e09WJam9gqJbR/Add5vOEtEGgMjtzNZyRX5OOe2C+fxY3OEu4dSxaFHg +j/sl+4POLeIHnw7/Cn1J6VnE/W8TIkqwAKIvr5FEghny+aegbY8N5Zpv/ZeRc9nS +kCy00/lFlnq1ZFYLzwnL98onFtWoOyIXaaUBe0YkwKkR0F0nd31FbYS8Dz55TpEi +P7zqgyce+uxtg7LwZz8wj+pYwsQI+1h+owEb/qq59/Y8C+e6DbHhVSI= -----END CERTIFICATE REQUEST----- diff --git a/CertificateManagement/tls/mock-data-holder.ext b/CertificateManagement/tls/mock-data-holder.ext index d76044f..552191c 100644 --- a/CertificateManagement/tls/mock-data-holder.ext +++ b/CertificateManagement/tls/mock-data-holder.ext @@ -4,5 +4,6 @@ keyUsage = critical, nonRepudiation, digitalSignature, keyEnciphermen extendedKeyUsage = critical, serverAuth subjectAltName = @alt_names [alt_names] -DNS.1 = localhost -DNS.2 = dataholder.mock +DNS.1 = mock-data-holder-energy +DNS.2 = localhost + diff --git a/CertificateManagement/tls/mock-data-holder.key b/CertificateManagement/tls/mock-data-holder.key index e7a7f57..455c9be 100644 --- a/CertificateManagement/tls/mock-data-holder.key +++ b/CertificateManagement/tls/mock-data-holder.key @@ -1,28 +1,28 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCw0cmH7Z0i7A48 -TXBZToDhbQONGbOqHpp5Bn2u7hzoBmBBGUnWhn81JLjR8KkJAck+l7Dc7BX+uTiq -8Rfxii5dAYI7pIopP9v/hgAtcnqNnJb007h8oRGh3W+stIDZd6tiJxZCOYE66ZRL -PSb2r0B4/2usehMZHkgnECXYRGrrpsWSNZQ0V6M7MWoNsFjEYpD0xFv1JxAjCgrA -FYNqjEWOgHq9NZjI39Z7cVoqQdT9C5JrNpfOfIrgg4ARivQ6HKGcbChKrXuuvJNA -FJfpUygp7fSeIrg8/ie7Lt55JHXlv3KbLBzqMLBSGpnhuqGzsrdiJTLLGQVuVFgN -kl5043CdAgMBAAECggEALLQNSJFZbe/SNYq6gcmoKdX+1NiPpM3x7fEnK2fF5R9f -jHXRRixg0tXC6Ej4428RKwL80w3ZDbpUSluD2yw9RoRQIbYavA0KGNMPDm5n74+M -Vr+EX/X02EB8sGQ+QzzPFpSdOwcA1h0hwdfnFuz91tl0pnmChJI0WbPqbX/2rDbk -5LjsvXOvSruk9RRcvk7ppRf/aOer9BesAhbOkwUykt90G//8WaiftOnEhIoYnhOl -TV5K+oMkiByeh2+OiarJrV5V5BSm+TQBYb8cs/3GPwR1CJ1pujE5/AxgKr/hktEk -ELLkBOjLy2AchZ4R/m0DKv4N/yY1iT0uw7DTu5l+3QKBgQDi7JQtIWsy6AG77tu2 -fNDYPAibLx0c9ed52Ide7UrCepMek28dRCUXc5q3szYy1nYg1+oWBnwCC9KpLYhJ -M66CbFmmsvnV3Pto5M29U6bbbadruKNwh/jKpxgjKyo8FX9UiO6q1iuSUTqJF+IG -ATLwhQx/8QefkrK6d1aQfyjggwKBgQDHebUYTR6ElvAXLESDlZ1+3+vnkkc+kCnP -j2W2s04wD522du8Qzp1GwVx15qKdGIEW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BtLqPDJnT97rVOQAx6LnnwI91g8r68/03AFI7EcVm7pQOErl +oqj+lnjlSBVvB/9SA9kAXBqhGCk1UfQRP7dUVqIunzMiaMOTDYBQ/GykOdiYUNX1 +CrfownCToH6bIkeazKr6VQ== -----END PRIVATE KEY----- diff --git a/CertificateManagement/tls/mock-data-holder.pem b/CertificateManagement/tls/mock-data-holder.pem index 87292d4..3d358d8 100644 --- a/CertificateManagement/tls/mock-data-holder.pem +++ b/CertificateManagement/tls/mock-data-holder.pem @@ -1,28 +1,29 @@ -----BEGIN CERTIFICATE----- -MIIE0zCCArugAwIBAgIUF3EHUgccfdTxbug7CvE7qyx2XmEwDQYJKoZIhvcNAQEL +MIIE4zCCAsugAwIBAgIUZArKvnjChy+gwjOSYMnMf3tiou0wDQYJKoZIhvcNAQEL BQAwYTELMAkGA1UEBhMCQVUxDDAKBgNVBAgMA0FDVDERMA8GA1UEBwwIQ2FuYmVy cmExDTALBgNVBAoMBEFDQ0MxDDAKBgNVBAsMA0NEUjEUMBIGA1UEAwwLTW9jayBD -RFIgQ0EwHhcNMjIwNTExMDUzODA4WhcNMjMwNjE1MDUzODA4WjBmMRkwFwYDVQQD -DBBtb2NrLWRhdGEtaG9sZGVyMQswCQYDVQQGEwJBVTEMMAoGA1UECAwDQUNUMREw -DwYDVQQHDAhDYW5iZXJyYTENMAsGA1UECgwEQUNDQzEMMAoGA1UECwwDQ0RSMIIB -IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsNHJh+2dIuwOPE1wWU6A4W0D -jRmzqh6aeQZ9ru4c6AZgQRlJ1oZ/NSS40fCpCQHJPpew3OwV/rk4qvEX8YouXQGC -O6SKKT/b/4YALXJ6jZyW9NO4fKERod1vrLSA2XerYicWQjmBOumUSz0m9q9AeP9r -rHoTGR5IJxAl2ERq66bFkjWUNFejOzFqDbBYxGKQ9MRb9ScQIwoKwBWDaoxFjoB6 -vTWYyN/We3FaKkHU/QuSazaXznyK4IOAEYr0OhyhnGw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K6hcYKBzGa +Ic+HV5FhtJJsiaSM6vuctjJdCcEA0R7nATlE353aQz2QfEjPmNK0dQ+dgNky1sTr +gQFkA0Qa1l23URakbDCcFOrsJpjjIBKYsniNsp9XsPOst2VS4p0NTd6sZWwImnD5 +YDHbqUc6K+7ctqazu9M7cFq/D4cK54kOmqTgXzq3+ToWioBQQ0HTfuJGOFaWP18J +wvm6agOJB7dgmPkFG8Gh2Xxn8r0WhY2VAsLU3yDTZy3lAt6QRrb+LxQIf+Pf08IX +11qK//UQC4MsGcvo5A+TG/0RBfoiM3Hsf7lmAWbsl5umQxeITyb+QZWU2tdvDmy6 +IHT7erH41g== -----END CERTIFICATE----- diff --git a/CertificateManagement/tls/mock-data-holder.pfx b/CertificateManagement/tls/mock-data-holder.pfx index b836450..62ecde9 100644 Binary files a/CertificateManagement/tls/mock-data-holder.pfx and b/CertificateManagement/tls/mock-data-holder.pfx differ diff --git a/Source/CDR.DataHolder.API.Gateway.mTLS/CDR.DataHolder.API.Gateway.mTLS.csproj b/Source/CDR.DataHolder.API.Gateway.mTLS/CDR.DataHolder.API.Gateway.mTLS.csproj index 84db56b..15de07a 100644 --- a/Source/CDR.DataHolder.API.Gateway.mTLS/CDR.DataHolder.API.Gateway.mTLS.csproj +++ b/Source/CDR.DataHolder.API.Gateway.mTLS/CDR.DataHolder.API.Gateway.mTLS.csproj @@ -3,9 +3,9 @@ net6.0 win-x64;linux-x64 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.API.Gateway.mTLS/Certificates/server.pfx b/Source/CDR.DataHolder.API.Gateway.mTLS/Certificates/server.pfx index 6b1eae9..4ce1b60 100644 Binary files a/Source/CDR.DataHolder.API.Gateway.mTLS/Certificates/server.pfx and b/Source/CDR.DataHolder.API.Gateway.mTLS/Certificates/server.pfx differ diff --git a/Source/CDR.DataHolder.API.Infrastructure.UnitTests/CDR.DataHolder.API.Infrastructure.UnitTests.csproj b/Source/CDR.DataHolder.API.Infrastructure.UnitTests/CDR.DataHolder.API.Infrastructure.UnitTests.csproj index 969e616..b56f07a 100644 --- a/Source/CDR.DataHolder.API.Infrastructure.UnitTests/CDR.DataHolder.API.Infrastructure.UnitTests.csproj +++ b/Source/CDR.DataHolder.API.Infrastructure.UnitTests/CDR.DataHolder.API.Infrastructure.UnitTests.csproj @@ -3,9 +3,9 @@ net6.0 false - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.API.Infrastructure/CDR.DataHolder.API.Infrastructure.csproj b/Source/CDR.DataHolder.API.Infrastructure/CDR.DataHolder.API.Infrastructure.csproj index 0024d19..57a8340 100644 --- a/Source/CDR.DataHolder.API.Infrastructure/CDR.DataHolder.API.Infrastructure.csproj +++ b/Source/CDR.DataHolder.API.Infrastructure/CDR.DataHolder.API.Infrastructure.csproj @@ -2,9 +2,9 @@ net6.0 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 @@ -17,5 +17,9 @@ + + + + diff --git a/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/ApplicationHealthCheck.cs b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/ApplicationHealthCheck.cs new file mode 100644 index 0000000..9e97dc7 --- /dev/null +++ b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/ApplicationHealthCheck.cs @@ -0,0 +1,32 @@ +using CDR.DataHolder.Repository.Infrastructure; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using System.Threading; +using System.Threading.Tasks; + +namespace CDR.DataHolder.API.Infrastructure.HealthChecks +{ + public class ApplicationHealthCheck : IHealthCheck + { + private readonly HealthCheckStatuses _healthCheckStatuses; + + public ApplicationHealthCheck(HealthCheckStatuses healthCheckStatuses) + { + _healthCheckStatuses = healthCheckStatuses; + } + + public Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) + { + if (_healthCheckStatuses.AppStatus == AppStatus.NotStarted) + { + return Task.FromResult(HealthCheckResult.Unhealthy("Application not started")); + } + + if (_healthCheckStatuses.AppStatus == AppStatus.Shutdown) + { + return Task.FromResult(HealthCheckResult.Unhealthy("Application is shutdown")); + } + + return Task.FromResult(HealthCheckResult.Healthy("Application started successfully")); + } + } +} diff --git a/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/DatabaseMigrationHealthCheck.cs b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/DatabaseMigrationHealthCheck.cs new file mode 100644 index 0000000..ab78bda --- /dev/null +++ b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/DatabaseMigrationHealthCheck.cs @@ -0,0 +1,45 @@ +using CDR.DataHolder.Repository.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace CDR.DataHolder.API.Infrastructure.HealthChecks +{ + public class DatabaseMigrationHealthCheck : IHealthCheck + { + private readonly DataHolderDatabaseContext _dbContext; + private readonly HealthCheckStatuses _healthCheckStatuses; + + public DatabaseMigrationHealthCheck(DataHolderDatabaseContext dbContext, HealthCheckStatuses healthCheckStatuses) + { + _dbContext = dbContext; + _healthCheckStatuses=healthCheckStatuses; + } + + public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) + { + try + { + var migrationPending = await _dbContext.Database.GetPendingMigrationsAsync(cancellationToken); + + if (migrationPending.Count() == 0) + { + _healthCheckStatuses.IsMigrationDone = true; + return HealthCheckResult.Healthy("Database migration completed."); + } + + _healthCheckStatuses.IsMigrationDone = false; + return HealthCheckResult.Unhealthy($"Database migration pending. {migrationPending.Count()} pending migrations."); + } + catch (Exception e) + { + _healthCheckStatuses.IsMigrationDone = false; + return HealthCheckResult.Unhealthy($"Error. {e.Message}"); + } + + } + } +} diff --git a/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/DatabaseSeedingHealthCheck.cs b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/DatabaseSeedingHealthCheck.cs new file mode 100644 index 0000000..9fb7d4a --- /dev/null +++ b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/DatabaseSeedingHealthCheck.cs @@ -0,0 +1,37 @@ +using CDR.DataHolder.Repository.Infrastructure; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using System.Threading; +using System.Threading.Tasks; + +namespace CDR.DataHolder.API.Infrastructure.HealthChecks +{ + public class DatabaseSeedingHealthCheck : IHealthCheck + { + private readonly HealthCheckStatuses _healthCheckStatuses; + + public DatabaseSeedingHealthCheck(HealthCheckStatuses healthCheckStatuses) + { + _healthCheckStatuses=healthCheckStatuses; + } + + public Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) + { + if (_healthCheckStatuses.SeedingStatus == SeedingStatus.NotStarted) + { + return Task.FromResult(HealthCheckResult.Unhealthy("Database seeding not started")); + } + + if (_healthCheckStatuses.SeedingStatus == SeedingStatus.NotConfigured) + { + return Task.FromResult(HealthCheckResult.Healthy("Database seeding not configured")); + } + + if (_healthCheckStatuses.SeedingStatus == SeedingStatus.Failed) + { + return Task.FromResult(HealthCheckResult.Unhealthy("Database seeding failed")); + } + + return Task.FromResult(HealthCheckResult.Healthy($"Database seeding successful")); + } + } +} diff --git a/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/SqlServerHealthCheck.cs b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/SqlServerHealthCheck.cs new file mode 100644 index 0000000..4026358 --- /dev/null +++ b/Source/CDR.DataHolder.API.Infrastructure/HealthChecks/SqlServerHealthCheck.cs @@ -0,0 +1,34 @@ +using CDR.DataHolder.Repository; +using Microsoft.Data.SqlClient; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace CDR.DataHolder.API.Infrastructure.HealthChecks +{ + public class SqlServerHealthCheck : IHealthCheck + { + private readonly string _connectionString; + + public SqlServerHealthCheck(IConfiguration configuration) + { + _connectionString =configuration.GetConnectionString(DbConstants.ConnectionStringNames.Resource.Logging); + } + + public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) + { + using var connection = new SqlConnection(_connectionString); + try + { + await connection.OpenAsync(cancellationToken); + return HealthCheckResult.Healthy("SQL Server connection successful"); + } + catch (Exception ex) + { + return HealthCheckResult.Unhealthy(ex.Message); + } + } + } +} diff --git a/Source/CDR.DataHolder.API.Logger/CDR.DataHolder.API.Logger.csproj b/Source/CDR.DataHolder.API.Logger/CDR.DataHolder.API.Logger.csproj index 2f6b012..ad167e6 100644 --- a/Source/CDR.DataHolder.API.Logger/CDR.DataHolder.API.Logger.csproj +++ b/Source/CDR.DataHolder.API.Logger/CDR.DataHolder.API.Logger.csproj @@ -4,9 +4,9 @@ net6.0 enable enable - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.Admin.API/CDR.DataHolder.Admin.API.csproj b/Source/CDR.DataHolder.Admin.API/CDR.DataHolder.Admin.API.csproj index 29498c4..8f3062e 100644 --- a/Source/CDR.DataHolder.Admin.API/CDR.DataHolder.Admin.API.csproj +++ b/Source/CDR.DataHolder.Admin.API/CDR.DataHolder.Admin.API.csproj @@ -3,9 +3,9 @@ net6.0 win-x64;linux-x64 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.Admin.API/Certificates/tls-mock-data-holder-energy.pfx b/Source/CDR.DataHolder.Admin.API/Certificates/tls-mock-data-holder-energy.pfx index 11d4587..62ecde9 100644 Binary files a/Source/CDR.DataHolder.Admin.API/Certificates/tls-mock-data-holder-energy.pfx and b/Source/CDR.DataHolder.Admin.API/Certificates/tls-mock-data-holder-energy.pfx differ diff --git a/Source/CDR.DataHolder.Domain/CDR.DataHolder.Domain.csproj b/Source/CDR.DataHolder.Domain/CDR.DataHolder.Domain.csproj index ff88080..b2d2b63 100644 --- a/Source/CDR.DataHolder.Domain/CDR.DataHolder.Domain.csproj +++ b/Source/CDR.DataHolder.Domain/CDR.DataHolder.Domain.csproj @@ -2,9 +2,9 @@ net6.0 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.IntegrationTests/CDR.DataHolder.IntegrationTests.csproj b/Source/CDR.DataHolder.IntegrationTests/CDR.DataHolder.IntegrationTests.csproj index f13528d..9eed084 100644 --- a/Source/CDR.DataHolder.IntegrationTests/CDR.DataHolder.IntegrationTests.csproj +++ b/Source/CDR.DataHolder.IntegrationTests/CDR.DataHolder.IntegrationTests.csproj @@ -2,9 +2,9 @@ net6.0 false - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.IntegrationTests/Certificates/MDR/jwks.pfx b/Source/CDR.DataHolder.IntegrationTests/Certificates/MDR/jwks.pfx index d5fb751..828e8a9 100644 Binary files a/Source/CDR.DataHolder.IntegrationTests/Certificates/MDR/jwks.pfx and b/Source/CDR.DataHolder.IntegrationTests/Certificates/MDR/jwks.pfx differ diff --git a/Source/CDR.DataHolder.IntegrationTests/Certificates/client-additional.pfx b/Source/CDR.DataHolder.IntegrationTests/Certificates/client-additional.pfx index 0c72559..4ab62b6 100644 Binary files a/Source/CDR.DataHolder.IntegrationTests/Certificates/client-additional.pfx and b/Source/CDR.DataHolder.IntegrationTests/Certificates/client-additional.pfx differ diff --git a/Source/CDR.DataHolder.IntegrationTests/Certificates/client.pfx b/Source/CDR.DataHolder.IntegrationTests/Certificates/client.pfx index 85e022e..ad2726e 100644 Binary files a/Source/CDR.DataHolder.IntegrationTests/Certificates/client.pfx and b/Source/CDR.DataHolder.IntegrationTests/Certificates/client.pfx differ diff --git a/Source/CDR.DataHolder.IntegrationTests/Certificates/mock-data-holder.pfx b/Source/CDR.DataHolder.IntegrationTests/Certificates/mock-data-holder.pfx index b836450..62ecde9 100644 Binary files a/Source/CDR.DataHolder.IntegrationTests/Certificates/mock-data-holder.pfx and b/Source/CDR.DataHolder.IntegrationTests/Certificates/mock-data-holder.pfx differ diff --git a/Source/CDR.DataHolder.Manage.API/CDR.DataHolder.Manage.API.csproj b/Source/CDR.DataHolder.Manage.API/CDR.DataHolder.Manage.API.csproj index d05245c..305b743 100644 --- a/Source/CDR.DataHolder.Manage.API/CDR.DataHolder.Manage.API.csproj +++ b/Source/CDR.DataHolder.Manage.API/CDR.DataHolder.Manage.API.csproj @@ -3,9 +3,9 @@ net6.0 win-x64;linux-x64 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.Manage.API/Certificates/tls-mock-data-holder-energy.pfx b/Source/CDR.DataHolder.Manage.API/Certificates/tls-mock-data-holder-energy.pfx index 11d4587..62ecde9 100644 Binary files a/Source/CDR.DataHolder.Manage.API/Certificates/tls-mock-data-holder-energy.pfx and b/Source/CDR.DataHolder.Manage.API/Certificates/tls-mock-data-holder-energy.pfx differ diff --git a/Source/CDR.DataHolder.Manage.API/Controllers/ManageController.cs b/Source/CDR.DataHolder.Manage.API/Controllers/ManageController.cs index 6226f2f..72e9141 100644 --- a/Source/CDR.DataHolder.Manage.API/Controllers/ManageController.cs +++ b/Source/CDR.DataHolder.Manage.API/Controllers/ManageController.cs @@ -15,12 +15,14 @@ public class ManageController : ControllerBase { private readonly ILogger _logger; private readonly DataHolderDatabaseContext _dbContext; + private readonly HealthCheckStatuses _healthCheckStatuses; public ManageController(ILogger logger, - DataHolderDatabaseContext dbContext) + DataHolderDatabaseContext dbContext, HealthCheckStatuses healthCheckStatuses) { _logger = logger; _dbContext = dbContext; + _healthCheckStatuses=healthCheckStatuses; } [HttpPost] @@ -33,7 +35,7 @@ public async Task LoadData() try { - await _dbContext.SeedDatabaseFromJson(json, _logger, true); + await _dbContext.SeedDatabaseFromJson(json, _logger, _healthCheckStatuses, true); } catch { diff --git a/Source/CDR.DataHolder.Manage.API/Startup.cs b/Source/CDR.DataHolder.Manage.API/Startup.cs index 6fcedf5..c7738ef 100644 --- a/Source/CDR.DataHolder.Manage.API/Startup.cs +++ b/Source/CDR.DataHolder.Manage.API/Startup.cs @@ -1,4 +1,5 @@ using CDR.DataHolder.API.Infrastructure.Filters; +using CDR.DataHolder.API.Infrastructure.HealthChecks; using CDR.DataHolder.API.Infrastructure.Middleware; using CDR.DataHolder.Domain.Repositories; using CDR.DataHolder.Repository; @@ -7,7 +8,6 @@ using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -25,11 +25,6 @@ namespace CDR.DataHolder.Manage.API { public class Startup { - static private bool healthCheckMigration = false; - static private string healthCheckMigrationMessage = null; - static private bool healthCheckSeedData = false; - static private string healthCheckSeedDataMessage = null; - public Startup(IConfiguration configuration) { Configuration = configuration; @@ -56,113 +51,26 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); - string connStr = Configuration.GetConnectionString(DbConstants.ConnectionStringNames.Resource.Logging); - int seedDataTimeSpan = Configuration.GetValue("SeedData:TimeSpan"); - services.AddHealthChecks() - - .AddCheck("migration", () => healthCheckMigration ? HealthCheckResult.Healthy(healthCheckMigrationMessage) : HealthCheckResult.Unhealthy(healthCheckMigrationMessage)) - - // implemented "seed-data2" here just in case - .AddCheck("seed-data2", () => healthCheckSeedData ? HealthCheckResult.Healthy(healthCheckSeedDataMessage) : HealthCheckResult.Unhealthy(healthCheckSeedDataMessage)) - - .AddCheck("sql-connection", () => { - using (var db = new SqlConnection(connStr)) - { - try - { - db.Open(); - } - catch (SqlException) - { - return HealthCheckResult.Unhealthy(); - } - } - return HealthCheckResult.Healthy(); - }) - - .AddCheck("seed-data", () => { - if (!SeedData()) - { - return HealthCheckResult.Healthy("Seed data not configured"); - } - - using (var db = new SqlConnection(connStr)) - { - try - { - db.Open(); - using var selectCommand = new SqlCommand($"SELECT [TimeStamp] FROM [LogEventsManageAPI] WHERE [Message] = @msg ORDER BY [TimeStamp] DESC", db); - selectCommand.Parameters.AddWithValue("@msg", "Hosting started"); - var hostStarted = selectCommand.ExecuteScalar(); - if (hostStarted != null) - { - // Return the TimeStamp for when the Host is Started (all startup processing has completed) - // use this as the reference to test if the below operations are within the appsetting - SeedData:TimeSpan value - var hostStartedTimeStamp = Convert.ToDateTime(hostStarted); + services.AddSingleton(); - // IF the Seed Data was to be Imported or to be Updated - // if the log record message "Seed-Data:imported" exists and the process was completed within the SeedData:TimeSpan - // then it is considered to be Healthy - using var selectCommand1 = new SqlCommand($"SELECT TOP 1 [Id], [TimeStamp] FROM [LogEventsManageAPI] WHERE [Message] = @msg AND [SourceContext] = @srcContext ORDER BY [TimeStamp] DESC", db); - selectCommand1.Parameters.AddWithValue("@msg", "Seed-Data:imported"); - selectCommand1.Parameters.AddWithValue("@srcContext", "CDR.DataHolder.Manage.API.Startup"); - var dbReader1 = selectCommand1.ExecuteReader(); - if (dbReader1.HasRows) - { - using (dbReader1) - { - while (dbReader1.Read()) - { - TimeSpan timespan = (hostStartedTimeStamp - Convert.ToDateTime(dbReader1.GetDateTime(1))); - if (timespan.Minutes < seedDataTimeSpan) - { - return HealthCheckResult.Healthy(); - } - } - } - } - - dbReader1.Close(); - - // IF the Seed Data was flagged as to NOT be Imported - // if the log record message "Seed-Data:not-imported" exists and the process was completed within the SeedData:TimeSpan - // then it is considered to be Healthy - using var selectCommand2 = new SqlCommand($"SELECT TOP 1 [Id], [TimeStamp] FROM [LogEventsManageAPI] WHERE [Message] = @msg AND [SourceContext] = @srcContext ORDER BY [TimeStamp] DESC", db); - selectCommand2.Parameters.AddWithValue("@msg", "Seed-Data:not-imported"); - selectCommand2.Parameters.AddWithValue("@srcContext", "CDR.DataHolder.Manage.API.Startup"); - var dbReader2 = selectCommand2.ExecuteReader(); - if (dbReader2.HasRows) - { - using (dbReader2) - { - while (dbReader2.Read()) - { - TimeSpan timespan = (hostStartedTimeStamp - Convert.ToDateTime(dbReader2.GetDateTime(1))); - if (timespan.Minutes < seedDataTimeSpan) - return HealthCheckResult.Healthy(); - } - } - } - } - } - catch (SqlException) - { - return HealthCheckResult.Unhealthy(); - } - - return HealthCheckResult.Unhealthy(); - } - }); + services.AddHealthChecks() + .AddCheck("Application Check", HealthStatus.Unhealthy, new[] { "AppStatus" }, TimeSpan.FromSeconds(3)) + .AddCheck("SQL Server Check", HealthStatus.Unhealthy, new[] { "DatabaseStatus" }, TimeSpan.FromSeconds(10)) + .AddCheck("Migrations Check", HealthStatus.Unhealthy, new[] { "Migrations" }, TimeSpan.FromSeconds(10)) + .AddCheck("Seeding Check", HealthStatus.Unhealthy, new[] { "Seeding" }, TimeSpan.FromSeconds(3)); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger, IHostApplicationLifetime applicationLifetime, HealthCheckStatuses healthStatuses) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } + applicationLifetime.ApplicationStarted.Register(() => { healthStatuses.AppStatus = AppStatus.Started; }); + applicationLifetime.ApplicationStopping.Register(() => { healthStatuses.AppStatus = AppStatus.Shutdown; }); + app.UseSerilogRequestLogging(); app.UseHttpsRedirection(); @@ -180,17 +88,15 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger< }); // Ensure the database exists and is up to the latest version. - EnsureDatabase(app, logger); + EnsureDatabase(app, logger, healthStatuses); } - private void EnsureDatabase(IApplicationBuilder app, ILogger logger) + private void EnsureDatabase(IApplicationBuilder app, ILogger logger, HealthCheckStatuses healthCheckStatuses) { using (var serviceScope = app.ApplicationServices.GetService().CreateScope()) { if (RunMigrations()) { - healthCheckMigrationMessage = "Migration in progress"; - // Use DBO connection string since it has DBO rights needed to update db schema var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSqlServer(Configuration.GetConnectionString(DbConstants.ConnectionStringNames.Resource.Migrations) @@ -200,9 +106,7 @@ private void EnsureDatabase(IApplicationBuilder app, ILogger logger) using var dbMigrationsContext = new DataHolderDatabaseContext(optionsBuilder.Options); dbMigrationsContext.Database.Migrate(); - healthCheckMigrationMessage = "Migration completed"; } - healthCheckMigration = true; // Seed the database using the sample data JSON. var seedDataFilePath = Configuration.GetValue("SeedData:FilePath"); @@ -211,19 +115,15 @@ private void EnsureDatabase(IApplicationBuilder app, ILogger logger) if (!string.IsNullOrEmpty(seedDataFilePath)) { - healthCheckSeedDataMessage = "Seeding of data in progress"; - var context = serviceScope.ServiceProvider.GetRequiredService(); logger.LogInformation("Seed data file found within configuration. Attempting to seed the repository from the seed data..."); - Task.Run(() => context.SeedDatabaseFromJsonFile(seedDataFilePath, logger, seedDataOverwrite, offsetDates)).Wait(); + Task.Run(() => context.SeedDatabaseFromJsonFile(seedDataFilePath, logger, healthCheckStatuses, seedDataOverwrite, offsetDates)).Wait(); - healthCheckSeedDataMessage = "Seeding of data completed"; } else { - healthCheckSeedDataMessage = "Data is not seeded based on configuration"; + healthCheckStatuses.SeedingStatus = SeedingStatus.NotConfigured; } - healthCheckSeedData = true; } } @@ -250,7 +150,8 @@ private static Task CustomResponseWriter(HttpContext context, HealthReport healt { status = healthReport.Entries.Select(e => new { key = e.Key, - value = e.Value.Status.ToString() + value = e.Value.Status.ToString(), + description = e.Value.Description }) }); return context.Response.WriteAsync(result); diff --git a/Source/CDR.DataHolder.Public.API/CDR.DataHolder.Public.API.csproj b/Source/CDR.DataHolder.Public.API/CDR.DataHolder.Public.API.csproj index aa2f9d0..519638a 100644 --- a/Source/CDR.DataHolder.Public.API/CDR.DataHolder.Public.API.csproj +++ b/Source/CDR.DataHolder.Public.API/CDR.DataHolder.Public.API.csproj @@ -3,9 +3,9 @@ net6.0 win-x64;linux-x64 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.Public.API/Certificates/tls-mock-data-holder-energy.pfx b/Source/CDR.DataHolder.Public.API/Certificates/tls-mock-data-holder-energy.pfx index 11d4587..62ecde9 100644 Binary files a/Source/CDR.DataHolder.Public.API/Certificates/tls-mock-data-holder-energy.pfx and b/Source/CDR.DataHolder.Public.API/Certificates/tls-mock-data-holder-energy.pfx differ diff --git a/Source/CDR.DataHolder.Repository/CDR.DataHolder.Repository.csproj b/Source/CDR.DataHolder.Repository/CDR.DataHolder.Repository.csproj index c9c2c49..dd61050 100644 --- a/Source/CDR.DataHolder.Repository/CDR.DataHolder.Repository.csproj +++ b/Source/CDR.DataHolder.Repository/CDR.DataHolder.Repository.csproj @@ -2,9 +2,9 @@ net6.0 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.Repository/Infrastructure/Extensions.cs b/Source/CDR.DataHolder.Repository/Infrastructure/Extensions.cs index 896ae92..06df0d6 100644 --- a/Source/CDR.DataHolder.Repository/Infrastructure/Extensions.cs +++ b/Source/CDR.DataHolder.Repository/Infrastructure/Extensions.cs @@ -22,6 +22,7 @@ public async static Task SeedDatabaseFromJsonFile( this DataHolderDatabaseContext dataHolderDatabaseContext, string jsonFileFullPath, ILogger logger, + HealthCheckStatuses healthStatuses, bool overwriteExistingData = false, bool offsetDates = true) { @@ -32,7 +33,7 @@ public async static Task SeedDatabaseFromJsonFile( } var json = await File.ReadAllTextAsync(jsonFileFullPath); - await dataHolderDatabaseContext.SeedDatabaseFromJson(json, logger, overwriteExistingData, offsetDates); + await dataHolderDatabaseContext.SeedDatabaseFromJson(json, logger, healthStatuses, overwriteExistingData, offsetDates); } /// @@ -42,6 +43,7 @@ public async static Task SeedDatabaseFromJson( this DataHolderDatabaseContext dataHolderDatabaseContext, string json, ILogger logger, + HealthCheckStatuses healthStatuses, bool overwriteExistingData = false, bool offsetDates = true) { @@ -57,13 +59,13 @@ public async static Task SeedDatabaseFromJson( "Existing data found, but set to overwrite. Seeding data..." : "No existing data found. Seeding data..."); - await dataHolderDatabaseContext.ReSeedDatabaseFromJson(json, logger, offsetDates); + await dataHolderDatabaseContext.ReSeedDatabaseFromJson(json, logger, healthStatuses, offsetDates); } /// /// Re-Seed the database from the input JSON data. All existing data in the database will be removed prior to creating the new data set. /// - public async static Task ReSeedDatabaseFromJson(this DataHolderDatabaseContext dataHolderDatabaseContext, string json, ILogger logger, bool offsetDates = true) + public async static Task ReSeedDatabaseFromJson(this DataHolderDatabaseContext dataHolderDatabaseContext, string json, ILogger logger, HealthCheckStatuses healthStatuses, bool offsetDates = true) { using (var transaction = dataHolderDatabaseContext.Database.BeginTransaction()) { @@ -126,9 +128,11 @@ public async static Task ReSeedDatabaseFromJson(this DataHolderDatabaseContext d // DO NOT REMOVE or ALTER this is referenced in the health check logger.LogInformation("Seed-Data:imported"); + healthStatuses.SeedingStatus = SeedingStatus.Succeeded; } catch (Exception ex) { + healthStatuses.SeedingStatus = SeedingStatus.Failed; // Log any errors. logger.LogError(ex, "Error while seeding the database."); throw; diff --git a/Source/CDR.DataHolder.Repository/Infrastructure/HealthCheckStatuses.cs b/Source/CDR.DataHolder.Repository/Infrastructure/HealthCheckStatuses.cs new file mode 100644 index 0000000..71ea230 --- /dev/null +++ b/Source/CDR.DataHolder.Repository/Infrastructure/HealthCheckStatuses.cs @@ -0,0 +1,26 @@ +namespace CDR.DataHolder.Repository.Infrastructure +{ + public enum SeedingStatus + { + NotStarted, + Succeeded, + Failed, + NotConfigured + } + + public enum AppStatus + { + Started, + Shutdown, + NotStarted + } + public class HealthCheckStatuses + { + public bool IsMigrationDone { get; set; } = false; + + public SeedingStatus SeedingStatus { get; set; } = SeedingStatus.NotStarted; + + public AppStatus AppStatus { get; set; } = AppStatus.NotStarted; + + } +} diff --git a/Source/CDR.DataHolder.Resource.API.UnitTests/CDR.DataHolder.Resource.API.UnitTests.csproj b/Source/CDR.DataHolder.Resource.API.UnitTests/CDR.DataHolder.Resource.API.UnitTests.csproj index 8956117..c50d641 100644 --- a/Source/CDR.DataHolder.Resource.API.UnitTests/CDR.DataHolder.Resource.API.UnitTests.csproj +++ b/Source/CDR.DataHolder.Resource.API.UnitTests/CDR.DataHolder.Resource.API.UnitTests.csproj @@ -3,9 +3,9 @@ net6.0 false - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.Resource.API.UnitTests/Fixtures/SeedDataFixture.cs b/Source/CDR.DataHolder.Resource.API.UnitTests/Fixtures/SeedDataFixture.cs index 6e79cef..01248f8 100644 --- a/Source/CDR.DataHolder.Resource.API.UnitTests/Fixtures/SeedDataFixture.cs +++ b/Source/CDR.DataHolder.Resource.API.UnitTests/Fixtures/SeedDataFixture.cs @@ -44,12 +44,15 @@ public SeedDataFixture() services.AddScoped(); services.AddSingleton(x => new IdPermanenceManager(configuration)); + services.AddSingleton(); + this.ServiceProvider = services.BuildServiceProvider(); // Migrate the database to the latest version during application startup. var context = this.ServiceProvider.GetRequiredService(); var loggerFactory = this.ServiceProvider.GetRequiredService(); var logger = loggerFactory.CreateLogger("UnitTests"); + var healthCheckStatuses = this.ServiceProvider.GetRequiredService(); loggerFactory.AddSerilog(); @@ -64,7 +67,7 @@ public SeedDataFixture() if (!string.IsNullOrEmpty(seedDataFilePath)) { logger.LogInformation("Seed data file found within configuration. Attempting to seed the repository from the seed data..."); - Task.Run(() => context.SeedDatabaseFromJsonFile(seedDataFilePath, logger, seedDataOverwrite, offsetDates)).Wait(); + Task.Run(() => context.SeedDatabaseFromJsonFile(seedDataFilePath, logger, healthCheckStatuses, seedDataOverwrite, offsetDates)).Wait(); } } } diff --git a/Source/CDR.DataHolder.Resource.API/CDR.DataHolder.Resource.API.csproj b/Source/CDR.DataHolder.Resource.API/CDR.DataHolder.Resource.API.csproj index 4a94d34..e37524d 100644 --- a/Source/CDR.DataHolder.Resource.API/CDR.DataHolder.Resource.API.csproj +++ b/Source/CDR.DataHolder.Resource.API/CDR.DataHolder.Resource.API.csproj @@ -3,9 +3,9 @@ net6.0 win-x64;linux-x64 - 1.3.1 - 1.3.1 - 1.3.1 + 1.3.2 + 1.3.2 + 1.3.2 diff --git a/Source/CDR.DataHolder.Resource.API/Certificates/tls-mock-data-holder-energy.pfx b/Source/CDR.DataHolder.Resource.API/Certificates/tls-mock-data-holder-energy.pfx index 11d4587..62ecde9 100644 Binary files a/Source/CDR.DataHolder.Resource.API/Certificates/tls-mock-data-holder-energy.pfx and b/Source/CDR.DataHolder.Resource.API/Certificates/tls-mock-data-holder-energy.pfx differ