Skip to content

Frontend for the Knowledge Based Verification Credential Issuer

License

Notifications You must be signed in to change notification settings

govuk-one-login/ipv-cri-kbv-front

Repository files navigation

Digital Identity Credential Issuer

di-ipv-cri-kbv-front

Frontend for the Knowledge Based Verification Credential Issuer

This is the home for the front end user interface for a credential issuer as a part of the Identity Proofing and Verification (IPV) system within the GDS digital identity platform. Other repositories are used for core services or other credential issuers.

Installation

Clone this repository and then run

yarn install

Precommit Hooks

Install pre-commit from here

Run pre-commit install to install pre-commit hooks locally.

If you get the error:

[ERROR] Cowardly refusing to install hooks with `core.hooksPath` set.

Run git config --unset-all core.hooksPath to reset your git hook settings.

Environment Variables

  • 'BASE_URL': Externally accessible base url of the webserver. Used to generate the callback url as part of credential issuer oauth flows
  • PORT - Default port to run webserver on. (Default to 5020)
  • GA4_DISABLED - Feature flag to disable GA4, defaulted to false
  • UA_DISABLED - Feature flag to disable UA, defaulted to true
  • UA_CONTAINER_ID - Container ID for Universal Analytics, required for UA to work correctly. Default value is GTM-TK92W68
  • GA4_CONTAINER_ID - Container ID for GA4, required for analytics to work correctly. Default value is GTM-KD86CMZ
  • ANALYTICS_COOKIE_DOMAIN - Cookie domain to persist values throughout the different sections of the OneLogin journey. Default value is localhost
  • LANGUAGE_TOGGLE_DISABLED - Feature flag to disable Language Toggle, defaulted to true

Mock Data

Wiremock has been used to create a stateful mock of the API, through the use of scenarios. These configuration files are stored as JSON files in the ./test/mocks/mappings directory.

This can be run by using:

yarn run mock

The frontend can be configured to use this mock server through two environment variables:

  • NODE_ENV = development - this enables a middleware that passes the x-scenario-id header from web requests through to the API
  • API_BASE_URL = http://localhost:8090 - this points the frontend at the Wiremock instance

A browser extension, such as Mod Header, can be used to set the value of this header in a web browser.

Request properties

In order to support consistent use of headers for API requests, middleware is applied to add an instance of axios on each request onto req.axios. This is then reused in any code that uses the API.

Browser tests

Browser based tests can be run against the mock server, and should be able to be run against an instance of the API.

These tests are written using Cucumber as the test runner and Playwright as the automation tool. They also follow the Page Object Model for separation of concerns.

They can be run by using:

yarn run test:browser

Using mocked scenario data

Any cucumber feature or scenario with a tag prefixed with @mock-api:

e.g.

  @mock-api:question-error
  Scenario: API error
...

This scenario will be configured to send a scenario-id header of question-error on every web browser request.

Code Owners

This repo has a CODEOWNERS file in the root and is configured to require PRs to reviewed by Code Owners.