This service manages users for The Cabinet Office's Apply for a Grant service
- IntelliJ (Community or Ultimate)
- Java 17
- Homebrew
- Postgres
- pgadmin also recommended
- Docker
- Install Colima using the instructions here: GitHub - abiosoft/colima: Container runtimes on macOS (and Linux) with minimal setup
- You’ll also need Docker command line so make sure to read that part of the Colima instructions
- run
colima start
- run
docker pull postgres
- run
docker run -itd -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 --name postgres-local postgres
- connect to the database using pgaAdmin or any other DMS and seed the database with the script you can find in src/main/resources/db/Users-setup-LOCAL.sql
- NOTE: to start this container AFTER the first time you run this command, just use
docker start postgres-local
Install PGAdmin either through docker or directly onto your system then connect to the instance of Postgres you’ve just started:- host:
localhost
or127.0.0.1
(orhost.docker.internal
if you also run PGAdmin with docker) - port:
5432
- username:
postgres
- password:
mysecretpassword
- host:
- Install postgres and pgadmin
- run
brew services start postgresql
- open pgadmin and create a database called
gapuserlocaldb
- update your application.properties database username and password. Default user/pass for the
postgres
user ispostgres
/postgres
- spring.datasource.username
- spring.datasource.password
- seed the database with the script you can find in src/main/resources/db/Users-setup-LOCAL.sql
Wiremock can be used in local development to stub responses from OneLogin API.
To start wiremock server on http://localhost:8888
cd mockOneLogin
docker compose up -d
Ensure One Login base URL points to Wiremock
onelogin.base-url=http://localhost:8888
Request Mappings are found in mockOneLogin/wiremock
New mappings should be added to mockOneLogin/wiremock/mappings
ensuring file name conforms to using UUID
Responses that return JSON should be added to mockOneLogin/wiremock/__files
- Configure IntelliJ to use the Java 17 SDK
- Set up the database as above
- Install your dependencies with Maven, using the Maven tab in IntelliJ:
- Download Sources and/or Documentation
- Generate Sources and Update Folders For All Projects
- Reload All Maven Projects
- Ensure you have the following in your application.properties:
- feature.onelogin.enabled=true
- feature.onelogin.migration.enabled=true
- Run GapUserServiceApplication.java
- If successful, you should see a message at the bottom of the terminal stating:
g.c.g.GapUserServiceApplication : Started GapUserServiceApplication in X.xxx seconds
-
ensure that the email and sub in the gaplocaluserdb>gap_users table match what's returned in wiremock
- you must restart the wiremock server if you make any changes to the files in mockOneLogin
-
ensure that ONE_LOGIN_ENABLED is true in all your projects
-
ensure that the ports match up between your FE and BE
-
if you're logging in as an admin, ensure that admin has a department
-
if you're having trouble running the migration scripts
- run
mvn flyway:clean
- then
mvn clean flyway:migrate
- then rerun the service
- run
-
if you're having trouble installing a new package in your pom.xml:
- open the Maven tab in IntelliJ, and check the 3 buttons in the top-left of the tab
- click "Download Sources and/or Documentation" > "Download Sources and Documentation"
- click "Reload All Maven Projects"
- It should now be working!