Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
v1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
CDR-AndrewG authored Aug 2, 2022
2 parents 3c48f30 + 028e9b0 commit 5abc2a6
Show file tree
Hide file tree
Showing 75 changed files with 3,714 additions and 245 deletions.
43 changes: 43 additions & 0 deletions .azuredevops/pipelines/build-dr-func.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
trigger:
- develop
- main
- releases/*

pool:
vmImage: windows-latest

steps:
- task: UseDotNet@2
displayName: 'Install .NET 6 SDK'
inputs:
packageType: 'sdk'
version: '6.0.x'
performMultiLevelLookup: true

- script: |
ls
cd Source/CDR.GetDataRecipients
ls
dotnet restore
dotnet build --configuration Release
- task: DotNetCoreCLI@2
inputs:
command: publish
arguments: '--configuration Release --output publish_output'
projects: 'Source/CDR.GetDataRecipients/CDR.GetDataRecipients.csproj'
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false

- task: ArchiveFiles@2
displayName: 'Archive Files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
includeRootFolder: false
archiveFile: '$(System.DefaultWorkingDirectory)/CDR.GetDataRecipients.zip'

- task: PublishBuildArtifacts@1
inputs:
PathToPublish: '$(System.DefaultWorkingDirectory)/CDR.GetDataRecipients.zip'
artifactName: 'functions'
63 changes: 28 additions & 35 deletions .azuredevops/pipelines/build-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ resources:

trigger:
- develop
- main
- releases/*

pool:
vmImage: ubuntu-latest
Expand All @@ -24,7 +26,7 @@ steps:
displayName: Build mock-register image
inputs:
command: build
Dockerfile: $(Build.SourcesDirectory)/sb-mock-register/Source/Dockerfile
Dockerfile: $(Build.SourcesDirectory)/sb-mock-register/Source/Dockerfile.for-testing
buildContext: $(Build.SourcesDirectory)/sb-mock-register/Source
repository: mock-register
tags: latest
Expand All @@ -39,16 +41,6 @@ steps:
repository: mock-data-holder-energy
tags: latest

# Build mock-data-holder-energy-unit-tests
- task: Docker@2
displayName: Build mock-data-holder-energy-unit-tests image
inputs:
command: build
Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/Dockerfile.unit-tests
buildContext: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source
repository: mock-data-holder-energy-unit-tests
tags: latest

# Build mock-data-holder-energy-integration-tests
- task: Docker@2
displayName: Build mock-data-holder-energy-integration-tests image
Expand All @@ -59,30 +51,23 @@ steps:
repository: mock-data-holder-energy-integration-tests
tags: latest

# Build mock-data-holder-energy-for-testing
- task: Docker@2
displayName: Build mock-data-holder-energy-for-testing image
inputs:
command: build
Dockerfile: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/Dockerfile.for-testing
buildContext: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source
repository: mock-data-holder-energy-for-testing
tags: latest

# List docker images
- task: Docker@2
displayName: List Docker images
condition: always()
inputs:
command: images

# Run unit tests
- task: DockerCompose@0
displayName: Unit Tests - Up
inputs:
action: Run a Docker Compose command
dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/docker-compose.UnitTests.yml
dockerComposeCommand: up --abort-on-container-exit --exit-code-from mock-data-holder-energy-unit-tests

# Remove unit tests
- task: DockerCompose@0
displayName: Unit Tests - Down
condition: always()
inputs:
action: Run a Docker Compose command
dockerComposeFile: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/docker-compose.UnitTests.yml
dockerComposeCommand: down

# Run integration tests
- task: DockerCompose@0
displayName: Integration Tests - Up
Expand Down Expand Up @@ -131,12 +116,6 @@ steps:
condition: always()
artifact: Mock-Data-Holder-Energy - Logs

# Publish mock-data-holder unit tests results
- publish: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-unit-tests/testresults
displayName: Publish unit tests
condition: always()
artifact: Mock-Data-Holder-Energy - Unit tests

# Publish mock-data-holder integration tests results
- publish: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/_temp/mock-data-holder-energy-integration-tests/testresults
displayName: Publish integration tests
Expand Down Expand Up @@ -175,4 +154,18 @@ steps:
- publish: $(Build.SourcesDirectory)/sb-mock-data-holder-energy/Source/CDR.DataHolder.Repository/efbundle
displayName: Publish EF Migration bundle
condition: always()
artifact: Database Migration Scripts
artifact: Database Migration Scripts

- task: PublishTestResults@2
displayName: 'Surface Integration Test TRX results to devops'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'VSTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/results.trx'
#searchFolder: '$(System.DefaultWorkingDirectory)' # Optional
#mergeTestResults: false # Optional
#failTaskOnFailedTests: false # Optional
#testRunTitle: # Optional
#buildPlatform: # Optional
#buildConfiguration: # Optional
#publishRunAttachments: true # Optional
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./Source
file: ./Source/Dockerfile
file: ./Source/Dockerfile.for-testing
platforms: linux/amd64,linux/arm64
push: ${{ github.repository_owner == 'ConsumerDataRight' && github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
# Build mock-data-holder-energy image
- name: Build the mock-data-holder-energy image
run: |
docker build ./mock-data-holder-energy/Source --file ./mock-data-holder-energy/Source/Dockerfile --tag mock-data-holder-energy:latest
docker build ./mock-data-holder-energy/Source --file ./mock-data-holder-energy/Source/Dockerfile.for-testing --tag mock-data-holder-energy:latest
# Build mock-data-holder-energy-unit-tests image
- name: Build the mock-data-holder-energy-unit-tests-energy image
run: |
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.0.0] - 2022-07-22
### Added
- Azure function to perform Data Recipient discovery by polling the Get Data Recipients API of the Register.

### Changed
- First version of the Mock Data Holder Energy deployed into the CDR Sandbox.
- Updated Get Energy Concessions schema to match Consumer Data Standards 1.17.0.

## [0.1.1] - 2022-06-09
### Changed
- Person information in seed data.
Expand Down
66 changes: 66 additions & 0 deletions Help/azurefunctions/HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<h2>Azure Functions</h2>
<div style="margin-left:18px;">
The Mock Data Holder Energy solution contains an azure function project.<br />
The GetDataRecipients function is used to get the list of Data Recipients<br />
from the Mock Register and update the Mock Data Hoder Energy repository.<br />
</div>

<h2>To Run and Debug Azure Functions</h2>
<div style="margin-left:18px;">
The following procedures can be used to run the functions in a local development environment for evaluation of the functions.
<br />

<div style="margin-top:6px;margin-bottom:6px;">
1) Start the Mock Register and the Mock Data Holder Energy solutions.
</div>

<div style="margin-top:6px;">
2) Start the Azure Storage Emulator (Azurite):
</div>
<div style="margin-left:18px;margin-bottom:6px;">
using a MS Windows command prompt:<br />
</div>

```
md C:\azurite
cd "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator"
azurite --silent --location c:\azurite --debug c:\azurite\debug.log
```

<div style="margin-left:18px;">
Noting this is only required to be performed once, it will then be listening on ports - 10000, 10001 and 10002<br />
when debugging is started from MS Visual Studio by selecting CDR.GetDataRecipients as the startup project<br />
(by starting a debug instance using F5 or Debug > Start Debugging)
<br />
</div>
<div style="margin-left:18px;margin-bottom:6px;">
or by using a MS Windows command prompt:<br />
</div>

```
navigate to .\mock-data-holder-energy\Source\CDR.GetDataRecipients<br />
func start --verbose<br />
```

<p>3) Open the Mock Data Holder Energy in MS Visual Studio, select CDR.GetDataRecipients as the startup project.</p>

<p>4) Start each debug instances (F5 or Debug > Start Debugging), this will simulate the discovery of Data Recipients and the</p>
<div style="margin-left:18px;margin-top:-12px;">
updating of the data in the Mock Data Holder Energy repositories.
</div>

<div style="margin-left:18px;margin-top:12px;margin-bottom:6px;">
Noting the below sql scripts are used to observe the results.<br />
</div>

```
SELECT * FROM [cdr-mdhe].[dbo].[LegalEntity]
SELECT * FROM [cdr-mdhe].[dbo].[Brand]
SELECT * FROM [cdr-mdhe].[dbo].[SoftwareProduct]
SELECT * FROM [cdr-mdhe].[dbo].[LogEvents_DRService]
```

<h2>To Build Azure Functions</h2>
<div style="margin-left:18px;">
dotnet SDK 6.0.30x or higher is required. Latest SDK can be found from the link https://microsoft.com/net
<br />
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Consumer Data Right Logo](https://raw.githubusercontent.com/ConsumerDataRight/mock-data-holder-energy/main/cdr-logo.png)

[![Consumer Data Standards v1.16.0](https://img.shields.io/badge/Consumer%20Data%20Standards-v1.16.0-blue.svg)](https://consumerdatastandardsaustralia.github.io/standards-archives/standards-1.16.0/#introduction)
[![Consumer Data Standards v1.17.0](https://img.shields.io/badge/Consumer%20Data%20Standards-v1.17.0-blue.svg)](https://consumerdatastandardsaustralia.github.io/standards/#introduction)
[![FAPI 1.0 Advanced Profile](https://img.shields.io/badge/FAPI%201.0-orange.svg)](https://openid.net/specs/openid-financial-api-part-2-1_0.html)
[![made-with-dotnet](https://img.shields.io/badge/Made%20with-.NET-1f425Ff.svg)](https://dotnet.microsoft.com/)
[![made-with-csharp](https://img.shields.io/badge/Made%20with-C%23-1f425Ff.svg)](https://docs.microsoft.com/en-us/dotnet/csharp/)
Expand All @@ -13,7 +13,7 @@ This project includes source code, documentation and instructions for a Consumer
This repository contains a mock implementation of a Mock Data Holder Energy and is offered to help the community in the development and testing of their CDR solutions.

## Mock Data Holder Energy - Alignment
The Mock Data Holder Energy aligns to [v1.16.0](https://consumerdatastandardsaustralia.github.io/standards-archives/standards-1.16.0/#introduction) of the [Consumer Data Standards](https://consumerdatastandardsaustralia.github.io/standards/#introduction).
The Mock Data Holder Energy aligns to [v1.17.0](https://consumerdatastandardsaustralia.github.io/standards/#introduction) of the [Consumer Data Standards](https://consumerdatastandardsaustralia.github.io/standards/#introduction).
The Mock Data Holder Energy is based on the [Mock Data Holder](https://github.com/ConsumerDataRight/mock-data-holder) codebase. The [Mock Data Holder](https://github.com/ConsumerDataRight/mock-data-holder) has passed v3.2 of the [Conformance Test Suite for Data Holders](https://www.cdr.gov.au/for-providers/conformance-test-suite-data-holders). Conformance Testing specific to the Mock Data Holder Energy has not yet been completed.
The Mock Data Holder Energy is compliant with the [FAPI 1.0 Advanced Profile](https://openid.net/specs/openid-financial-api-part-2-1_0.html).
The Mock Data Holder Energy aligns to [FAPI 1.0 Migration Phase 2](https://consumerdatastandardsaustralia.github.io/standards-archives/standards-1.16.0/#authentication-flows).
Expand Down Expand Up @@ -115,6 +115,9 @@ The following diagram outlines the high level architecture of the Mock Data Hold

[<img src="https://raw.githubusercontent.com/ConsumerDataRight/mock-data-holder-energy/main/mock-data-holder-energy-architecture.png" height='600' width='800' alt="Mock Data Holder Energy - Architecture"/>](https://raw.githubusercontent.com/ConsumerDataRight/mock-data-holder-energy/main/mock-data-holder-energy-architecture.png)

Get Data Recipients discovery Azure Function:

[<img src="mock-data-holder-discovery-architecture.png" height='250' width='360' alt="Get Data Recipients discovery function"/>](mock-data-holder-discovery-architecture.png)

## Mock Data Holder Energy - Components
The Mock Data Holder Energy contains the following components:
Expand All @@ -140,6 +143,9 @@ The Mock Data Holder Energy contains the following components:
- Not part of the Consumer Data Standards, but allows for the maintenance of data in the Mock Data Holder Energy repository.
- Also includes trigger points to refresh the Data Recipient, Data Recipient Status and Software Product Status from the Mock Register.
- A user interface may be added at some time in the future to provide user friendly access to the repository data.
- Azure Function
- An Azure Function that can automate the continuous Get Data Recipients discovery process.
- To get help on the Azure Functions, see the [help guide](./Help/azurefunctions/HELP.md).
- Repository
- A SQL database containing Mock Data Holder Energy data.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<Version>0.1.0</Version>
<FileVersion>0.1.0</FileVersion>
<AssemblyVersion>0.1.0</AssemblyVersion>
<Version>1.0.0</Version>
<FileVersion>1.0.0</FileVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -35,6 +35,10 @@
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.6.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CDR.DataHolder.API.Infrastructure\CDR.DataHolder.API.Infrastructure.csproj" />
</ItemGroup>

<ItemGroup>
<Resource Include="Certificates\server.pfx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using CDR.DataHolder.API.Infrastructure.Exceptions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

Expand All @@ -11,7 +12,6 @@ namespace CDR.DataHolder.API.Gateway.mTLS.Certificates
/// </summary>
public class CertificateValidator : ICertificateValidator
{
private const string ROOT_CA_SUBJECT = "CN=Mock CDR CA, OU=CDR, O=ACCC, L=Canberra, S=ACT, C=AU";
private readonly ILogger<CertificateValidator> _logger;
private readonly IConfiguration _config;

Expand All @@ -21,7 +21,7 @@ public CertificateValidator(ILogger<CertificateValidator> logger, IConfiguration
_config = config;
}

public bool IsValid(X509Certificate2 clientCert)
public void ValidateClientCertificate(X509Certificate2 clientCert)
{
_logger.LogInformation($"Validating certificate within the {nameof(CertificateValidator)}");

Expand All @@ -34,7 +34,8 @@ public bool IsValid(X509Certificate2 clientCert)
var rootCACertificate = new X509Certificate2(_config.GetValue<string>("RootCACertificate:Path"));
var ch = new X509Chain();
ch.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
ch.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
ch.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;
ch.ChainPolicy.CustomTrustStore.Clear();
ch.ChainPolicy.CustomTrustStore.Add(rootCACertificate);
ch.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;

Expand All @@ -44,16 +45,13 @@ public bool IsValid(X509Certificate2 clientCert)
}
catch (Exception ex)
{
throw new ArgumentException("The certificate chain cannot be discovered from the provided client certificate.", ex);
throw new ClientCertificateException("The certificate chain cannot be discovered from the provided client certificate.", ex);
}

if (ch.ChainStatus.Any())
{
_logger.LogError("The client cert could not be verified to have been issued by '{subject}'. {statusInformation}", ROOT_CA_SUBJECT, ch.ChainStatus[0].StatusInformation);
return false;
throw new ClientCertificateException(ch.ChainStatus.First().StatusInformation);
}

return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace CDR.DataHolder.API.Gateway.mTLS.Certificates
{
public interface ICertificateValidator
{
bool IsValid(X509Certificate2 clientCert);
void ValidateClientCertificate(X509Certificate2 clientCert);
}
}
Loading

0 comments on commit 5abc2a6

Please sign in to comment.