From 09e5f65516327e37f3521e8e9652ac80b27488ca Mon Sep 17 00:00:00 2001 From: John Shields Date: Wed, 20 Mar 2024 13:43:37 +0000 Subject: [PATCH] PP-11681 Require RESTClientError from axios code in common library in order to revert test condition introduced to make cypress test pass. --- .secrets.baseline | 24 +++++++++---------- .../registration/registration.controller.js | 5 ++-- .../registration.controller.test.js | 3 ++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 59c01439b9..2ca77a5679 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -136,21 +136,21 @@ "filename": "app/controllers/registration/registration.controller.js", "hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", "is_verified": false, - "line_number": 24 + "line_number": 25 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.js", "hashed_secret": "cbb085747f0bcbeac56f2a583779b44c8f445d92", "is_verified": false, - "line_number": 25 + "line_number": 26 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.js", "hashed_secret": "7b652417979832c620feec2e89b92c56a291ae52", "is_verified": false, - "line_number": 107 + "line_number": 108 } ], "app/controllers/registration/registration.controller.test.js": [ @@ -159,56 +159,56 @@ "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "9695086041c462c6598c6dd5e35d3a2c9cbbe5f8", "is_verified": false, - "line_number": 175 + "line_number": 176 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "7b652417979832c620feec2e89b92c56a291ae52", "is_verified": false, - "line_number": 176 + "line_number": 177 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "f5378ce7cd012d12a9be51e6be241b1e66240879", "is_verified": false, - "line_number": 183 + "line_number": 184 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "69c8d31085756bfd34bb8ca6d393289374b7d7c2", "is_verified": false, - "line_number": 190 + "line_number": 191 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "3f3c2dca191782c9b8b2f513d16abaa66dc543bf", "is_verified": false, - "line_number": 197 + "line_number": 198 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "0ee4c488221aee414cd9ae5300e28d11c2851fe5", "is_verified": false, - "line_number": 212 + "line_number": 213 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "d8fe3060b1c00ad00ece5d205e493764b113b94c", "is_verified": false, - "line_number": 218 + "line_number": 219 }, { "type": "Secret Keyword", "filename": "app/controllers/registration/registration.controller.test.js", "hashed_secret": "a04fccdd7f93b63162cd0d3e015761cd3a24d86a", "is_verified": false, - "line_number": 326 + "line_number": 327 } ], "app/controllers/your-psp/worldpay-3ds-flex-validations.test.js": [ @@ -903,5 +903,5 @@ } ] }, - "generated_at": "2024-01-17T17:13:09Z" + "generated_at": "2024-03-20T13:39:41Z" } diff --git a/app/controllers/registration/registration.controller.js b/app/controllers/registration/registration.controller.js index 8351269636..888bf3b7fe 100644 --- a/app/controllers/registration/registration.controller.js +++ b/app/controllers/registration/registration.controller.js @@ -4,7 +4,8 @@ const qrcode = require('qrcode') const lodash = require('lodash') const logger = require('../../utils/logger')(__filename) -const { RESTClientError, ExpiredInviteError } = require('../../errors') +const { ExpiredInviteError } = require('../../errors') +const { RESTClientError } = require('@govuk-pay/pay-js-commons/lib/utils/axios-base-client/errors') const adminusersClient = require('../../services/clients/adminusers.client')() const paths = require('../../paths') const { @@ -53,7 +54,7 @@ async function submitEmailPage (req, res, next) { res.redirect(paths.register.checkEmail) } catch (err) { - if (err instanceof RESTClientError | err.constructor.name === 'RESTClientError') { + if (err instanceof RESTClientError) { if (err.errorCode === 403) { errors[EMAIL_INPUT_FIELD_NAME] = validationErrors.notPublicSectorEmail return res.render('registration/email', { errors, email }) diff --git a/app/controllers/registration/registration.controller.test.js b/app/controllers/registration/registration.controller.test.js index c839dd4eee..264651941e 100644 --- a/app/controllers/registration/registration.controller.test.js +++ b/app/controllers/registration/registration.controller.test.js @@ -3,7 +3,8 @@ const sinon = require('sinon') const { expect } = require('chai') const inviteFixtures = require('../../../test/fixtures/invite.fixtures') -const { RESTClientError, ExpiredInviteError } = require('../../errors') +const { ExpiredInviteError } = require('../../errors') +const { RESTClientError } = require('@govuk-pay/pay-js-commons/lib/utils/axios-base-client/errors') const { paths } = require('../../routes') const registrationController = require('./registration.controller') const { APP, SMS } = require('../../models/second-factor-method')