Giter Site home page Giter Site logo

ministryofjustice / hmcts-common-platform-mock-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 11.0 2.0 3.71 MB

Mock for HMCTS Common Platform API

Ruby 88.60% Dockerfile 0.25% Shell 0.12% JavaScript 0.63% CSS 0.11% HTML 9.92% SCSS 0.07% Mustache 0.31%
common-platform crime-apps

hmcts-common-platform-mock-api's Introduction

HMCTS Common Platform Mock API

Set up

This is a standard 6 Rails API application which requires:

Clone the repo, then:

Database setup

Running the tests and the application server locally with require a local Postgres database running. This can be done using docker with the following command. This runs the same database image that is used in the CircleCI tests.

docker run -d --name hmcts-mock-db -p 5432:5432 cimg/postgres:14.11

Populate .env file

There is a template .env file included in the repository which will need to be updated with the required values.

As this file is tracked in the repository it is best to avoid populating it with secrets incase it is committed pushed to GitHub. Therefore the recommendation is to create new files e.g. .env.development.local and .env.test.local which are in the gitignore file. The settings in these env files can be used by prefacing all rails and rspec commands with the RAILS_ENV environment variable e.g.

RAILS_ENV=test rails s

The rails environment should be set to test for running the test suite or development for running/debugging the application server locally

The DEV client id and secret refer to the Court Data Adaptor (DEV) OAuth2.0 credentials. These can be found in the encrypted helm values file.

LAA_DEV_CLIENT_ID=
LAA_DEV_CLIENT_SECRET=

The database url should be setup to point to your local Postgres database e.g.

DATABASE_URL=postgres://postgres:@localhost:5432/hmcts_common_platform_api_test

Setup the app

Clone this repo, then run:

bundle install
RAILS_ENV=development rails db:setup

You can then start the application server by running:

RAILS_ENV=development rails s

By default, the application will listen on port 3000 as defined in puma.rb. You can verify your setup by sending a request to an endpoint and checking for a HTTP response code of 2xx/Success. The credentials for the HTTP Basic Authentication are defined in .env.

curl -u admin:password --head http://localhost:3000/admin/prosecution_cases

Running the App using docker compose

The application and associated database can be started up using the following docker compose command. By default the base .env file will be used however you can set the .env.test.local or .env.development.local files using the --env-file argument.

docker-compose --env-file .env.development.local up --build

Running the tests

The RSpec test can be run using the following command:

RAILS_ENV=test bundle exec rspec

Generate demonstration data

Tasks have been created to facilitate generation of a small specific, rememberable set of demonstration data. This data reflects current understanding of a bare minimum needed to effectively demonstrate the workings of this adaptor and its user interface View court data.

To generate demo data:

rake mock:demodata:load

To destroy demo data:

rake mock:demodata:unload

Publish HearingResulted to LAA

Run the rake task by passing in the hearing id as an argument

bundle exec rails 'publish:hearing[HEARING_ID]'

This will trigger a publish to the LAA Adaptor service defined by the environment variable LAA_DEV_API_URL

Decrypting secrets for deployment

NOTE: git-crypt is required to store secrets needed for all environments. To be able to modify those secrets, git-crypt needs to be set up according to the following guide.

This requires your gpg key to have been added to git-crypt. Liaise with another developer to action the steps in git-crypt.md

Once the pull request has been merged, pull master and run

git-crypt unlock

hmcts-common-platform-mock-api's People

Contributors

alexdesi avatar archferns avatar arthurashman avatar chris-groves avatar dependabot-preview[bot] avatar dependabot[bot] avatar hkhela avatar jsugarman avatar kmahern avatar laurentqro avatar mhowell494 avatar mpw5 avatar msahilan07 avatar mtac50 avatar nittagr avatar pking-moj avatar snyk-bot avatar stone-dj avatar willmcb avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hmcts-common-platform-mock-api's Issues

A branch protection setting is not enabled: administrators require review

Hi there
The default branch protection setting called administrators require review is not enabled for this repository
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require a pull request before merging option
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

User access removed, access is now via a team

Hi there

This user had Direct Member access to this repository and access via a team.

Access is now only via a team.

If you have any questions, please post in #ask-operations-engineering on Slack.

This issue can be closed.

A branch protection setting is not enabled: codeowners require reviews

Hi there
The default branch protection setting called codeowners require review is not enabled for this repository
This option affects a pull request, i.e a PR will need to be reviewed and approved by a CODEOWNER before it can be merged.
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Require review from Code Owners option
Create a .github/CODEOWNERS file
Add a or multiple entries of @ministryofjustice/team_name to the CODEOWNERS file
The team_name shall be a team from within the MoJ teams: https://github.com/orgs/ministryofjustice/teams
See GH Codeowners documentation: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

Default branch is not main

Hi there
The default branch for this repository is not set to main
See repository settings/settings/branches to rename the default branch to main and ensure the Branch protection rules is set to main as well
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

User access removed, access is now via a team

Hi there

This user had Direct Member access to this repository and access via a team.

Access is now only via a team.

If you have any questions, please post in #ask-operations-engineering on Slack.

This issue can be closed.

A branch protection setting is not enabled: Include administrators

Hi there
The default branch protection setting called Include administrators is not enabled for this repository
See repository settings/Branches/Branch protection rules
Either add a new Branch protection rule or edit the existing branch protection rule and select the Include administrators option
This will enable the branch protection rules to admin uses as well
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

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.