Giter Club home page Giter Club logo

am-role-assignment-service's Introduction

role-assignment-service

API Docs Quality Gate Status Security Rating Vulnerabilities Maintainability Rating Coverage

Role Assignment Service

Purpose

This SpringBoot application covers the implementation of the Role Assignment Service, which manages the assignment of roles with attributes to actors, to support both ccd access control and work allocation requirements.

  1. The core service manages role assignments, including both case roles and organisational roles. The service is responsible for robust validation of role assignments, against a set of configured rules and/or configuration.
  2. Role assignments are made available through a queryable API to two major consumers: the Case Access Control and Work Allocation.

Prerequisites

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

  • Java 11
  • Docker (optional)

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

Environment variables

The following environment variables are required:

Name Default Description
  |ROLE_ASSIGNMENT_S2S_AUTHORISED_SERVICES| ccd_gw,am_role_assignment_service,am_org_role_mapping_service,wa_task_management_api,aac_manage_case_assignment,ccd_data|
  |AM_ROLE_ASSIGNMENT_SERVICE_SECRET|
  |IDAM_USER_URL| http://idam-api:5000 |
  |IDAM_S2S_URL| http://service-auth-provider-api:8080|
  |ROLE_ASSIGNMENT_IDAM_CLIENT_ID|am_docker|
  |ROLE_ASSIGNMENT_IDAM_CLIENT_SECRET|am_docker_secret|
  |ROLE_ASSIGNMENT_IDAM_REDIRECT_URI|http://localhost:4096/oauth2redirect|
  |ROLE_ASSIGNMENT_IDAM_ADMIN_USERID|[email protected]|
  |ROLE_ASSIGNMENT_IDAM_ADMIN_PASSWORD|Pa55word11|
  |ROLE_ASSIGNMENT_IDAM_ADMIN_SCOPE|search-user|
  |CCD_DATA_STORE_URL|http://localhost:4452|
  |LAUNCH_DARKLY_ENV|local|
  |LD_SDK_KEY|"Please contact the AM team for getting this key"|

Building the application

The project uses Gradle as a build tool. It already contains ./gradlew wrapper script, so there's no need to install gradle.

To build the project execute the following command:

  ./gradlew build

To clean up your environment use the following, it will delete any temporarily generated files such as reports.

  ./gradlew clean

Running

If you want your code to become available to other Docker projects (e.g. for local environment testing), you need to build the image:

docker-compose build

When the project has been packaged in target/ directory, you can run it by executing following command:

docker-compose up

Note: This setup requires both IDAM and serviceAuth application to be running in Local docker network 'am-docker'. Please follow the am-docker project to setup these dependencies.

As a result the following containers will get created and started:

  • API exposing port 4096

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

./gradlew clean bootRun

If required, to run with a low memory consumption, the following can be used:

./gradlew --no-daemon assemble && java -Xmx384m -jar build/libs/role-assoignment-service.jar

Using the application

To understand if the application is working, you can call it's health endpoint:

curl http://localhost:4096/health

If the API is running, you should see this response:

{"status":"UP"}

DB Initialisation˙

The application uses a Postgres database which can be run through a docker container on its own if required.

The application should automatically apply any database migrations using liquibase.

Running integration tests:

You can run the integration tests as follows:

./gradlew integration

Running functional tests:

If the API is running (either inside a Docker container or via gradle bootRun) you can run the functional tests as follows:

./gradlew functional

Running smoke tests:

If the API is running (either inside a Docker container or via gradle bootRun) you can run the smoke tests as follows:

./gradlew smoke

Running mutation tests tests:

If you have some time to spare, you can run the mutation tests as follows:

./gradlew pitest

If you are using windows machine to run PI test , use following property in gradle.build under pitest section.

 useClasspathFile = true

As the project grows, these tests will take longer and longer to execute but are useful indicators of the quality of the test suite.

More information about mutation testing can be found here: http://pitest.org/

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

Remember to return the localhost back to the remote broker

Endpoints

Authorization(OIDC user token) and ServiceAuthorization (S2S) tokens are required in the headers for all endpoints.

POST /am/role-assignments
  • Used for creating multiple role assignments records. Also requires a request body payload containing:
  1. roleRequest
  2. requestedRoles
GET /am/role-assignments/actors/{actorId}
  • Retrieve JSON representation of multiple Role Assignment records.
GET ​/am​/role-assignments
  • Get Role assignment records by Case Id and Actor Id for RoleType as a CASE.
GET /am/role-assignments/roles
  • Retrieves a list of roles available in role assignment service.
DELETE /am/role-assignments/
  • Deletes multiple role assignment based on query parameters. Also requires following request params
  1. process {string}
  2. reference {string}
DELETE /am/role-assignments/{assignmentId}
  • Deletes single role assignment by assignment Id.

Functional Tests

The functional tests are located in functionalTest folder. These are the tests run against an environment. For example if you would like to test your local environment you'll need to export the following variables on your .bash_profile script.

#Functional Tests
export BEFTA_S2S_CLIENT_ID=am_role_assignment_service
export BEFTA_S2S_CLIENT_SECRET=AAAAAAAAAAAAAAAC
export BEFTA_RESPONSE_HEADER_CHECK_POLICY=JUST_WARN
export OAUTH2_CLIENT_ID=am_docker
export OAUTH2_CLIENT_SECRET=am_docker_secret
export OAUTH2_ACCESS_TOKEN_TYPE=OIDC
export OAUTH2_SCOPE_VARIABLES=openid%20profile%20roles%20authorities
export OAUTH2_REDIRECT_URI=http://localhost:4096/oauth2redirect
export IDAM_CLIENT_ID=am_role_assignment
export OPENID_SCOPE_VARIABLES =openid+profile+roles+authorities
export TEST_AM_USER1_BEFTA_PWD=Pa55word11
export TEST_AM_USER2_BEFTA_PWD=Pa55word11
export TEST_AM_USER3_BEFTA_PWD=Pa55word11

####Running the tests

In order to run the tests you will need to pull down am-docker repo and checkout the master branch.

Run the scripts as instructed in am-docker page . Once this is done, try to run your functional tests.

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details.

am-role-assignment-service's People

Contributors

aashishaggarwal123 avatar abul-syed avatar adewumio-hmcts avatar arshinsalim avatar conorh994 avatar dependabot-preview[bot] avatar dependabot[bot] avatar dharmendra8186 avatar github-actions[bot] avatar hmcts-jenkins-a-to-c[bot] avatar hmcts-jenkins-cft[bot] avatar hmcts-jenkins-d-to-i[bot] avatar isaacola-hub avatar karthikarenjith avatar lukehalsall avatar mattnayler avatar mikebrownccd avatar nitinsahu1 avatar nitishsingla1234 avatar poojithanag avatar prashanthkumarnb avatar renovate-bot avatar renovate[bot] avatar ruban72 avatar sankar-padakula avatar sivakanukolluqa avatar tomxelliott avatar vijayrajagopalan-hmcts avatar vladkovalskyi avatar yashikno avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

am-role-assignment-service's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency org.apache.poi:poi-ooxml to v5.3.0
  • Update dependency org.apache.poi:poi-scratchpad to v5.3.0
  • Update dependency org.pitest:pitest to v1.16.1
  • Update dependency org.postgresql:postgresql to v42.7.3
  • Update dependency org.springdoc:springdoc-openapi-ui to v1.8.0
  • Update log4j2 monorepo to v2.23.1 (org.apache.logging.log4j:log4j-to-slf4j, org.apache.logging.log4j:log4j-api)
  • Update plugin com.github.ben-manes.versions to v0.51.0
  • Update plugin org.sonarqube to v4.4.1.3373
  • Update postgres Docker tag to v15.7
  • Update spring security to v5.8.13 (org.springframework.security:spring-security-test, org.springframework.security:spring-security-oauth2-resource-server, org.springframework.security:spring-security-oauth2-jose, org.springframework.security:spring-security-oauth2-core, org.springframework.security:spring-security-oauth2-client, org.springframework.security:spring-security-crypto, org.springframework.security:spring-security-config, org.springframework.security:spring-security-web, org.springframework.security:spring-security-core)
  • Update versions.drools to v7.74.1.Final (org.kie:kie-ci, org.drools:drools-decisiontables, org.drools:drools-compiler, org.drools:drools-core)
  • Update dependency com.github.hmcts:idam-java-client to v3
  • Update dependency com.github.tomakehurst:wiremock-jre8 to v3
  • Update dependency com.google.guava:guava to v33
  • Update dependency com.launchdarkly:launchdarkly-java-server-sdk to v7
  • Update dependency io.github.openfeign:feign-jackson to v13
  • Update dependency org.json:json to v20240303
  • Update dependency pmd to v7
  • Update dependency ubuntu to v22
  • Update flyway to v10 (major) (org.flywaydb:flyway-core, org.flywaydb.flyway)
  • Update hmctspublic.azurecr.io/base/java Docker tag to v21
  • Update plugin org.sonarqube to v5
  • Update postgres Docker tag to v16
  • Update versions.drools to v9 (major) (org.kie:kie-ci, org.drools:drools-decisiontables, org.drools:drools-compiler, org.drools:drools-core)
  • Update versions.serenity to v4 (major) (net.serenity-bdd:serenity-spring, net.serenity-bdd:serenity-rest-assured, net.serenity-bdd:serenity-junit, net.serenity-bdd:serenity-core)
  • Update versions.tomcat to v10 (major) (org.apache.tomcat.embed:tomcat-embed-core, org.apache.tomcat.embed:tomcat-embed-websocket)
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

docker-compose
docker-compose.yml
dockerfile
Dockerfile
  • hmctspublic.azurecr.io/base/java 17-distroless
docker/database/Dockerfile
  • postgres 15.2
github-actions
.github/workflows/combine-prs.yml
  • ubuntu 20.04
.github/workflows/swagger.yml
  • hmcts/workflow-publish-openapi-spec v1
gradle
build.gradle
  • net.serenity-bdd:serenity-gradle-plugin 2.4.34
  • info.solidsoft.gradle.pitest:gradle-pitest-plugin 1.15.0
  • uk.gov.hmcts.java 0.12.63
  • io.spring.dependency-management 1.1.6
  • org.springframework.boot 2.7.18
  • info.solidsoft.pitest 1.15.0
  • com.github.ben-manes.versions 0.45.0
  • org.sonarqube 4.0.0.2929
  • com.github.spacialcircumstances.gradle-cucumber-reporting 0.1.25
  • au.com.dius.pact 4.3.12
  • org.flywaydb.flyway 8.5.13
  • org.owasp.dependencycheck 10.0.3
  • pmd 6.54.0
  • jacoco 0.8.8
  • org.springframework.boot:spring-boot-starter-web 2.7.18
  • org.springframework.boot:spring-boot-starter-data-jpa 2.7.18
  • org.springframework.boot:spring-boot-starter-actuator 2.7.18
  • org.springframework.boot:spring-boot-starter-aop 2.7.18
  • org.springframework.boot:spring-boot-starter-json 2.7.18
  • org.springframework.boot:spring-boot-starter-security 2.7.18
  • org.springframework.boot:spring-boot-starter-cache 2.7.18
  • org.springframework.boot:spring-boot-starter-oauth2-client 2.7.18
  • org.springframework.boot:spring-boot-starter-oauth2-resource-server 2.7.18
  • org.springframework.security:spring-security-core 5.7.11
  • org.springframework.security:spring-security-web 5.7.11
  • org.springframework.security:spring-security-config 5.7.11
  • org.springframework.security:spring-security-crypto 5.7.11
  • org.springframework.security:spring-security-oauth2-client 5.7.11
  • org.springframework.security:spring-security-oauth2-core 5.7.11
  • org.springframework.security:spring-security-oauth2-jose 5.7.11
  • org.springframework.security:spring-security-oauth2-resource-server 5.7.11
  • org.springframework.retry:spring-retry 2.0.7
  • org.springframework.cloud:spring-cloud-starter-netflix-hystrix 2.2.10.RELEASE
  • org.springframework.cloud:spring-cloud-starter-bootstrap 3.1.8
  • org.springframework.cloud:spring-cloud-starter-openfeign 2.2.10.RELEASE
  • org.apache.poi:poi 5.2.5
  • org.apache.poi:poi-ooxml 5.2.5
  • org.apache.poi:poi-scratchpad 5.2.5
  • org.springframework:spring-core 5.3.37
  • org.springframework:spring-beans 5.3.37
  • org.springframework:spring-aop 5.3.37
  • org.springframework:spring-aspects 5.3.37
  • org.springframework:spring-context 5.3.37
  • org.springframework:spring-context-support 5.3.37
  • org.springframework:spring-expression 5.3.37
  • org.springframework:spring-jcl 5.3.37
  • org.springframework:spring-jdbc 5.3.37
  • org.springframework:spring-orm 5.3.37
  • org.springframework:spring-tx 5.3.37
  • org.springframework:spring-web 5.3.37
  • org.springframework:spring-webmvc 5.3.37
  • org.springdoc:springdoc-openapi-ui 1.6.8
  • org.springframework.cloud:spring-cloud-starter-bootstrap 3.1.8
  • org.drools:drools-core 7.73.0.Final
  • org.drools:drools-compiler 7.73.0.Final
  • org.drools:drools-decisiontables 7.73.0.Final
  • org.kie:kie-ci 7.73.0.Final
  • org.apache.maven:maven-core 3.8.7
  • org.flywaydb:flyway-core 8.5.13
  • com.google.guava:guava 32.1.3-jre
  • javax.inject:javax.inject 1
  • com.launchdarkly:launchdarkly-java-server-sdk 5.10.9
  • org.apache.tomcat.embed:tomcat-embed-websocket 9.0.91
  • org.apache.tomcat.embed:tomcat-embed-core 9.0.91
  • org.hibernate:hibernate-core 5.6.15.Final
  • com.github.ben-manes.caffeine:caffeine 3.1.8
  • org.postgresql:postgresql 42.6.1
  • com.nimbusds:nimbus-jose-jwt 9.40
  • io.jsonwebtoken:jjwt 0.9.1
  • commons-io:commons-io 2.16.1
  • org.apache.commons:commons-compress 1.26.2
  • commons-beanutils:commons-beanutils 1.9.4
  • org.json:json 20231013
  • commons-fileupload:commons-fileupload 1.5
  • com.github.hmcts.java-logging:logging 6.1.5
  • com.github.hmcts:idam-java-client 2.1.1
  • com.github.hmcts:service-auth-provider-java-client 4.0.2
  • com.fasterxml.jackson.core:jackson-databind 2.17.2
  • com.fasterxml.jackson:jackson-bom 2.17.2
  • com.thoughtworks.xstream:xstream 1.4.20
  • com.microsoft.azure:applicationinsights-spring-boot-starter 2.6.4
  • com.opentable.components:otj-pg-embedded 1.0.3
  • com.github.tomakehurst:wiremock-jre8 2.35.2
  • org.springframework.cloud:spring-cloud-contract-wiremock 3.1.10
  • org.mockito:mockito-core 4.4.0
  • org.junit.jupiter:junit-jupiter-api 5.9.0
  • org.junit.jupiter:junit-jupiter-params 5.9.0
  • org.junit.jupiter:junit-jupiter-engine 5.9.0
  • org.junit.platform:junit-platform-commons 1.9.1
  • org.pitest:pitest 1.15.8
  • info.solidsoft.gradle.pitest:gradle-pitest-plugin 1.15.0
  • org.codehaus.sonar-plugins:sonar-pitest-plugin 0.5
  • org.springframework.security:spring-security-test 5.7.11
  • org.springframework.boot:spring-boot-starter-test 2.7.18
  • io.cucumber:cucumber-java 5.7.0
  • io.rest-assured:rest-assured 3.3.0
  • io.cucumber:cucumber-junit 5.7.0
  • io.github.openfeign:feign-jackson 12.5
  • net.serenity-bdd:serenity-core 2.2.12
  • net.serenity-bdd:serenity-junit 2.2.12
  • net.serenity-bdd:serenity-rest-assured 2.2.12
  • net.serenity-bdd:serenity-spring 2.2.12
  • com.github.hmcts:fortify-client 1.4.3
  • com.github.hmcts:befta-fw 8.7.11
  • io.projectreactor:reactor-core 3.6.8
  • commons-io:commons-io 2.16.1
  • org.projectlombok:lombok 1.18.34
  • org.pitest:pitest-junit5-plugin 1.2.1
  • au.com.dius.pact.provider:junit5 4.1.7
  • au.com.dius.pact.provider:spring 4.1.7
  • au.com.dius.pact.provider:junit5spring 4.1.7
  • org.apache.logging.log4j:log4j-api 2.19.0
  • org.apache.logging.log4j:log4j-to-slf4j 2.19.0
  • ch.qos.logback:logback-classic 1.2.13
  • ch.qos.logback:logback-core 1.2.13
  • net.minidev:json-smart 2.5.1
  • com.fasterxml.jackson.core:jackson-core 2.17.2
  • com.fasterxml.jackson.core:jackson-annotations 2.17.2
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 7.6.4
helm-values
charts/am-role-assignment-service/values.yaml
helmv3
charts/am-role-assignment-service/Chart.yaml
  • java 5.2.1
regex
Dockerfile
  • microsoft/ApplicationInsights-Java 3.5.3
terraform
infrastructure/main.tf
infrastructure/terraform.tf
  • azuread 2.53.1
  • azurerm ~> 3.113.0
terraform-version
infrastructure/.terraform-version
  • hashicorp/terraform 1.8.5

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.