Skip to content

hmcts/ccd-user-profile-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ccd-user-profile-api

API Docs License: MIT Build Status Docker Build Status codecov Codacy Badge Codacy Badge Known Vulnerabilities HitCount

UI preferences for Core Case Data users.


Getting started

Prerequisites

Environment variables

The following environment variables are required:

Name Default Description
USER_PROFILE_DB_USERNAME - Username for database
USER_PROFILE_DB_PASSWORD - Password for database
USER_PROFILE_S2S_AUTHORISED_SERVICES ccd_data,ccd_definition,ccd_admin Authorised micro-service names for S2S calls
IDAM_S2S_URL - Base URL for IdAM's S2S API service (service-auth-provider). http://localhost:4502 for the dockerised local instance or tunneled dev instance.
AZURE_APPLICATIONINSIGHTS_INSTRUMENTATIONKEY - For CNP environment this is provided by the terraform scripts. However any value would do for your local environment.

Building

The project uses Gradle.

To build project please execute the following command:

./gradlew clean build

Gradle Upgrades

It is important to run the following command and commit the updated gradle-wrapper.jar to the repository for proper gradle upgrades

# this sample is for v4.9 replace with correct upgrade version
./gradlew wrapper --gradle-version 4.9 --distribution-type all

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

The above will build both the application and database images. If you want to build only one of them just specify the name assigned in docker compose file, e.g.:

docker-compose build ccd-user-profile-api

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

docker-compose up

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

  • Database exposing port 5453
  • API exposing ports 4453

Handling database

Database will get initiated when you run docker-compose up for the first time by execute all scripts from database directory.

You don't need to migrate database manually since migrations are executed every time docker-compose up is executed.

You can connect to the database at http://localhost:5453 with the username and password set in the environment variables.

API

Their are currently 2 endpoints:

  • POST /user-profile/users - this is used to create a User Profile as well as it's associated Jurisdictions. At least one Jurisdiction must be defined in order to create a User Profile. Also, there is currently no way to amend a User's Jurisdictions other than manually removing them from the database and creating a new User.
  • GET /user-profile/users/{uid}/jurisdictions - this is used to retrieve a String[] of Jurisdictions ID for the given User ID.

Create a User

To create a user the following example JSON can be used:

{
	"id" : "user1",
	"jurisdictions" : [{
			"id" : "TEST1"
		}, {
			"id" : "TEST2"
		}
	]
}

Functional Tests

The functional tests are located in aat folder. The tests are written using befta-fw library. To find out more about BEFTA Framework, see the repository and its README here.

LICENSE

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