Skip to content

Commit

Permalink
Merge branch 'master' into RDCC-6706-SRD_WireMock_response_enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
manukundloo-hmcts authored Nov 13, 2023
2 parents 2296e87 + a4cbef4 commit aa1eb7e
Show file tree
Hide file tree
Showing 90 changed files with 4,168 additions and 562 deletions.
21 changes: 5 additions & 16 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
{
"enabledManagers": ["helm-requirements","gradle-wrapper","regex"],
"helm-requirements":
{
"fileMatch": ["\\Chart.yaml$"],
"aliases": {
"hmctspublic": "https://hmctspublic.azurecr.io/helm/v1/repo/"
}
},
"regexManagers": [
{
"fileMatch": ["^Dockerfile$"],
"matchStrings": [
"datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sARG .*?_VERSION=(?<currentValue>.*)\\s"
]
}
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>hmcts/.github:renovate-config",
"local>hmcts/.github//renovate/automerge-minor"
]
}
}
6 changes: 1 addition & 5 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def vaultOverrides = [
]

// Configure branches to sync with master branch
def branchesToSync = ['demo', 'ithc', 'perftest']
def branchesToSync = []

// Vars for Kubernetes PACT
env.PACT_BROKER_FULL_URL = 'https://pact-broker.platform.hmcts.net'
Expand All @@ -58,22 +58,18 @@ withPipeline(type, product, component) {

before('functionalTest:preview') {
env.execution_environment = "preview"
env.TEST_URL = "http://rd-caseworker-ref-api-preview.preview.platform.hmcts.net"
}

before('functionalTest:aat') {
env.execution_environment = "aat"
env.TEST_URL = "http://rd-caseworker-ref-api-aat.aat.platform.hmcts.net"
}

before('smoketest:preview') {
env.execution_environment = "preview"
env.TEST_URL = "http://rd-caseworker-ref-api-preview.preview.platform.hmcts.net"
}

before('smoketest:aat') {
env.execution_environment = "aat"
env.TEST_URL = "http://rd-caseworker-ref-api-aat.aat.platform.hmcts.net"
}

// Sync demo and perftest with master branch
Expand Down
59 changes: 48 additions & 11 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!groovy
properties([
pipelineTriggers([cron('21 01 * * *')]), // scheduling to trigger jenkins job
pipelineTriggers([cron('21 01 * * 1-5')]), // scheduling to trigger jenkins job
parameters([
string(name: 'ENVIRONMENT', defaultValue: 'aat', description: 'Environment to test'),
string(name: 'URL_TO_TEST', defaultValue: 'http://rd-caseworker-ref-api-aat.service.core-compute-aat.internal', description: 'The URL you want to run these tests against'),
string(name: 'SecurityRules',
defaultValue: 'http://raw.githubusercontent.com/hmcts/security-test-rules/master/conf/security-rules.conf',
Expand All @@ -13,7 +14,7 @@ properties([

def type = "java"
def product = "rd"
def component = "caseworker-ref-api.jar"
def component = "caseworker-ref-api"

def secrets = [
's2s-${env}': [
Expand All @@ -22,7 +23,15 @@ def secrets = [
'rd-${env}': [
secret('CA-REF-OAUTH2-CLIENT-SECRET', 'CA_REF_OAUTH2_CLIENT_SECRET'),
secret('CA-REF-OAUTH2-CLIENT-ID', 'CA_REF_OAUTH2_CLIENT_ID'),
secret('LD-SDK-KEY', 'LD_SDK_KEY')
secret('LD-SDK-KEY', 'LD_SDK_KEY'),
secret('OAUTH2-CLIENT-SECRET', 'OAUTH2_CLIENT_SECRET'),
secret('OAUTH2-CLIENT-AUTH', 'OAUTH2_CLIENT_AUTH'),
secret('OAUTH2-CLIENT-ID', 'OAUTH2_CLIENT_ID'),
secret('caseworker-ref-api-POSTGRES-HOST', 'FUNC_DATABASE_HOST'),
secret('caseworker-ref-api-POSTGRES-PASS', 'FUNC_DATABASE_PASS'),
secret('caseworker-ref-api-POSTGRES-USER', 'FUNC_DATABASE_USER'),
secret('caseworker-ref-api-POSTGRES-DATABASE', 'FUNC_DATABASE_NAME'),
secret('caseworker-ref-api-POSTGRES-PORT', 'FUNC_DATABASE_PORT')
]
]

Expand All @@ -40,8 +49,16 @@ def vaultOverrides = [
'spreview': 'saat'
]


import uk.gov.hmcts.contino.AppPipelineConfig

def subscription = "nonprod"
def config = new AppPipelineConfig()
config.vaultSecrets = secrets

withNightlyPipeline(type, product, component) {

env.TEST_URL = params.URL_TO_TEST
env.S2S_URL_FOR_TESTS = "http://rpe-service-auth-provider-aat.service.core-compute-aat.internal"
env.IDAM_URL = "https://idam-api.aat.platform.hmcts.net"
env.TEST_URL = "http://rd-caseworker-ref-api-aat.service.core-compute-aat.internal"
Expand All @@ -56,27 +73,47 @@ withNightlyPipeline(type, product, component) {
enableSecurityScan()
enableFortifyScan()

afterSuccess('mutationTest') {
afterSuccess('fullFunctionalTest') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/site/serenity/**/*'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*'

publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "build/reports/pitest",
reportDir : "target/site/serenity/",
reportFiles : "index.html",
reportName : "Mutation Test Report"
reportName : "Functional Tests Report"
]

print "calling delete script for nightly"
withSubscription(subscription) {
withTeamSecrets(config, params.ENVIRONMENT) {
deleteFunctionalDbData()
}
}
print "completed delete script for nightly"
}

afterSuccess('fullFunctionalTest') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/site/serenity/**/*'
steps.archiveArtifacts allowEmptyArchive: true, artifacts: 'build/reports/**/*'
afterSuccess('mutationTest') {
publishHTML target: [
allowMissing : true,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : "target/site/serenity/",
reportDir : "build/reports/pitest",
reportFiles : "index.html",
reportName : "Functional Tests Report"
reportName : "Mutation Test Report"
]
}
}

def deleteFunctionalDbData() {
withDocker('jbergknoff/postgresql-client', "--entrypoint='' -e PGPASSWORD=${FUNC_DATABASE_PASS} -v ${WORKSPACE}/deletescript/:/deletescript") {
sh "chmod +x /deletescript/delete-functional-data.sh"
sh "/deletescript/delete-functional-data.sh \
${FUNC_DATABASE_USER} \
${FUNC_DATABASE_NAME} \
${FUNC_DATABASE_HOST} \
${FUNC_DATABASE_PORT}"
}
}
65 changes: 60 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,43 @@ CaseWorker Ref API

Provides Case worker user profile data to clients, implemented as a Java/SpringBoot application.

for more Info about the CaseWorker, Please refer to the confluence

Architecture of the Caseworker (https://tools.hmcts.net/confluence/pages/viewpage.action?pageId=1444742328) and

Business of the CaseWorker (https://tools.hmcts.net/confluence/display/RTRD/Caseworker+Reference+Data)



### Prerequisites

To run the project you will need to have the following installed:

* Java 11
* Java 17
* Docker

For information about the software versions used to build this API and a complete list of it's dependencies see build.gradle

While not essential, it is highly recommended to use the pre-push git hook included in this repository to ensure that all tests are passing. This can be done by running the following command:
`$ git config core.hooksPath .githooks`

### Environment Vars

If running locally for development or testing you will need to set the following environment variables

* export POSTGRES_USERNAME=dbrefdata
* export POSTGRES_PASSWORD=<The database password. Please check with the dev team for more information.>
* export client-secret=<The actual client-secret. Please check with the dev team for more information.>
* export totp_secret=<The actual totp_secret. Please check with the dev team for more information.>
* export password=<The actual password. Please check with the dev team for more information.>
* export key=<The actual key. Please check with the dev team for more information.>

### Running the application

Please Make sure you are connected to the VPN before running the Application.
(https://portal.platform.hmcts.net/vdesk/webtop.eui?webtop=/Common/webtop_full&webtop_type=webtop_full)


To run the API quickly use the docker helper script as follows:

```
Expand All @@ -29,7 +55,7 @@ docker-compose up
```


Alternatively, you can start the application from the current source files using Gradle as follows:
After, you can start the application from the current source files using Gradle as follows:

```
./gradlew clean bootRun
Expand All @@ -46,7 +72,7 @@ If required, to run with a low memory consumption, the following can be used:
To understand if the application is working, you can call it's health endpoint:

```
curl http://localhost:8091/health
curl http://localhost:8095/health
```

If the API is running, you should see this response:
Expand All @@ -55,6 +81,12 @@ If the API is running, you should see this response:
{"status":"UP"}
```

If the API is running, you can see API's in swagger :

```
http://localhost:8095/swagger-ui.html
```

### DB Initialisation˙

The application uses a Postgres database which can be run through a docker container on its own if required.
Expand Down Expand Up @@ -112,7 +144,7 @@ http://pitest.org/
To test in Postman the easiest way is to start this service using the ./bin/run-in-docker.sh script. The in postman paste the following script:

```
pm.sendRequest('http://127.0.0.1:8089/token', function (err, res) {
pm.sendRequest('http://127.0.0.1:8095/token', function (err, res) {
if (err) {
console.log(err);
} else {
Expand All @@ -129,8 +161,31 @@ ServiceAuthorization: Bearer {{token}}
Authorization : Bearer copy IDAM access token

### Contract testing with pact

To publish against remote broker:
`./gradlew pactPublish`

Turn on VPN and verify on url `https://pact-broker.platform.hmcts.net/`
The pact contract(s) should be published


To publish against local broker:
Uncomment out the line found in the build.gradle:
`pactBrokerUrl = 'http://localhost:9292'`
comment out the real broker

Start the docker container from the root dir run
`docker-compose -f broker-compose.yml up`

Publish via the gradle command
`./gradlew pactPublish`

Once Verify on url `http://localhost:9292/`
The pact contract(s) should be published

Remember to return the localhost back to the remote broker

Please refer to the confluence on how to run and publish PACT tests.
for more information, Please refer to the confluence on how to run and publish PACT tests.
https://tools.hmcts.net/confluence/display/RTRD/PACT+testing


2 changes: 2 additions & 0 deletions audit.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"10112_Session Management Response Identified_http://rd-caseworker-ref-api-aat.service.core-compute-aat.internal/v2/api-docs_GET": "ignore",
"10049_Non-Storable Content_http://rd-caseworker-ref-api-aat.service.core-compute-aat.internal/v2/api-docs_GET": "ignore",
"10021_X-Content-Type-Options Header Missing_http://rd-caseworker-ref-api-aat.service.core-compute-aat.internal/_GET": "ignore",
"10010_Cookie No HttpOnly Flag_http://rd-caseworker-ref-api-aat.service.core-compute-aat.internal/_GET": "ignore",
"100001_Unexpected Content-Type was returned_http://rd-caseworker-ref-api-aat.service.core-compute-aat.internal/_GET": "ignore",
Expand Down
Loading

0 comments on commit aa1eb7e

Please sign in to comment.