diff --git a/.github/workflows/ui_test_job.yml b/.github/workflows/ui_test_job.yml index 0810fe259a..e1de8e8891 100644 --- a/.github/workflows/ui_test_job.yml +++ b/.github/workflows/ui_test_job.yml @@ -48,6 +48,15 @@ on: github_access_token: description: 'Github Token' required: true + test_onelogin_basic_auth: + description: 'Test OneLogin basic auth' + required: false + test_onelogin_totp_key: + description: 'Test OneLogin totp key' + required: false + test_onelogin_password: + description: 'Test OneLogin password' + required: false defaults: run: @@ -120,6 +129,9 @@ jobs: env: CYPRESS_baseUrl: ${{ inputs.base_url }} CYPRESS_RECORD_KEY: ${{ secrets.cypress_record_key }} + CYPRESS_TEST_ONELOGIN_BASIC_AUTH: ${{ secrets.test_onelogin_basic_auth }} + CYPRESS_TEST_ONELOGIN_TOTP_KEY: ${{ secrets.test_onelogin_totp_key }} + CYPRESS_TEST_ONELOGIN_PASSWORD: ${{ secrets.test_onelogin_password }} GITHUB_TOKEN: ${{ secrets.github_access_token }} run: yarn run cypress:parallel-with-specs --spec ${{ inputs.specs }} diff --git a/.github/workflows/workflow_pr.yml b/.github/workflows/workflow_pr.yml index dced46a5c4..0ed8c42073 100644 --- a/.github/workflows/workflow_pr.yml +++ b/.github/workflows/workflow_pr.yml @@ -145,6 +145,9 @@ jobs: aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ACTIONS }} cypress_record_key: ${{ secrets.CYPRESS_RECORD_KEY }} github_access_token: ${{ secrets.GITHUB_TOKEN }} + test_onelogin_basic_auth: ${{ secrets.TEST_ONELOGIN_BASIC_AUTH }} + test_onelogin_totp_key: ${{ secrets.TEST_ONELOGIN_TOTP_KEY }} + test_onelogin_password: ${{ secrets.TEST_ONELOGIN_PASSWORD }} always_remove_ingress: name: Remove CI ingress from environment diff --git a/cypress/smoke/smoke.cy.js b/cypress/smoke/smoke.cy.js index fa97ac39c6..ca63b6ce72 100644 --- a/cypress/smoke/smoke.cy.js +++ b/cypress/smoke/smoke.cy.js @@ -1,20 +1,51 @@ +const { TOTP } = require("totp-generator"); + describe('Smoke tests', () => { - describe('external dependencies', () => { - describe('UID service', () => { - it('request signing and base URL are configured correctly', () => { - cy.request('/health-check/dependency').should((response) => { - expect(response.status).not.to.eq(403) - }) - }) + describe('external dependencies', () => { + describe('UID service', () => { + it('request signing and base URL are configured correctly', () => { + cy.request('/health-check/dependency').should((response) => { + expect(response.status).not.to.eq(403) }) + }) }) + }) - describe('app', () => { - it('is available', () => { - cy.visit('/') + describe('app', () => { + it('is available', () => { + cy.visit('/') - cy.get('h1').should('contain', 'Make and register a lasting power of attorney (LPA)'); - cy.contains('a', 'Start'); - }) + cy.get('h1').should('contain', 'Make and register a lasting power of attorney (LPA)'); + + if (Cypress.config().baseUrl.includes('1221mlpab18')) { + cy.intercept('https://signin.integration.account.gov.uk/**', (req) => { + req.headers['Authorization'] = 'Basic ' + btoa(Cypress.env('TEST_ONELOGIN_BASIC_AUTH')); + }); + + cy.contains('a', 'Start').click({ timeout: 40000 }); + + const { otp } = TOTP.generate(Cypress.env('TEST_ONELOGIN_TOTP_KEY')); + + cy.origin('https://signin.integration.account.gov.uk', { args: { token: otp } }, ({ token }) => { + cy.url().should('contain', '/sign-in-or-create', { timeout: 30000 }); + + cy.contains('Sign in').click(); + cy.get('[type=email]').type('opgteam+modernising-lpa@digital.justice.gov.uk'); + cy.get('form').submit(); + cy.get('[type=password]').type(Cypress.env('TEST_ONELOGIN_PASSWORD')); + cy.get('form').submit(); + + cy.get('[name=code]').type(token); + cy.contains('button', 'Continue').click(); + }); + + cy.origin('https://preproduction.app.modernising.opg.service.justice.gov.uk', () => { + cy.url().should('contain', '/dashboard'); + cy.contains('Manage your LPAs'); + }); + } else { + cy.contains('a', 'Start'); + } }) + }) }) diff --git a/package.json b/package.json index 5266118757..3b96d6b912 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "esbuild": "^0.20.0", "govuk-frontend": "5.3.1", "jquery": "^3.6.1", - "sass": "^1.56.1" + "sass": "^1.56.1", + "totp-generator": "^1.0.0" }, "devDependencies": { "axe-core": "^4.6", diff --git a/yarn.lock b/yarn.lock index ec094c79e8..7d98bd1e7c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1501,6 +1501,11 @@ jsprim@^2.0.2: json-schema "0.4.0" verror "1.10.0" +jssha@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/jssha/-/jssha-3.3.1.tgz#c5b7fc7fb9aa745461923b87df0e247dd59c7ea8" + integrity sha512-VCMZj12FCFMQYcFLPRm/0lOBbLi8uM2BhXPTqw3U4YAfs4AZfiApOoBLoN8cQE60Z50m1MYMTQVCfgF/KaCVhQ== + lazy-ass@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/lazy-ass/-/lazy-ass-1.6.0.tgz#7999655e8646c17f089fdd187d150d3324d54513" @@ -2117,6 +2122,13 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +totp-generator@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/totp-generator/-/totp-generator-1.0.0.tgz#00a3532dbece7a08950a6318c1317bff3b609510" + integrity sha512-Iu/1Lk60/MH8FE+5cDWPiGbwKK1hxzSq+KT9oSqhZ1BEczGIKGcN50bP0WMLiIZKRg7t29iWLxw6f81TICQdoA== + dependencies: + jssha "^3.3.1" + tough-cookie@^4.1.3: version "4.1.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf"