Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFPL-1890: Setup WA in preview #5703

Merged
merged 30 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3e29b03
DFPL-1890: Copy over initial config work from DFPL-2537
DanCatchpole Nov 12, 2024
626c711
make scripts executable
DanCatchpole Nov 12, 2024
ad3ae14
add RAS url
DanCatchpole Nov 12, 2024
370244f
DFPL-1890: Add initial WA setup
DanCatchpole Nov 12, 2024
3a83966
import github API
DanCatchpole Nov 12, 2024
e54e20b
Bumping chart version/ fixing aliases
hmcts-jenkins-d-to-i[bot] Nov 12, 2024
f1c87cb
add wa urls to xui-webapp
DanCatchpole Nov 12, 2024
f301d08
Merge remote-tracking branch 'origin/DFPL-1890' into DFPL-1890
DanCatchpole Nov 12, 2024
7d2df85
move uploading DMNs
DanCatchpole Nov 14, 2024
6421ea1
fix sh script
DanCatchpole Nov 14, 2024
e8d1e84
change checkForLabel approach
DanCatchpole Nov 14, 2024
9d88d84
abstract out checking for WA
DanCatchpole Nov 14, 2024
c3c79ac
params...
DanCatchpole Nov 14, 2024
5398c2d
dmnBranch
DanCatchpole Nov 14, 2024
05b0cb3
update cd dir from iac's version
DanCatchpole Nov 14, 2024
e6cc923
add env vars
DanCatchpole Nov 14, 2024
fef8476
wrong dir...
DanCatchpole Nov 14, 2024
f32dd31
update RAS urls
DanCatchpole Nov 14, 2024
721014d
update authorised services
DanCatchpole Nov 14, 2024
11d7aa2
update cron schedule
DanCatchpole Nov 14, 2024
781d485
lower case
DanCatchpole Nov 14, 2024
e750f1f
load bpmn + dmn tables
DanCatchpole Nov 14, 2024
4484bc5
fix roles for ctsc-team-leader to see all tasks
DanCatchpole Nov 14, 2024
16f2eaf
add south-west judge
DanCatchpole Nov 14, 2024
1323a2f
add testing HCAs
DanCatchpole Nov 15, 2024
bc9cefc
Merge branch 'master' into DFPL-1890
DanCatchpole Nov 15, 2024
c940e38
Merge branch 'master' into DFPL-1890
DanCatchpole Nov 20, 2024
bfdb50b
Merge branch 'master' into DFPL-1890
DanCatchpole Nov 20, 2024
ae18d10
Merge branch 'master' into DFPL-1890
DanCatchpole Nov 27, 2024
d83ccd3
Merge branch 'master' into DFPL-1890
DanCatchpole Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@Library("Infrastructure")
import uk.gov.hmcts.contino.AppPipelineConfig
import uk.gov.hmcts.contino.AppPipelineDsl
import uk.gov.hmcts.contino.GithubAPI

def type = "java"
def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this)
Expand Down Expand Up @@ -48,7 +49,8 @@ def otherSecrets = [
],
'fpl-${env}': [
secret('definition-importer-username', 'CCD_CONFIGURER_IMPORTER_USERNAME'),
secret('definition-importer-password', 'CCD_CONFIGURER_IMPORTER_PASSWORD')
secret('definition-importer-password', 'CCD_CONFIGURER_IMPORTER_PASSWORD'),
secret('fpl-case-service-s2s-secret', 'FPL_S2S_SECRET')
]
]

Expand Down Expand Up @@ -149,6 +151,27 @@ def setupShutteringSecret() {
}
}

def deployWADmns() {
def githubApi = new GithubAPI(this)

def waStandaloneBranch = "master"
// For testing DMNs, change this to the branch on the DMN repo, but ensure it is changed back to master before merging
def dmnBranch = "master"

echo "Checking if we should use WA"
if (githubApi.checkForLabel(env.BRANCH_NAME, 'enable_wa')) {
env.SERVICES_WORK_ALLOCATION_TASK_API = "http://fpl-case-api-pr-${CHANGE_ID}-wa-task-management-api"
env.SERVICES_WA_WORKFLOW_API_URL = "http://fpl-case-api-pr-${CHANGE_ID}-wa-workflow-api"
env.WA_SUPPORTED_JURISDICTIONS = "PUBLICLAW"
echo "WA enabled, loading DMNs"
sh """
eval \$(./bin/variables/load-preview-environment-variables.sh ${CHANGE_ID})
./bin/pull-latest-dmn-files.sh ${dmnBranch}
./bin/pull-camunda-bpmn-files.sh ${waStandaloneBranch}
./bin/import-dmn-diagram.sh . publiclaw fpl
"""
}
}

// Vars for Kubernetes
env.PACT_BROKER_FULL_URL = 'https://pact-broker.platform.hmcts.net'
Expand Down Expand Up @@ -237,11 +260,14 @@ withPipeline(type, product, component) {
sh """
eval \$(./bin/variables/load-preview-environment-variables.sh ${CHANGE_ID})
./bin/add-ccd-user-roles.sh
./bin/add-role-assignments.sh
"""

archiveCoreCaseDataDefinitions('preview')
uploadCoreCaseDataDefinitions('preview', '0')

deployWADmns()

env.IDAM_API_URL = "https://idam-api.aat.platform.hmcts.net"
env.CASE_SERVICE_URL = "https://fpl-case-service-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.URL = "https://xui-fpl-case-service-pr-${CHANGE_ID}.preview.platform.hmcts.net"
Expand Down
2 changes: 2 additions & 0 deletions bin/add-ccd-user-roles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ ${dir}/utils/ccd-add-role.sh "citizen"
${dir}/utils/ccd-add-role.sh "caseworker-ras-validation"
${dir}/utils/ccd-add-role.sh "caseworker-wa-task-configuration"
${dir}/utils/ccd-add-role.sh "GS_profile"
${dir}/utils/ccd-add-role.sh "ctsc"
${dir}/utils/ccd-add-role.sh "hearing-centre-admin"
30 changes: 30 additions & 0 deletions bin/add-role-assignments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -eu

dir=$(dirname ${0})

jq -c '(.[])' service/src/cftlib/resources/cftlib-am-role-assignments.json | while read user; do
email=$(jq -r '.email' <<< $user)
idamId=$(jq -r '.id' <<< $user)
password=${SYSTEM_UPDATE_USER_PASSWORD}

if [[ $email == *"ejudiciary"* ]]; then
password=${E2E_TEST_JUDGE_PASSWORD}
fi

jq -c '(.roleAssignments[])' <<< $user | while read assignment; do
roleName=$(jq -r '.roleName' <<< $assignment)
roleCategory=$(jq -r '.roleCategory' <<< $assignment)
classification=$(jq -r '.classification' <<< $assignment)
grantType=$(jq -r '.grantType' <<< $assignment)
readOnly=$(jq -r '.readOnly' <<< $assignment)
attributes=$(jq -r '.attributes | tostring' <<< $assignment)

authorisations=$(jq -r '.authorisations | tostring' <<< $assignment)

echo "Creating '${roleName}' assignment for user ${email}"
${dir}/utils/organisational-role-assignment.sh $email $password $classification $roleName $attributes $roleCategory $authorisations $grantType
done
echo
done
66 changes: 66 additions & 0 deletions bin/import-dmn-diagram.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

set -eu
workspace=${1}
tenant_id=${2}
product=${3}

s2sSecret=${FPL_S2S_SECRET:-AABBCCDDEEFFGGHH}

serviceToken=$($(realpath $workspace)/bin/utils/idam-lease-service-token.sh fpl_case_service \
$(docker run --rm hmctspublic.azurecr.io/imported/toolbelt/oathtool --totp -b ${s2sSecret}))

camundaFilepath="$(realpath $workspace)/camunda"
if [ ! -d ${camundaFilepath} ]; then
echo "Directory with camunda definition files is missing: ${camundaFilepath}";
fi

# Load BPMN files
for file in $(find ${camundaFilepath} -name '*.bpmn')
do
echo "file=@${camundaFilepath}/$(basename ${file})";
uploadResponse=$(curl --insecure -v --silent -w "\n%{http_code}" --show-error -X POST \
${CAMUNDA_BASE_URL:-http://localhost:9404}/engine-rest/deployment/create \
-H "Accept: application/json" \
-H "ServiceAuthorization: Bearer ${serviceToken}" \
-F "deployment-name=$(basename ${file})" \
-F "deploy-changed-only=true" \
-F "file=@${camundaFilepath}/$(basename ${file})")

upload_http_code=$(echo "$uploadResponse" | tail -n1)
upload_response_content=$(echo "$uploadResponse" | sed '$d')

if [[ "${upload_http_code}" == '200' ]]; then
echo "$(basename ${file}) diagram uploaded successfully (${upload_response_content})";
continue;
fi

echo "$(basename ${file}) upload failed with http code ${upload_http_code} and response (${upload_response_content})"
continue;
done

# Load DMN files
for file in $(find ${camundaFilepath} -name '*.dmn')
do
echo "file=@${camundaFilepath}/$(basename ${file})";
uploadResponse=$(curl --insecure -v --silent -w "\n%{http_code}" --show-error -X POST \
${CAMUNDA_BASE_URL:-http://localhost:9404}/engine-rest/deployment/create \
-H "Accept: application/json" \
-H "ServiceAuthorization: Bearer ${serviceToken}" \
-F "deployment-name=$(basename ${file})" \
-F "deploy-changed-only=true" \
-F "deployment-source=$product" \
${tenant_id:+'-F' "tenant-id=$tenant_id"} \
-F "file=@${camundaFilepath}/$(basename ${file})")

upload_http_code=$(echo "$uploadResponse" | tail -n1)
upload_response_content=$(echo "$uploadResponse" | sed '$d')

if [[ "${upload_http_code}" == '200' ]]; then
echo "$(basename ${file}) diagram uploaded successfully (${upload_response_content})";
continue;
fi

echo "$(basename ${file}) upload failed with http code ${upload_http_code} and response (${upload_response_content})";
continue;
done
23 changes: 23 additions & 0 deletions bin/pull-camunda-bpmn-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

branchName=$1

#Checkout specific branch of wa-standalone-task-bpmn
git clone https://github.com/hmcts/wa-standalone-task-bpmn.git

if [ ! -d "./wa-standalone-task-bpmn" ]; then
exit 1
fi

echo "Switch to ${branchName} branch on wa-standalone-task-bpmn"
cd wa-standalone-task-bpmn
git checkout ${branchName}
cd ..

#Copy bpmn files to camunda folder
if [ ! -d "./camunda" ]; then
mkdir camunda
fi

cp -r ./wa-standalone-task-bpmn/src/main/resources/*.bpmn ./camunda
rm -rf ./wa-standalone-task-bpmn
23 changes: 23 additions & 0 deletions bin/pull-latest-dmn-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

branchName=$1

#Checkout specific branch of fpl-wa-task-configuration
git clone https://github.com/hmcts/fpl-wa-task-configuration.git

if [ ! -d "./fpl-wa-task-configuration" ]; then
exit 1
fi

echo "Switch to ${branchName} branch on fpl-wa-task-configuration"
cd fpl-wa-task-configuration
git checkout ${branchName}
cd ..

#Copy dmn files to camunda folder
if [ ! -d "./camunda" ]; then
mkdir camunda
fi

cp -r ./fpl-wa-task-configuration/src/main/resources/*.dmn ./camunda
rm -rf ./fpl-wa-task-configuration
11 changes: 11 additions & 0 deletions bin/utils/idam-user-id.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
## Usage: ./idam-user-id.sh [usertoken]
##
## Options:
## - usertoken: Token to get the user id for. Can be generated with ./idam-user-token.sh.
##
## Returns a valid IDAM user id for the given token.

USER_TOKEN=${1}

curl --silent --show-error -X GET "${IDAM_API_BASE_URL}/details" -H "accept: application/json" -H "authorization: Bearer ${USER_TOKEN}" | jq -r .id
55 changes: 55 additions & 0 deletions bin/utils/organisational-role-assignment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
## Usage: ./organisational-role-assignment.sh [username] [password] [role_classification] [role_name] [role_attributes] [microservice_name]
##
## Options:
## - username: Email for user. Default to `test@fake.hmcts.net`.
## - password: Password for user. Default to `Test`.
## - role_classification: Role assignment classification. Default to `PUBLIC`.
## - role_name: Name of the role for role-assignment. Default to `ctsc`.
##

USERNAME=${1:-test@fake.hmcts.net}
PASSWORD=${2:-Test}
ROLE_CLASSIFICATION="${3:-PUBLIC}"
ROLE_NAME="${4:-"ctsc"}"
ROLE_ATTRIBUTES="${5:-'{"jurisdiction":"PUBLICLAW"}'}"
ROLE_CATEGORY="${6:-"ADMIN"}"
AUTHORISATIONS="${7:-null}"
GRANT_TYPE="${8:-"STANDARD"}"

BASEDIR=$(dirname "$0")

USER_TOKEN=$($BASEDIR/idam-lease-user-token.sh $USERNAME $PASSWORD)
USER_ID=$($BASEDIR/idam-user-id.sh $USER_TOKEN)
SERVICE_TOKEN=$($BASEDIR/idam-lease-service-token.sh fpl_case_service \
$(docker run --rm hmctspublic.azurecr.io/imported/toolbelt/oathtool --totp -b ${FPL_S2S_SECRET:-AAAAAAAAAAAAAAAC}))

echo -e "\nCreating role assignment: \n User: ${USER_ID}\n Role name: ${ROLE_NAME}\n ROLE_CLASSIFICATION: ${ROLE_CLASSIFICATION}\n"

curl --silent --show-error -X POST "${ROLE_ASSIGNMENT_URL}/am/role-assignments" \
-H "accept: application/vnd.uk.gov.hmcts.role-assignment-service.create-assignments+json;charset=UTF-8;version=1.0" \
-H "Authorization: Bearer ${USER_TOKEN}" \
-H "ServiceAuthorization: Bearer ${SERVICE_TOKEN}" \
-H "Content-Type: application/json" \
-d '{ "roleRequest": {
"assignerId": "'"${USER_ID}"'",
"process": "staff-organisational-role-mapping",
"reference": "'"${USER_ID}/${ROLE_NAME}"'",
"replaceExisting": true,
"byPassOrgDroolRule": true
},
"requestedRoles": [
{
"actorIdType": "IDAM",
"actorId": "'"${USER_ID}"'",
"roleType": "ORGANISATION",
"roleName": "'"${ROLE_NAME}"'",
"classification": "'"${ROLE_CLASSIFICATION}"'",
"grantType": "'"${GRANT_TYPE}"'",
"roleCategory": "'"${ROLE_CATEGORY}"'",
"readOnly": false,
"attributes": '${ROLE_ATTRIBUTES}',
"authorisations": '${AUTHORISATIONS}'
}
]
}'
2 changes: 2 additions & 0 deletions bin/variables/load-preview-environment-variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ echo "export SERVICE_AUTH_PROVIDER_API_BASE_URL=http://rpe-service-auth-provider
echo "export IDAM_API_BASE_URL=https://idam-api.aat.platform.hmcts.net"
echo "export CCD_IDAM_REDIRECT_URL=https://ccd-case-management-web-aat.service.core-compute-aat.internal/oauth2redirect"
echo "export CCD_DEFINITION_STORE_API_BASE_URL=https://ccd-definition-store-fpl-case-service-pr-${pr}.preview.platform.hmcts.net"
echo "export ROLE_ASSIGNMENT_URL=https://am-role-assignment-service-fpl-case-service-pr-${pr}.preview.platform.hmcts.net"
echo "export CAMUNDA_BASE_URL=https://camunda-fpl-case-service-pr-${pr}.preview.platform.hmcts.net"

# definition placeholders
echo "export CCD_DEF_CASE_SERVICE_BASE_URL=http://fpl-case-service-pr-${pr}-java"

This file was deleted.

14 changes: 13 additions & 1 deletion charts/fpl-case-service/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: fpl-case-service
apiVersion: v2
home: https://github.com/hmcts/fpl-ccd-configuration
version: 1.12.80
version: 1.12.81
description: FPL Case Service
maintainers:
- name: HMCTS Family Public Law team
Expand Down Expand Up @@ -39,3 +39,15 @@ dependencies:
version: 1.0.2
repository: 'https://hmctspublic.azurecr.io/helm/v1/repo/'
condition: postgresql.enabled
- name: servicebus
version: 1.0.7
repository: 'https://hmctspublic.azurecr.io/helm/v1/repo/'
condition: servicebus.enabled
- name: wa
version: ~1.0.5
repository: 'https://hmctspublic.azurecr.io/helm/v1/repo/'
condition: wa.enabled
- name: ccd-message-publisher
version: ~0.1.11
repository: 'https://hmctspublic.azurecr.io/helm/v1/repo/'
condition: ccd-message-publisher.enabled
Loading
Loading