Skip to content

hmrc/universal-credit-liability-tests

Repository files navigation

universal-credit-liability-tests

Universal Credit Liability API tests.

Pre-requisites

Services

Start Mongo Docker container as follows:

docker run --rm -d -p 27017:27017 --name mongo percona/percona-server-mongodb:6.0

Start UNIVERSAL_CREDIT_LIABILITY_ALL services as follows:

sm2 --start UNIVERSAL_CREDIT_LIABILITY_ALL

Tests

Run tests as follows:

  • Argument <environment> must be local, dev, qa or staging.
./run-tests.sh <environment>

Scalafmt

Check all project files are formatted as expected as follows:

sbt scalafmtCheckAll scalafmtCheck

Format *.sbt and project/*.scala files as follows:

sbt scalafmtSbt

Format all project files as follows:

sbt scalafmtAll

Bruno testing

Bruno collection is set up for conducting manual tests and can be found under bruno. It has been developed and tested for Bruno v2.1.0. To use, in Bruno just select open collection, navigate to the bruno folder and open.

There are two configured environment profiles, Local and QA. There are also two auth requests, corresponding to the two environment profiles.

For more info on environment variables in Bruno see https://docs.usebruno.com/get-started/variables/environment-variables

Before you can make requests to the Universal Credit Liability Notification API, a valid auth token is required. This is obtained by triggering the auth requests corresponding to the environment profile selected (it will fail otherwise).

After a successful authentication request, the obtained auth token will be stored as a secret environment variable and utilised by the Universal Credit Liability Notification API requests. The auth token may be valid for a different length of time depending on the environment. e.g. QA = 4 hours

QA auth

For Auth/QA, a privileged application subscribing to the API needs to have already been preconfigured. The Bruno collection also has a dependency on an external JavaScript library totp-generator which will require nodejs.

After installing node, execute:

cd bruno
npm i

And then enable Developer Mode in Bruno.

For more info on external libraries in Bruno see https://docs.usebruno.com/testing/script/external-libraries

The QA environment is only semi configured, all the fields related to oauth 2.0 are specified as secrets which are not commited to the repo and will need to be manually set. This is done because these secrets can all expire and change.

Required QA Environment variables Description
clientId The client id to the QA application
clientSecret any valid client secret generated by the QA application
TOTP_SECRET The TOTP Secret for the given QA application

The other secret variables are placeholders for temporary variables as part of the authentication process, they do not need to be configured. These are pre-specified so they also don't get commited to the repo.

For more info on Bruno's secret variables see https://docs.usebruno.com/secrets-management/secret-variables

License

This code is open source software licensed under the Apache 2.0 License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages